Skip to main content

ProjectDb

Struct ProjectDb 

Source
pub struct ProjectDb { /* private fields */ }
Expand description

Project database handle.

Implementations§

Source§

impl ProjectDb

Source

pub fn open(db_path: &Path) -> DbResult<Self>

Open or create a project database at the given path.

Source

pub fn insert_file(&self, file: &FileRecord) -> DbResult<i64>

Insert a new file record. Returns the row id.

Source

pub fn get_file_by_path(&self, path: &str) -> DbResult<Option<FileRecord>>

Get a file record by absolute path.

Source

pub fn update_file_hash(&self, id: i64, hash: &str) -> DbResult<()>

Update the content hash for a file by id.

Source

pub fn list_files(&self) -> DbResult<Vec<FileRecord>>

List all file records ordered by path.

Source

pub fn get_config(&self, key: &str) -> DbResult<Option<String>>

Get a project config value.

Source

pub fn set_config(&self, key: &str, value: &str) -> DbResult<()>

Set a project config value.

Source

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.

Source

pub fn get_previous_component_scores(&self) -> DbResult<Option<String>>

Get the previous scan’s component_scores JSON (most recent scan).

Source

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.

Source

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.

Source

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).

Source

pub fn get_scan_history(&self, limit: usize) -> DbResult<Vec<ScanHistoryRecord>>

Get scan history entries (most recent first, limited).

Source

pub fn index_file_content( &self, relative_path: &str, content: &str, ) -> DbResult<()>

Populate FTS index for a file.

Source

pub fn search_files( &self, query: &str, limit: usize, ) -> DbResult<Vec<SearchResult>>

Search files using FTS5 full-text search.

Source

pub fn clear_fts_index(&self) -> DbResult<()>

Clear the entire FTS index.

Source

pub fn get_file_id_by_relative_path( &self, relative_path: &str, ) -> DbResult<Option<i64>>

Get file ID by relative path.

Source

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.

Source

pub fn clear_classifications(&self) -> DbResult<()>

Clear all classifications (before re-scan).

Source

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.

Source

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.

Source

pub fn delete_classification_for_file(&self, file_id: i64) -> DbResult<()>

Delete classification for a specific file.

Source

pub fn get_classifications(&self) -> DbResult<Vec<ClassificationRecord>>

Get all classifications with file paths (most recent per file).

Source

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.

Source

pub fn get_active_baseline(&self) -> DbResult<Option<BaselineRecord>>

Get the currently active baseline.

Source

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.

Source

pub fn bump_baseline(&self) -> DbResult<bool>

Bump (replace) the active baseline with the latest scan data.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more