diff --git a/.github/workflows/run_evals.yml b/.github/workflows/run_evals.yml index 9695cfef..914a0835 100644 --- a/.github/workflows/run_evals.yml +++ b/.github/workflows/run_evals.yml @@ -77,7 +77,7 @@ jobs: run: | # install postgres and other dependencies sudo apt update && sudo apt install -y git python3-pip libegl1 sqlite3 libsqlite3-dev libsqlite3-0 ffmpeg libsm6 libxext6 - sudo apt install -y postgresql postgresql-client && sudo apt install -y postgresql-server-dev-14 + sudo apt install -y postgresql postgresql-client && sudo apt install -y postgresql-server-dev-16 # upgrade pip python -m ensurepip --upgrade && python -m pip install --upgrade pip # install terrarium for code sandbox diff --git a/manifest.json b/manifest.json index 6c8ad3bf..8cdf3f2f 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "khoj", "name": "Khoj", - "version": "1.34.0", + "version": "1.35.2", "minAppVersion": "0.15.0", "description": "Your Second Brain", "author": "Khoj Inc.", diff --git a/src/interface/desktop/package.json b/src/interface/desktop/package.json index e7d0a4c2..d43bd1a6 100644 --- a/src/interface/desktop/package.json +++ b/src/interface/desktop/package.json @@ -1,6 +1,6 @@ { "name": "Khoj", - "version": "1.34.0", + "version": "1.35.2", "description": "Your Second Brain", "author": "Khoj Inc. ", "license": "GPL-3.0-or-later", diff --git a/src/interface/emacs/khoj.el b/src/interface/emacs/khoj.el index d832fc51..b77c70e9 100644 --- a/src/interface/emacs/khoj.el +++ b/src/interface/emacs/khoj.el @@ -6,7 +6,7 @@ ;; Saba Imran ;; Description: Your Second Brain ;; Keywords: search, chat, ai, org-mode, outlines, markdown, pdf, image -;; Version: 1.34.0 +;; Version: 1.35.2 ;; Package-Requires: ((emacs "27.1") (transient "0.3.0") (dash "2.19.1")) ;; URL: https://github.com/khoj-ai/khoj/tree/master/src/interface/emacs diff --git a/src/interface/obsidian/manifest.json b/src/interface/obsidian/manifest.json index 6c8ad3bf..8cdf3f2f 100644 --- a/src/interface/obsidian/manifest.json +++ b/src/interface/obsidian/manifest.json @@ -1,7 +1,7 @@ { "id": "khoj", "name": "Khoj", - "version": "1.34.0", + "version": "1.35.2", "minAppVersion": "0.15.0", "description": "Your Second Brain", "author": "Khoj Inc.", diff --git a/src/interface/obsidian/package.json b/src/interface/obsidian/package.json index 2ef8b849..8861f177 100644 --- a/src/interface/obsidian/package.json +++ b/src/interface/obsidian/package.json @@ -1,6 +1,6 @@ { "name": "Khoj", - "version": "1.34.0", + "version": "1.35.2", "description": "Your Second Brain", "author": "Debanjum Singh Solanky, Saba Imran ", "license": "GPL-3.0-or-later", diff --git a/src/interface/obsidian/versions.json b/src/interface/obsidian/versions.json index 47ff6efa..21346aa4 100644 --- a/src/interface/obsidian/versions.json +++ b/src/interface/obsidian/versions.json @@ -109,5 +109,8 @@ "1.33.0": "0.15.0", "1.33.1": "0.15.0", "1.33.2": "0.15.0", - "1.34.0": "0.15.0" + "1.34.0": "0.15.0", + "1.35.0": "0.15.0", + "1.35.1": "0.15.0", + "1.35.2": "0.15.0" } diff --git a/src/interface/web/package.json b/src/interface/web/package.json index b53be322..f0aac4af 100644 --- a/src/interface/web/package.json +++ b/src/interface/web/package.json @@ -1,6 +1,6 @@ { "name": "khoj-ai", - "version": "1.34.0", + "version": "1.35.2", "private": true, "scripts": { "dev": "next dev", diff --git a/src/khoj/database/management/commands/delete_orphaned_fileobjects.py b/src/khoj/database/management/commands/delete_orphaned_fileobjects.py index 99d45c6f..f7efa1dd 100644 --- a/src/khoj/database/management/commands/delete_orphaned_fileobjects.py +++ b/src/khoj/database/management/commands/delete_orphaned_fileobjects.py @@ -1,4 +1,5 @@ from django.core.management.base import BaseCommand +from django.db import transaction from django.db.models import Exists, OuterRef from khoj.database.models import Entry, FileObject diff --git a/src/khoj/database/migrations/0079_entry_file_object.py b/src/khoj/database/migrations/0079_entry_file_object.py index 3846dd9d..1b15b0a6 100644 --- a/src/khoj/database/migrations/0079_entry_file_object.py +++ b/src/khoj/database/migrations/0079_entry_file_object.py @@ -9,45 +9,40 @@ def migrate_entry_objects(apps, schema_editor): FileObject = apps.get_model("database", "FileObject") db_alias = schema_editor.connection.alias - # Create lookup dictionary of all file objects - file_objects_map = {(fo.user_id, fo.file_name): fo for fo in FileObject.objects.using(db_alias).all()} - - # Process entries in chunks of 1000 + # Process file objects in chunks chunk_size = 1000 processed = 0 - - processed_entry_ids = set() + processed_file_ids = set() while True: - entries = list( - Entry.objects.using(db_alias) + file_objects = list( + FileObject.objects.using(db_alias) + .exclude(id__in=processed_file_ids) .select_related("user") - .filter(file_object__isnull=True) - .exclude(id__in=processed_entry_ids) - .only("id", "user", "file_path")[:chunk_size] + .only("id", "user", "file_name")[:chunk_size] ) - if not entries: + if not file_objects: break - processed_entry_ids.update([entry.id for entry in entries]) + processed_file_ids.update([fo.id for fo in file_objects]) - entries_to_update = [] - for entry in entries: + for file_object in file_objects: try: - file_object = file_objects_map.get((entry.user_id, entry.file_path)) - if file_object: - entry.file_object = file_object - entries_to_update.append(entry) + # Find all entries matching this file object + matching_entries = Entry.objects.using(db_alias).filter( + user_id=file_object.user_id, file_path=file_object.file_name, file_object__isnull=True + ) + + if matching_entries.exists(): + # Update all matching entries in bulk + matching_entries.update(file_object=file_object) except Exception as e: - print(f"Error processing entry {entry.id}: {str(e)}") + print(f"Error processing file object {file_object.id}: {str(e)}") continue - if entries_to_update: - Entry.objects.using(db_alias).bulk_update(entries_to_update, ["file_object"], batch_size=chunk_size) - - processed += len(entries) - print(f"Processed {processed} entries") + processed += len(file_objects) + print(f"Processed {processed} file objects") def reverse_migration(apps, schema_editor): diff --git a/versions.json b/versions.json index 47ff6efa..21346aa4 100644 --- a/versions.json +++ b/versions.json @@ -109,5 +109,8 @@ "1.33.0": "0.15.0", "1.33.1": "0.15.0", "1.33.2": "0.15.0", - "1.34.0": "0.15.0" + "1.34.0": "0.15.0", + "1.35.0": "0.15.0", + "1.35.1": "0.15.0", + "1.35.2": "0.15.0" }