-
-
Notifications
You must be signed in to change notification settings - Fork 601
Gsoc'25 Frontend Revamp #489
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
Changes from all commits
d42d220
d7a494d
77fb571
dbb1438
9897c25
e91e33b
cfd7c03
46e310f
848a1b4
79aa6af
dee13c8
a396ee4
806bb81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -90,6 +90,81 @@ def db_bulk_insert_images(image_records: List[ImageRecord]) -> bool: | |||||||||||||||
| conn.close() | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def db_get_all_images() -> List[dict]: | ||||||||||||||||
| """ | ||||||||||||||||
| Get all images from the database with their tags. | ||||||||||||||||
|
|
||||||||||||||||
| Returns: | ||||||||||||||||
| List of dictionaries containing all image data including tags | ||||||||||||||||
| """ | ||||||||||||||||
| conn = sqlite3.connect(DATABASE_PATH) | ||||||||||||||||
| cursor = conn.cursor() | ||||||||||||||||
|
|
||||||||||||||||
| try: | ||||||||||||||||
| cursor.execute( | ||||||||||||||||
| """ | ||||||||||||||||
| SELECT | ||||||||||||||||
| i.id, | ||||||||||||||||
| i.path, | ||||||||||||||||
| i.folder_id, | ||||||||||||||||
| i.thumbnailPath, | ||||||||||||||||
| i.metadata, | ||||||||||||||||
| i.isTagged, | ||||||||||||||||
| m.name as tag_name | ||||||||||||||||
| FROM images i | ||||||||||||||||
| LEFT JOIN image_classes ic ON i.id = ic.image_id | ||||||||||||||||
| LEFT JOIN mappings m ON ic.class_id = m.class_id | ||||||||||||||||
| ORDER BY i.path, m.name | ||||||||||||||||
| """ | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| results = cursor.fetchall() | ||||||||||||||||
|
|
||||||||||||||||
| # Group results by image ID | ||||||||||||||||
| images_dict = {} | ||||||||||||||||
| for ( | ||||||||||||||||
| image_id, | ||||||||||||||||
| path, | ||||||||||||||||
| folder_id, | ||||||||||||||||
| thumbnail_path, | ||||||||||||||||
| metadata, | ||||||||||||||||
| is_tagged, | ||||||||||||||||
| tag_name, | ||||||||||||||||
| ) in results: | ||||||||||||||||
| if image_id not in images_dict: | ||||||||||||||||
| images_dict[image_id] = { | ||||||||||||||||
| "id": image_id, | ||||||||||||||||
| "path": path, | ||||||||||||||||
| "folder_id": folder_id, | ||||||||||||||||
| "thumbnailPath": thumbnail_path, | ||||||||||||||||
| "metadata": metadata, | ||||||||||||||||
| "isTagged": bool(is_tagged), | ||||||||||||||||
| "tags": [], | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| # Add tag if it exists | ||||||||||||||||
| if tag_name: | ||||||||||||||||
| images_dict[image_id]["tags"].append(tag_name) | ||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
+145
to
+148
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Deduplicate tags to avoid duplicates from joins If image_classes has duplicate rows or mappings alias the same name, this can add duplicates. Apply: - if tag_name:
- images_dict[image_id]["tags"].append(tag_name)
+ if tag_name and tag_name not in images_dict[image_id]["tags"]:
+ images_dict[image_id]["tags"].append(tag_name)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| # Convert to list and set tags to None if empty | ||||||||||||||||
| images = [] | ||||||||||||||||
| for image_data in images_dict.values(): | ||||||||||||||||
| if not image_data["tags"]: | ||||||||||||||||
| image_data["tags"] = None | ||||||||||||||||
| images.append(image_data) | ||||||||||||||||
|
|
||||||||||||||||
| # Sort by path | ||||||||||||||||
| images.sort(key=lambda x: x["path"]) | ||||||||||||||||
|
|
||||||||||||||||
| return images | ||||||||||||||||
|
|
||||||||||||||||
| except Exception as e: | ||||||||||||||||
| print(f"Error getting all images: {e}") | ||||||||||||||||
| return [] | ||||||||||||||||
| finally: | ||||||||||||||||
| conn.close() | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def db_get_untagged_images() -> List[ImageRecord]: | ||||||||||||||||
| """ | ||||||||||||||||
| Find all images that need AI tagging. | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Make SYNC_MICROSERVICE_URL configurable via environment.
Avoid hardcoding localhost; allow deployments to override and normalize trailing slash.
📝 Committable suggestion
🤖 Prompt for AI Agents