[mob] Rename
This commit is contained in:
parent
5b339fc30e
commit
7e9c6a7f81
|
@ -18,7 +18,7 @@ import 'package:sqflite/sqflite.dart';
|
|||
///
|
||||
/// This includes:
|
||||
/// [facesTable] - Stores all the detected faces and its embeddings in the images.
|
||||
/// [peopleTable] - Stores all the clusters of faces which are considered to be the same person.
|
||||
/// [personTable] - Stores all the clusters of faces which are considered to be the same person.
|
||||
class FaceMLDataDB {
|
||||
static final Logger _logger = Logger("FaceMLDataDB");
|
||||
|
||||
|
@ -49,7 +49,7 @@ class FaceMLDataDB {
|
|||
|
||||
Future _onCreate(Database db, int version) async {
|
||||
await db.execute(createFacesTable);
|
||||
await db.execute(createPeopleTable);
|
||||
await db.execute(createPersonTable);
|
||||
await db.execute(createClusterTable);
|
||||
await db.execute(createClusterSummaryTable);
|
||||
await db.execute(createNotPersonFeedbackTable);
|
||||
|
@ -165,7 +165,7 @@ class FaceMLDataDB {
|
|||
await db.delete(facesTable);
|
||||
await db.delete(clustersTable);
|
||||
await db.delete(clusterSummaryTable);
|
||||
await db.delete(peopleTable);
|
||||
await db.delete(personTable);
|
||||
await db.delete(notPersonFeedback);
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ class FaceMLDataDB {
|
|||
final db = await instance.database;
|
||||
if (personID != null) {
|
||||
final List<Map<String, dynamic>> maps = await db.rawQuery(
|
||||
'SELECT * FROM $peopleTable where $idColumn = ?',
|
||||
'SELECT * FROM $personTable where $idColumn = ?',
|
||||
[personID],
|
||||
);
|
||||
if (maps.isEmpty) {
|
||||
|
@ -450,7 +450,7 @@ class FaceMLDataDB {
|
|||
debugPrint("inserting person");
|
||||
final db = await instance.database;
|
||||
await db.insert(
|
||||
peopleTable,
|
||||
personTable,
|
||||
mapPersonToRow(p),
|
||||
conflictAlgorithm: ConflictAlgorithm.replace,
|
||||
);
|
||||
|
@ -467,7 +467,7 @@ class FaceMLDataDB {
|
|||
Future<void> updatePerson(Person p) async {
|
||||
final db = await instance.database;
|
||||
await db.update(
|
||||
peopleTable,
|
||||
personTable,
|
||||
mapPersonToRow(p),
|
||||
where: '$idColumn = ?',
|
||||
whereArgs: [p.remoteID],
|
||||
|
@ -597,14 +597,18 @@ class FaceMLDataDB {
|
|||
|
||||
Future<(Map<int, Person>, Map<String, Person>)> getClusterIdToPerson() async {
|
||||
final db = await instance.database;
|
||||
final Map<String, Person> peopleMap = await getPeopleMap();
|
||||
final List<Person> persons = await getPersons();
|
||||
final Map<String, Person> personMap = {};
|
||||
for (final p in persons) {
|
||||
personMap[p.remoteID] = p;
|
||||
}
|
||||
final List<Map<String, dynamic>> maps = await db.rawQuery(
|
||||
'SELECT $personIdColumn, $cluserIDColumn FROM $clustersTable',
|
||||
);
|
||||
|
||||
final Map<int, Person> result = {};
|
||||
for (final map in maps) {
|
||||
final Person? p = peopleMap[map[personIdColumn] as String];
|
||||
final Person? p = personMap[map[personIdColumn] as String];
|
||||
if (p != null) {
|
||||
result[map[cluserIDColumn] as int] = p;
|
||||
} else {
|
||||
|
@ -613,32 +617,13 @@ class FaceMLDataDB {
|
|||
);
|
||||
}
|
||||
}
|
||||
return (result, peopleMap);
|
||||
return (result, personMap);
|
||||
}
|
||||
|
||||
Future<Map<String, Person>> getPeopleMap() async {
|
||||
Future<List<Person>> getPersons() async {
|
||||
final db = await instance.database;
|
||||
final List<Map<String, dynamic>> maps = await db.query(
|
||||
peopleTable,
|
||||
columns: [
|
||||
idColumn,
|
||||
nameColumn,
|
||||
personHiddenColumn,
|
||||
clusterToFaceIdJson,
|
||||
coverFaceIDColumn,
|
||||
],
|
||||
);
|
||||
final Map<String, Person> result = {};
|
||||
for (final map in maps) {
|
||||
result[map[idColumn] as String] = mapRowToPerson(map);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<List<Person>> getPeople() async {
|
||||
final db = await instance.database;
|
||||
final List<Map<String, dynamic>> maps = await db.query(
|
||||
peopleTable,
|
||||
personTable,
|
||||
columns: [
|
||||
idColumn,
|
||||
nameColumn,
|
||||
|
@ -651,33 +636,33 @@ class FaceMLDataDB {
|
|||
}
|
||||
|
||||
/// WARNING: This will delete ALL data in the database! Only use this for debug/testing purposes!
|
||||
Future<void> dropClustersAndPeople({bool faces = false}) async {
|
||||
Future<void> dropClustersAndPersonTable({bool faces = false}) async {
|
||||
final db = await instance.database;
|
||||
if (faces) {
|
||||
await db.execute(deleteFacesTable);
|
||||
await db.execute(createFacesTable);
|
||||
}
|
||||
await db.execute(deletePeopleTable);
|
||||
await db.execute(deletePersonTable);
|
||||
await db.execute(dropClustersTable);
|
||||
await db.execute(dropClusterSummaryTable);
|
||||
await db.execute(dropNotPersonFeedbackTable);
|
||||
|
||||
await db.execute(createPeopleTable);
|
||||
await db.execute(createPersonTable);
|
||||
await db.execute(createClusterTable);
|
||||
await db.execute(createNotPersonFeedbackTable);
|
||||
await db.execute(createClusterSummaryTable);
|
||||
}
|
||||
|
||||
/// WARNING: This will delete ALL data in the database! Only use this for debug/testing purposes!
|
||||
Future<void> dropPeople() async {
|
||||
Future<void> dropPersonTable() async {
|
||||
final db = await instance.database;
|
||||
|
||||
await db.execute(deletePeopleTable);
|
||||
await db.execute(deletePersonTable);
|
||||
await db.execute(dropClustersTable);
|
||||
await db.execute(dropNotPersonFeedbackTable);
|
||||
|
||||
// await db.execute(createFacesTable);
|
||||
await db.execute(createPeopleTable);
|
||||
await db.execute(createPersonTable);
|
||||
await db.execute(createClusterTable);
|
||||
await db.execute(createNotPersonFeedbackTable);
|
||||
}
|
||||
|
|
|
@ -34,14 +34,14 @@ const deleteFacesTable = 'DROP TABLE IF EXISTS $facesTable';
|
|||
// End of Faces Table Fields & Schema Queries
|
||||
|
||||
// People Table Fields & Schema Queries
|
||||
const peopleTable = 'people';
|
||||
const personTable = 'people';
|
||||
const idColumn = 'id';
|
||||
const nameColumn = 'name';
|
||||
const personHiddenColumn = 'hidden';
|
||||
const clusterToFaceIdJson = 'clusterToFaceIds';
|
||||
const coverFaceIDColumn = 'cover_face_id';
|
||||
|
||||
const createPeopleTable = '''CREATE TABLE IF NOT EXISTS $peopleTable (
|
||||
const createPersonTable = '''CREATE TABLE IF NOT EXISTS $personTable (
|
||||
$idColumn TEXT NOT NULL UNIQUE,
|
||||
$nameColumn TEXT NOT NULL DEFAULT '',
|
||||
$personHiddenColumn INTEGER NOT NULL DEFAULT 0,
|
||||
|
@ -51,7 +51,7 @@ const createPeopleTable = '''CREATE TABLE IF NOT EXISTS $peopleTable (
|
|||
);
|
||||
''';
|
||||
|
||||
const deletePeopleTable = 'DROP TABLE IF EXISTS $peopleTable';
|
||||
const deletePersonTable = 'DROP TABLE IF EXISTS $personTable';
|
||||
//End People Table Fields & Schema Queries
|
||||
|
||||
// Clusters Table Fields & Schema Queries
|
||||
|
|
|
@ -173,7 +173,7 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
|
|||
trailingIcon: Icons.chevron_right_outlined,
|
||||
trailingIconIsMuted: true,
|
||||
onTap: () async {
|
||||
await FaceMLDataDB.instance.dropPeople();
|
||||
await FaceMLDataDB.instance.dropPersonTable();
|
||||
Bus.instance.fire(PeopleChangedEvent());
|
||||
showShortToast(context, "Done");
|
||||
},
|
||||
|
@ -195,7 +195,7 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
|
|||
firstButtonLabel: "Yes, confirm",
|
||||
firstButtonOnTap: () async {
|
||||
await FaceMLDataDB.instance.resetClusterIDs();
|
||||
await FaceMLDataDB.instance.dropClustersAndPeople();
|
||||
await FaceMLDataDB.instance.dropClustersAndPersonTable();
|
||||
Bus.instance.fire(PeopleChangedEvent());
|
||||
showShortToast(context, "Done");
|
||||
},
|
||||
|
@ -218,7 +218,8 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
|
|||
"You will need to again re-index all the faces. You can drop feedback if you want to label again",
|
||||
firstButtonLabel: "Yes, confirm",
|
||||
firstButtonOnTap: () async {
|
||||
await FaceMLDataDB.instance.dropClustersAndPeople(faces: true);
|
||||
await FaceMLDataDB.instance
|
||||
.dropClustersAndPersonTable(faces: true);
|
||||
Bus.instance.fire(PeopleChangedEvent());
|
||||
showShortToast(context, "Done");
|
||||
},
|
||||
|
@ -237,7 +238,7 @@ class _FaceDebugSectionWidgetState extends State<FaceDebugSectionWidget> {
|
|||
onTap: () async {
|
||||
try {
|
||||
final List<Person> persons =
|
||||
await FaceMLDataDB.instance.getPeople();
|
||||
await FaceMLDataDB.instance.getPersons();
|
||||
final EnteWatch w = EnteWatch('feedback')..start();
|
||||
for (final Person p in persons) {
|
||||
await ClusterFeedbackService.instance
|
||||
|
|
|
@ -275,8 +275,8 @@ class _PersonActionSheetState extends State<PersonActionSheet> {
|
|||
PersonAttr(name: text, faces: <String>[]),
|
||||
);
|
||||
await FaceMLDataDB.instance.insert(p, clusterID);
|
||||
final bool extraPhotosFound =
|
||||
await ClusterFeedbackService.instance.checkAndDoAutomaticMerges(p);
|
||||
final bool extraPhotosFound = await ClusterFeedbackService.instance
|
||||
.checkAndDoAutomaticMerges(p);
|
||||
if (extraPhotosFound) {
|
||||
showShortToast(context, "Extra photos found for $text");
|
||||
}
|
||||
|
@ -296,6 +296,6 @@ class _PersonActionSheetState extends State<PersonActionSheet> {
|
|||
}
|
||||
|
||||
Future<List<Person>> _getPersons() async {
|
||||
return FaceMLDataDB.instance.getPeople();
|
||||
return FaceMLDataDB.instance.getPersons();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue