[mob] Slightly faster indexed file count
This commit is contained in:
parent
da7302b677
commit
5a5cdc8b6b
2 changed files with 17 additions and 9 deletions
|
@ -136,6 +136,14 @@ class FaceMLDataDB {
|
|||
return result;
|
||||
}
|
||||
|
||||
Future<int> getIndexedFileCount() async {
|
||||
final db = await instance.sqliteAsyncDB;
|
||||
final List<Map<String, dynamic>> maps = await db.getAll(
|
||||
'SELECT COUNT(DISTINCT $fileIDColumn) as count FROM $facesTable',
|
||||
);
|
||||
return maps.first['count'] as int;
|
||||
}
|
||||
|
||||
Future<Map<int, int>> clusterIdToFaceCount() async {
|
||||
final db = await instance.database;
|
||||
final List<Map<String, dynamic>> maps = await db.rawQuery(
|
||||
|
|
|
@ -57,14 +57,14 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
|
|||
return Column(
|
||||
children: [
|
||||
MenuItemWidget(
|
||||
captionedTextWidget: FutureBuilder<Map<int, int>>(
|
||||
future: FaceMLDataDB.instance.getIndexedFileIds(),
|
||||
captionedTextWidget: FutureBuilder<int>(
|
||||
future: FaceMLDataDB.instance.getIndexedFileCount(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return CaptionedTextWidget(
|
||||
title: LocalSettings.instance.isFaceIndexingEnabled
|
||||
? "Disable indexing (${snapshot.data!.length})"
|
||||
: "Enable indexing (${snapshot.data!.length})",
|
||||
? "Disable indexing (${snapshot.data!})"
|
||||
: "Enable indexing (${snapshot.data!})",
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
|
@ -92,8 +92,8 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
|
|||
},
|
||||
),
|
||||
MenuItemWidget(
|
||||
captionedTextWidget: FutureBuilder<Map<int, int>>(
|
||||
future: FaceMLDataDB.instance.getIndexedFileIds(),
|
||||
captionedTextWidget: FutureBuilder<int>(
|
||||
future: FaceMLDataDB.instance.getIndexedFileCount(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return CaptionedTextWidget(
|
||||
|
@ -306,12 +306,12 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
|
|||
if (kDebugMode) sectionOptionSpacing,
|
||||
if (kDebugMode)
|
||||
MenuItemWidget(
|
||||
captionedTextWidget: FutureBuilder<Map<int, int>>(
|
||||
future: FaceMLDataDB.instance.getIndexedFileIds(),
|
||||
captionedTextWidget: FutureBuilder<int>(
|
||||
future: FaceMLDataDB.instance.getIndexedFileCount(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return CaptionedTextWidget(
|
||||
title: "Read embeddings for ${snapshot.data!.length} files",
|
||||
title: "Read embeddings for ${snapshot.data!} files",
|
||||
);
|
||||
}
|
||||
return const CaptionedTextWidget(
|
||||
|
|
Loading…
Add table
Reference in a new issue