diff options
| author | Ellie Huxtable <ellie@atuin.sh> | 2024-07-08 11:17:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-08 11:17:47 +0100 |
| commit | 5b384487331eaf08031dfe438bb2affa31aafcbb (patch) | |
| tree | 51904c3df8c54cbc5b7aa5832a5bae49d57f7141 /ui/backend/src/db.rs | |
| parent | feat(bash/blesh): hook into BLE_ONLOAD to resolve loading order issue (#2234) (diff) | |
| download | atuin-5b384487331eaf08031dfe438bb2affa31aafcbb.zip | |
feat(gui): runbooks that run (#2233)
* add initial runbooks frontend
* fix buttons, scroll, add shell support to editor
* work
* some tweaks
* wip - run crate
* functioning executable blocks
* handle resizing, killing ptys
* clear properly on stop
* move terminal to its own component, handle lifecycle better
* fix all build issues
* ffs codespelll
* update lockfile
* clippy is needy once more
* only build pty stuff on mac/linux
* vendor pty handling into desktop
* update lockfile
Diffstat (limited to 'ui/backend/src/db.rs')
| -rw-r--r-- | ui/backend/src/db.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ui/backend/src/db.rs b/ui/backend/src/db.rs index 1015ebf1..56d422ab 100644 --- a/ui/backend/src/db.rs +++ b/ui/backend/src/db.rs @@ -174,6 +174,41 @@ impl HistoryDB { Ok(history) } + pub async fn prefix_search(&self, query: &str) -> Result<Vec<UIHistory>, String> { + let context = Context { + session: "".to_string(), + cwd: "".to_string(), + host_id: "".to_string(), + hostname: "".to_string(), + git_root: None, + }; + + let filters = OptFilters { + limit: Some(5), + ..OptFilters::default() + }; + + let history = self + .0 + .search( + SearchMode::Prefix, + FilterMode::Global, + &context, + query, + filters, + ) + .await + .map_err(|e| e.to_string())?; + + let history = history + .into_iter() + .filter(|h| h.duration > 0) + .map(|h| h.into()) + .collect(); + + Ok(history) + } + pub async fn calendar(&self) -> Result<Vec<(String, u64)>, String> { let query = "select count(1) as count, strftime('%F', datetime(timestamp / 1000000000, 'unixepoch')) as day from history where timestamp > ((unixepoch() - 31536000) * 1000000000) group by day;"; |
