pub struct ProjectDb { /* private fields */ }Expand description
Project database handle.
Implementations§
Source§impl ProjectDb
impl ProjectDb
Sourcepub fn open(db_path: &Path) -> DbResult<Self>
pub fn open(db_path: &Path) -> DbResult<Self>
Open or create a project database at the given path.
Sourcepub fn insert_file(&self, file: &FileRecord) -> DbResult<i64>
pub fn insert_file(&self, file: &FileRecord) -> DbResult<i64>
Insert a new file record. Returns the row id.
Sourcepub fn get_file_by_path(&self, path: &str) -> DbResult<Option<FileRecord>>
pub fn get_file_by_path(&self, path: &str) -> DbResult<Option<FileRecord>>
Get a file record by absolute path.
Sourcepub fn update_file_hash(&self, id: i64, hash: &str) -> DbResult<()>
pub fn update_file_hash(&self, id: i64, hash: &str) -> DbResult<()>
Update the content hash for a file by id.
Sourcepub fn list_files(&self) -> DbResult<Vec<FileRecord>>
pub fn list_files(&self) -> DbResult<Vec<FileRecord>>
List all file records ordered by path.
Sourcepub fn insert_scan_history(
&self,
total_score: f64,
traffic_light: &str,
files_scanned: usize,
duration_ms: u64,
component_scores: &str,
) -> DbResult<i64>
pub fn insert_scan_history( &self, total_score: f64, traffic_light: &str, files_scanned: usize, duration_ms: u64, component_scores: &str, ) -> DbResult<i64>
Insert a scan history record. Returns the row id.
Sourcepub fn get_previous_component_scores(&self) -> DbResult<Option<String>>
pub fn get_previous_component_scores(&self) -> DbResult<Option<String>>
Get the previous scan’s component_scores JSON (most recent scan).
Sourcepub fn insert_scan_history_v2(
&self,
total_score: f64,
traffic_light: &str,
files_scanned: usize,
duration_ms: u64,
component_scores: &str,
commit_sha: Option<&str>,
branch: Option<&str>,
) -> DbResult<(i64, Option<f64>)>
pub fn insert_scan_history_v2( &self, total_score: f64, traffic_light: &str, files_scanned: usize, duration_ms: u64, component_scores: &str, commit_sha: Option<&str>, branch: Option<&str>, ) -> DbResult<(i64, Option<f64>)>
Insert a scan history record with git context and auto-computed delta.
Sourcepub fn insert_quality_issue(
&self,
scan_id: i64,
issue_id: &str,
file_path: Option<&str>,
category: &str,
severity: &str,
title: &str,
attribution: &str,
suggestion: Option<&str>,
) -> DbResult<()>
pub fn insert_quality_issue( &self, scan_id: i64, issue_id: &str, file_path: Option<&str>, category: &str, severity: &str, title: &str, attribution: &str, suggestion: Option<&str>, ) -> DbResult<()>
Insert a quality issue record.
Sourcepub fn upsert_file(
&self,
path: &str,
relative_path: &str,
content_hash: Option<&str>,
size: Option<i64>,
modified_at: Option<&str>,
extension: Option<&str>,
is_markdown: bool,
) -> DbResult<()>
pub fn upsert_file( &self, path: &str, relative_path: &str, content_hash: Option<&str>, size: Option<i64>, modified_at: Option<&str>, extension: Option<&str>, is_markdown: bool, ) -> DbResult<()>
Upsert a file record (insert or update by relative_path).
Sourcepub fn get_scan_history(&self, limit: usize) -> DbResult<Vec<ScanHistoryRecord>>
pub fn get_scan_history(&self, limit: usize) -> DbResult<Vec<ScanHistoryRecord>>
Get scan history entries (most recent first, limited).
Sourcepub fn index_file_content(
&self,
relative_path: &str,
content: &str,
) -> DbResult<()>
pub fn index_file_content( &self, relative_path: &str, content: &str, ) -> DbResult<()>
Populate FTS index for a file.
Sourcepub fn search_files(
&self,
query: &str,
limit: usize,
) -> DbResult<Vec<SearchResult>>
pub fn search_files( &self, query: &str, limit: usize, ) -> DbResult<Vec<SearchResult>>
Search files using FTS5 full-text search.
Sourcepub fn clear_fts_index(&self) -> DbResult<()>
pub fn clear_fts_index(&self) -> DbResult<()>
Clear the entire FTS index.
Sourcepub fn get_file_id_by_relative_path(
&self,
relative_path: &str,
) -> DbResult<Option<i64>>
pub fn get_file_id_by_relative_path( &self, relative_path: &str, ) -> DbResult<Option<i64>>
Get file ID by relative path.
Sourcepub fn insert_classification(
&self,
file_id: i64,
doc_type: &str,
subcategory: Option<&str>,
confidence: f64,
source: &str,
) -> DbResult<i64>
pub fn insert_classification( &self, file_id: i64, doc_type: &str, subcategory: Option<&str>, confidence: f64, source: &str, ) -> DbResult<i64>
Insert a classification record for a file.
Sourcepub fn clear_classifications(&self) -> DbResult<()>
pub fn clear_classifications(&self) -> DbResult<()>
Clear all classifications (before re-scan).
Sourcepub fn purge_stale_files(
&self,
current_paths: &HashSet<String>,
) -> DbResult<usize>
pub fn purge_stale_files( &self, current_paths: &HashSet<String>, ) -> DbResult<usize>
Remove files from DB that are no longer on disk. Accepts a set of relative paths that currently exist. Deletes all files (and their classifications) not in the set.
Sourcepub fn insert_user_correction(
&self,
file_id: i64,
doc_type: &str,
subcategory: Option<&str>,
) -> DbResult<()>
pub fn insert_user_correction( &self, file_id: i64, doc_type: &str, subcategory: Option<&str>, ) -> DbResult<()>
Insert a user correction and update classification to user source with confidence 1.0.
Sourcepub fn delete_classification_for_file(&self, file_id: i64) -> DbResult<()>
pub fn delete_classification_for_file(&self, file_id: i64) -> DbResult<()>
Delete classification for a specific file.
Sourcepub fn get_classifications(&self) -> DbResult<Vec<ClassificationRecord>>
pub fn get_classifications(&self) -> DbResult<Vec<ClassificationRecord>>
Get all classifications with file paths (most recent per file).
Sourcepub fn set_baseline(
&self,
name: &str,
total_score: f64,
commit_sha: Option<&str>,
component_scores: Option<&str>,
) -> DbResult<i64>
pub fn set_baseline( &self, name: &str, total_score: f64, commit_sha: Option<&str>, component_scores: Option<&str>, ) -> DbResult<i64>
Create a named baseline from the current score.
Sourcepub fn get_active_baseline(&self) -> DbResult<Option<BaselineRecord>>
pub fn get_active_baseline(&self) -> DbResult<Option<BaselineRecord>>
Get the currently active baseline.
Sourcepub fn get_last_n_scores(&self, n: usize) -> DbResult<Vec<f64>>
pub fn get_last_n_scores(&self, n: usize) -> DbResult<Vec<f64>>
Return the last N total scores (0.0–1.0) ordered oldest to newest. Used for sparkline visualization in the CLI header.
Sourcepub fn bump_baseline(&self) -> DbResult<bool>
pub fn bump_baseline(&self) -> DbResult<bool>
Bump (replace) the active baseline with the latest scan data.
Auto Trait Implementations§
impl !Freeze for ProjectDb
impl !RefUnwindSafe for ProjectDb
impl Send for ProjectDb
impl !Sync for ProjectDb
impl Unpin for ProjectDb
impl UnsafeUnpin for ProjectDb
impl !UnwindSafe for ProjectDb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more