This commit is contained in:
Neeraj Gupta 2024-08-16 17:23:38 +05:30
parent 2cf8bd14f9
commit b6d5ebc5b4
4 changed files with 11 additions and 9 deletions

View File

@ -6,8 +6,9 @@ import "package:photos/db/ml/db.dart";
import "package:photos/db/ml/db_fields.dart";
import "package:photos/events/embedding_updated_event.dart";
import "package:photos/models/ml/clip.dart";
import "package:photos/models/ml/ml_versions.dart";
extension EmbeddingsDB on MLDataDB {
extension ClipDB on MLDataDB {
static const databaseName = "ente.embeddings.db";
Future<List<ClipEmbedding>> getAll() async {
@ -28,10 +29,12 @@ extension EmbeddingsDB on MLDataDB {
return result;
}
Future<int> getClipIndexedFileCount() async {
Future<int> getClipIndexedFileCount({
int minimumMlVersion = clipMlVersion,
}) async {
final db = await MLDataDB.instance.asyncDB;
const String query =
'SELECT COUNT(DISTINCT $fileIDColumn) as count FROM $clipTable';
final String query =
'SELECT COUNT(DISTINCT $fileIDColumn) as count FROM $clipTable WHERE $mlVersionColumn >= $minimumMlVersion';
final List<Map<String, dynamic>> maps = await db.getAll(query);
return maps.first['count'] as int;
}

View File

@ -5,8 +5,8 @@ import "dart:ui" show Image;
import "package:logging/logging.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/db/ml/clip_db.dart";
import "package:photos/db/ml/db.dart";
import "package:photos/db/ml/embeddings_db.dart";
import "package:photos/events/diff_sync_complete_event.dart";
import "package:photos/events/people_changed_event.dart";
import "package:photos/extensions/list.dart";

View File

@ -9,8 +9,8 @@ import "package:logging/logging.dart";
import "package:photos/core/cache/lru_map.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/db/files_db.dart";
import "package:photos/db/ml/clip_db.dart";
import "package:photos/db/ml/db.dart";
import "package:photos/db/ml/embeddings_db.dart";
import 'package:photos/events/embedding_updated_event.dart';
import "package:photos/models/file/file.dart";
import "package:photos/models/ml/clip.dart";

View File

@ -6,8 +6,8 @@ import "package:flutter/services.dart" show PlatformException;
import "package:logging/logging.dart";
import "package:photos/core/configuration.dart";
import "package:photos/db/files_db.dart";
import "package:photos/db/ml/clip_db.dart";
import "package:photos/db/ml/db.dart";
import "package:photos/db/ml/embeddings_db.dart";
import "package:photos/models/file/extensions/file_props.dart";
import "package:photos/models/file/file.dart";
import "package:photos/models/file/file_type.dart";
@ -51,8 +51,7 @@ class FileMLInstruction {
Future<IndexStatus> getIndexStatus() async {
try {
final int indexableFiles = (await getIndexableFileIDs()).length;
final int facesIndexedFiles =
await MLDataDB.instance.getIndexedFileCount();
final int facesIndexedFiles = await MLDataDB.instance.getIndexedFileCount();
final int clipIndexedFiles =
await MLDataDB.instance.getClipIndexedFileCount();
final int indexedFiles = math.min(facesIndexedFiles, clipIndexedFiles);