Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

Merge branch 'main' into min-max-size-in-api

Louis Beaumont697434202e7a
diff --cc screenpipe-server/src/db.rs
index 5b0fb4730,ab4d9fcc3..30a18eb79
--- a/screenpipe-server/src/db.rs
+++ b/screenpipe-server/src/db.rs
@@@ -996,32 -909,12 +996,32 @@@ impl DatabaseManager
"#
.to_string();
+ let mut param_count = 3;
+
if app_name.is_some() {
- sql.push_str(" AND ocr_text.app_name LIKE '%' || ?4 || '%' COLLATE NOCASE");
+ 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 window_name.is_some() {
- sql.push_str(" AND ocr_text.window_name LIKE '%' || ?5 || '%' COLLATE NOCASE");
+ param_count += 1;
+ sql.push_str(&format!(
- " AND ocr_text.window_name = ?{} COLLATE NOCASE",
++ " AND ocr_text.window_name LIKE '%' || ?{} || '%' COLLATE NOCASE",
+ param_count
+ ));
+ }
+
+ if min_length.is_some() {
+ param_count += 1;
+ sql.push_str(&format!(" AND LENGTH(ocr_text.text) >= ?{}", param_count));
+ }
+
+ if max_length.is_some() {
+ param_count += 1;
+ sql.push_str(&format!(" AND LENGTH(ocr_text.text) <= ?{}", param_count));
}
let mut query = sqlx::query_as::<_, (i64,)>(&sql)
diff --cc screenpipe-server/src/server.rs
index 4e04329b4,40c9c8077..e8bbe9618
--- a/screenpipe-server/src/server.rs
+++ b/screenpipe-server/src/server.rs
@@@ -905,28 -927,43 +925,70 @@@ curl -X POST "http://localhost:3030/pip
}' | jq
++
+# Basic search with min_length and max_length
+curl "http://localhost:3030/search?q=test&limit=10&offset=0&min_length=5&max_length=50" | jq
+
+# Search for OCR content with length constraints
+curl "http://localhost:3030/search?q=code&content_type=ocr&limit=5&offset=0&min_length=20&max_length=100" | jq
+
+# Search for audio content with length constraints
+curl "http://localhost:3030/search?q=meeting&content_type=audio&limit=5&offset=0&min_length=50&max_length=200" | jq
+
+# Search with time range and length constraints
+curl "http://localhost:3030/search?q=project&limit=10&offset=0&min_length=10&max_length=100&start_time=$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ)&end_time=$(date -u +%Y-%m-%dT%H:%M:%SZ)" | jq
+
+# Search with app_name and length constraints
+curl "http://localhost:3030/search?app_name=cursor&limit=5&offset=0&min_length=15&max_length=150" | jq
+
+# Search with window_name and length constraints
+curl "http://localhost:3030/search?window_name=alacritty&min_length=5&max_length=50" | jq
+
+# Search for very short content
+curl "http://localhost:3030/search?q=&limit=10&offset=0&max_length=10" | jq
+
+# Search for very long content
+curl "http://localhost:3030/search?q=&limit=10&offset=0&min_length=500" | jq
+
++
+ # read random data and generate a clip using the merge endpoint
+
+
+ # Perform the search and store the response
+
+ # First, let's search for some recent video content
+ SEARCH_RESPONSE1=$(curl -s "http://localhost:3030/search?q=&limit=5&offset=0&content_type=ocr&start_time=$(date -u -v-30M +%Y-%m-%dT%H:%M:%SZ)&end_time=$(date -u -v-25M +%Y-%m-%dT%H:%M:%SZ)")
+ SEARCH_RESPONSE2=$(curl -s "http://localhost:3030/search?q=&limit=5&offset=0&content_type=ocr&start_time=$(date -u -v-40M +%Y-%m-%dT%H:%M:%SZ)&end_time=$(date -u -v-35M +%Y-%m-%dT%H:%M:%SZ)")
+ SEARCH_RESPONSE3=$(curl -s "http://localhost:3030/search?q=&limit=5&offset=0&content_type=ocr&start_time=$(date -u -v-50M +%Y-%m-%dT%H:%M:%SZ)&end_time=$(date -u -v-45M +%Y-%m-%dT%H:%M:%SZ)")
+
+ # Extract the file paths from the search results without creating JSON arrays
+ VIDEO_PATHS1=$(echo "$SEARCH_RESPONSE1" | jq -r '.data[].content.file_path' | sort -u)
+ VIDEO_PATHS2=$(echo "$SEARCH_RESPONSE2" | jq -r '.data[].content.file_path' | sort -u)
+ VIDEO_PATHS3=$(echo "$SEARCH_RESPONSE3" | jq -r '.data[].content.file_path' | sort -u)
+
+ # Merge the video paths and create a single JSON array
+ MERGED_VIDEO_PATHS=$(echo "$VIDEO_PATHS1"$'\n'"$VIDEO_PATHS2"$'\n'"$VIDEO_PATHS3" | sort -u | jq -R -s -c 'split("\n") | map(select(length > 0))')
+
+ # Create the JSON payload for merging videos
+ MERGE_PAYLOAD=$(jq -n \
+ --argjson video_paths "$MERGED_VIDEO_PATHS" \
+ '{
+ video_paths: $video_paths
+ }')
+
+ echo "Merge Payload: $MERGE_PAYLOAD"
+
+ # Send the merge request and store the response
+ MERGE_RESPONSE=$(curl -s -X POST "http://localhost:3030/experimental/frames/merge" \
+ -H "Content-Type: application/json" \
+ -d "$MERGE_PAYLOAD")
+
+ echo "Merge Response: $MERGE_RESPONSE"
+
+ # Extract the merged video path from the response
+ MERGED_VIDEO_PATH=$(echo "$MERGE_RESPONSE" | jq -r '.video_path')
+
+ echo "Merged Video Path: $MERGED_VIDEO_PATH"
+
++
*/