Skip to content

Commit

Permalink
feat: keyword search for app name and window name
Browse files Browse the repository at this point in the history
  • Loading branch information
louis030195 committed Sep 14, 2024
1 parent b8aee09 commit 29dc3ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion screenpipe-app-tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
version = "0.2.37"
version = "0.2.38"
description = ""
authors = ["you"]
license = ""
Expand Down
10 changes: 5 additions & 5 deletions screenpipe-server/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,15 +664,15 @@ impl DatabaseManager {
if let Some(_) = app_name {
param_count += 1;
sql.push_str(&format!(
" AND ocr_text.app_name = ?{} COLLATE NOCASE",
" AND ocr_text.app_name LIKE '%' || ?{} || '%' COLLATE NOCASE",
param_count
));
}

if let Some(_) = window_name {
param_count += 1;
sql.push_str(&format!(
" AND ocr_text.window_name = ?{} COLLATE NOCASE",
" AND ocr_text.window_name LIKE '%' || ?{} || '%' COLLATE NOCASE",
param_count
));
}
Expand Down Expand Up @@ -897,7 +897,7 @@ impl DatabaseManager {
start_time: Option<DateTime<Utc>>,
end_time: Option<DateTime<Utc>>,
app_name: Option<&str>,
window_name: Option<&str>, // Add window_name parameter
window_name: Option<&str>,
) -> Result<usize, sqlx::Error> {
let mut sql = r#"
SELECT COUNT(*)
Expand All @@ -910,11 +910,11 @@ impl DatabaseManager {
.to_string();

if app_name.is_some() {
sql.push_str(" AND ocr_text.app_name = ?6 COLLATE NOCASE");
sql.push_str(" AND ocr_text.app_name LIKE '%' || ?4 || '%' COLLATE NOCASE");
}

if window_name.is_some() {
sql.push_str(" AND ocr_text.window_name = ?7 COLLATE NOCASE");
sql.push_str(" AND ocr_text.window_name LIKE '%' || ?5 || '%' COLLATE NOCASE");
}

let mut query = sqlx::query_as::<_, (i64,)>(&sql)
Expand Down

0 comments on commit 29dc3ed

Please sign in to comment.