aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/atuin_daemon/search/index.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-12 17:16:19 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-12 17:16:19 +0200
commit2ca7dd57b12861e8c9bbc9238cda612e0ff22ff3 (patch)
tree302a644f6a50d60cc8304c4498fe6bbb72ddaaa9 /crates/turtle/src/atuin_daemon/search/index.rs
parentfeat(server): Really make users stateless (with tests) (diff)
downloadatuin-2ca7dd57b12861e8c9bbc9238cda612e0ff22ff3.zip
chore(treewide): Cleanup themes
Diffstat (limited to 'crates/turtle/src/atuin_daemon/search/index.rs')
-rw-r--r--crates/turtle/src/atuin_daemon/search/index.rs29
1 files changed, 12 insertions, 17 deletions
diff --git a/crates/turtle/src/atuin_daemon/search/index.rs b/crates/turtle/src/atuin_daemon/search/index.rs
index a23b3133..197a8c1b 100644
--- a/crates/turtle/src/atuin_daemon/search/index.rs
+++ b/crates/turtle/src/atuin_daemon/search/index.rs
@@ -90,7 +90,7 @@ impl FrecencyData {
};
// Frequency boost: more uses = higher score (with diminishing returns)
- let frequency_score = ((self.count as f64).ln() * 20.0).min(100.0);
+ let frequency_score = (f64::from(self.count).ln() * 20.0).min(100.0);
// Apply multipliers and combine scores, then round to u32
((recency_score * recency_mul) + (frequency_score * frequency_mul)).round() as u32
@@ -117,7 +117,7 @@ pub(crate) struct CommandData {
}
impl CommandData {
- /// Create a new CommandData from a history entry.
+ /// Create a new [`CommandData`] from a history entry.
/// Returns None if the history entry has invalid UUIDs.
pub(crate) fn new(history: &History, interner: &ThreadedRodeo) -> Option<Self> {
let history_id = parse_uuid_bytes(&history.id.0)?;
@@ -237,9 +237,13 @@ pub(crate) enum IndexFilterMode {
/// Context for search queries.
#[derive(Debug, Clone, Default)]
pub(crate) struct QueryContext {
+ #[expect(dead_code)]
pub(crate) cwd: Option<String>,
+ #[expect(dead_code)]
pub(crate) git_root: Option<String>,
+ #[expect(dead_code)]
pub(crate) hostname: Option<String>,
+ #[expect(dead_code)]
pub(crate) session_id: Option<String>,
}
@@ -325,21 +329,21 @@ impl SearchIndex {
self.commands.len()
}
- /// Get the number of items in Nucleo (should match command_count).
- pub(crate) async fn nucleo_item_count(&self) -> u32 {
- self.nucleo.read().await.snapshot().item_count()
- }
-
/// Search for commands matching a query.
///
/// Returns a list of history IDs (most recent invocation per command).
/// Uses precomputed global frecency for scoring if available.
#[instrument(skip_all, level = tracing::Level::TRACE, name = "index_search", fields(query = %query))]
+ #[expect(
+ clippy::significant_drop_tightening,
+ reason = "The nucleo early drop is a false-positive"
+ )]
pub(crate) async fn search(
&self,
query: &str,
filter_mode: IndexFilterMode,
- _context: &QueryContext,
+ // TODO(@bpeetz): Use the query context here <2026-06-12>
+ #[expect(unused)] context: &QueryContext,
limit: u32,
) -> Vec<String> {
let mut nucleo = self.nucleo.write().await;
@@ -480,15 +484,6 @@ mod tests {
use super::*;
use time::macros::datetime;
- fn make_history(command: &str, cwd: &str, timestamp: OffsetDateTime) -> History {
- History::import()
- .timestamp(timestamp)
- .command(command)
- .cwd(cwd)
- .build()
- .into()
- }
-
#[test]
fn frecency_data_compute() {
let now = 1_000_000i64;