[mob] Fix reset queries for feedback & clusters

This commit is contained in:
Neeraj Gupta 2024-04-02 12:21:14 +05:30
parent 226808aadb
commit 8e322114b7
3 changed files with 15 additions and 9 deletions

View file

@ -444,9 +444,9 @@ class FaceMLDataDB {
Future<void> resetClusterIDs() async {
final db = await instance.database;
await db.rawQuery(dropFaceClustersTable);
await db.rawQuery(createFaceClustersTable);
await db.rawQuery(fcClusterIDIndex);
await db.execute(dropFaceClustersTable);
await db.execute(createFaceClustersTable);
await db.execute(fcClusterIDIndex);
}
Future<void> insert(Person p, int cluserID) async {
@ -647,6 +647,7 @@ class FaceMLDataDB {
await db.execute(createFacesTable);
await db.execute(dropFaceClustersTable);
await db.execute(createFaceClustersTable);
await db.execute(fcClusterIDIndex);
}
await db.execute(deletePersonTable);
await db.execute(dropClusterPersonTable);

View file

@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS $faceClustersTable (
''';
// -- Creating a non-unique index on clusterID for query optimization
const fcClusterIDIndex =
'''CREATE INDEX IF NOT EXISTS idx_fcClusterID ON faceClustersTable(fcClusterID);''';
'''CREATE INDEX IF NOT EXISTS idx_fcClusterID ON $faceClustersTable($fcClusterID);''';
const dropFaceClustersTable = 'DROP TABLE IF EXISTS $faceClustersTable';
//##endregion

View file

@ -181,7 +181,7 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
sectionOptionSpacing,
MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget(
title: "Reset feedback & labels",
title: "Reset feedback & clusters",
),
pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined,
@ -194,10 +194,15 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
"You will need to again cluster all the faces. You can drop feedback if you want to return to original cluster labels",
firstButtonLabel: "Yes, confirm",
firstButtonOnTap: () async {
await FaceMLDataDB.instance.resetClusterIDs();
await FaceMLDataDB.instance.dropClustersAndPersonTable();
Bus.instance.fire(PeopleChangedEvent());
showShortToast(context, "Done");
try {
await FaceMLDataDB.instance.resetClusterIDs();
await FaceMLDataDB.instance.dropClustersAndPersonTable();
Bus.instance.fire(PeopleChangedEvent());
showShortToast(context, "Done");
} catch (e, s) {
_logger.warning('reset feedback failed ', e, s);
await showGenericErrorDialog(context: context, error: e);
}
},
);
},