Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added monitor device in vision tables and search query #1253

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion screenpipe-server/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,13 @@ impl DatabaseManager {

// Insert the new frame with file_path as name
let id = sqlx::query(
"INSERT INTO frames (video_chunk_id, offset_index, timestamp, name) VALUES (?1, ?2, ?3, ?4)",
"INSERT INTO frames (video_chunk_id, offset_index, timestamp, name, device_name) VALUES (?1, ?2, ?3, ?4, ?5)",
)
.bind(video_chunk_id)
.bind(offset_index)
.bind(timestamp)
.bind(file_path)
.bind(device_name)
.execute(&mut *tx)
.await?
.last_insert_rowid();
Expand All @@ -339,6 +340,8 @@ impl DatabaseManager {
// Commit the transaction
tx.commit().await?;

debug!("Inserted frame {} for device {}", id, device_name);

Ok(id)
}

Expand Down Expand Up @@ -746,6 +749,7 @@ impl DatabaseManager {
ocr_text.app_name,
ocr_text.ocr_engine,
ocr_text.window_name,
video_chunks.device_name,
GROUP_CONCAT(tags.name, ',') as tags
FROM {}
JOIN frames ON ocr_text.frame_id = frames.id
Expand Down Expand Up @@ -795,6 +799,7 @@ impl DatabaseManager {
app_name: raw.app_name,
ocr_engine: raw.ocr_engine,
window_name: raw.window_name,
device_name: raw.device_name,
tags: raw
.tags
.map(|t| t.split(',').map(String::from).collect())
Expand Down Expand Up @@ -2095,6 +2100,7 @@ impl DatabaseManager {
ocr_engine: raw.ocr_engine,
window_name: raw.window_name,
frame_name: raw.frame_name,
device_name: raw.device_name,
tags: raw
.tags
.map(|t| t.split(',').map(String::from).collect())
Expand Down
2 changes: 2 additions & 0 deletions screenpipe-server/src/db_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct OCRResultRaw {
pub ocr_engine: String,
pub window_name: String,
pub tags: Option<String>,
pub device_name: String,
}

#[derive(Debug, Serialize, Deserialize)]
Expand All @@ -51,6 +52,7 @@ pub struct OCRResult {
pub ocr_engine: String,
pub window_name: String,
pub tags: Vec<String>,
pub device_name: String,
}

#[derive(Debug, Deserialize, PartialEq, Default, Clone)]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Add migration script here
ALTER TABLE frames ADD COLUMN device_name TEXT NOT NULL DEFAULT '';
CREATE INDEX idx_frames_device_name ON frames(device_name);
Loading