mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-25 00:14:42 +01:00
Rename FaceRecognition table
This commit is contained in:
parent
383e38a579
commit
c920a6bc36
12 changed files with 103 additions and 92 deletions
|
@ -207,12 +207,6 @@ Future<void> _initDiContainer(InitIsolateType isolateType) async {
|
||||||
const AlbumRemoteDataSource2(), AlbumSqliteDbDataSource2(c.sqliteDb));
|
const AlbumRemoteDataSource2(), AlbumSqliteDbDataSource2(c.sqliteDb));
|
||||||
c.albumRepo2Remote = const BasicAlbumRepo2(AlbumRemoteDataSource2());
|
c.albumRepo2Remote = const BasicAlbumRepo2(AlbumRemoteDataSource2());
|
||||||
c.albumRepo2Local = BasicAlbumRepo2(AlbumSqliteDbDataSource2(c.sqliteDb));
|
c.albumRepo2Local = BasicAlbumRepo2(AlbumSqliteDbDataSource2(c.sqliteDb));
|
||||||
c.faceRecognitionPersonRepo = const BasicFaceRecognitionPersonRepo(
|
|
||||||
FaceRecognitionPersonRemoteDataSource());
|
|
||||||
c.faceRecognitionPersonRepoRemote = const BasicFaceRecognitionPersonRepo(
|
|
||||||
FaceRecognitionPersonRemoteDataSource());
|
|
||||||
c.faceRecognitionPersonRepoLocal = BasicFaceRecognitionPersonRepo(
|
|
||||||
FaceRecognitionPersonSqliteDbDataSource(c.sqliteDb));
|
|
||||||
c.fileRepo = FileRepo(FileCachedDataSource(c));
|
c.fileRepo = FileRepo(FileCachedDataSource(c));
|
||||||
c.fileRepoRemote = const FileRepo(FileWebdavDataSource());
|
c.fileRepoRemote = const FileRepo(FileWebdavDataSource());
|
||||||
c.fileRepoLocal = FileRepo(FileSqliteDbDataSource(c));
|
c.fileRepoLocal = FileRepo(FileSqliteDbDataSource(c));
|
||||||
|
@ -228,6 +222,12 @@ Future<void> _initDiContainer(InitIsolateType isolateType) async {
|
||||||
const NcAlbumRemoteDataSource(), NcAlbumSqliteDbDataSource(c.sqliteDb));
|
const NcAlbumRemoteDataSource(), NcAlbumSqliteDbDataSource(c.sqliteDb));
|
||||||
c.ncAlbumRepoRemote = const BasicNcAlbumRepo(NcAlbumRemoteDataSource());
|
c.ncAlbumRepoRemote = const BasicNcAlbumRepo(NcAlbumRemoteDataSource());
|
||||||
c.ncAlbumRepoLocal = BasicNcAlbumRepo(NcAlbumSqliteDbDataSource(c.sqliteDb));
|
c.ncAlbumRepoLocal = BasicNcAlbumRepo(NcAlbumSqliteDbDataSource(c.sqliteDb));
|
||||||
|
c.faceRecognitionPersonRepo = const BasicFaceRecognitionPersonRepo(
|
||||||
|
FaceRecognitionPersonRemoteDataSource());
|
||||||
|
c.faceRecognitionPersonRepoRemote = const BasicFaceRecognitionPersonRepo(
|
||||||
|
FaceRecognitionPersonRemoteDataSource());
|
||||||
|
c.faceRecognitionPersonRepoLocal = BasicFaceRecognitionPersonRepo(
|
||||||
|
FaceRecognitionPersonSqliteDbDataSource(c.sqliteDb));
|
||||||
|
|
||||||
c.touchManager = TouchManager(c);
|
c.touchManager = TouchManager(c);
|
||||||
|
|
||||||
|
|
|
@ -434,8 +434,4 @@ extension DiContainerExtension on DiContainer {
|
||||||
DiContainer withLocalFileRepo() => copyWith(fileRepo: OrNull(fileRepoLocal));
|
DiContainer withLocalFileRepo() => copyWith(fileRepo: OrNull(fileRepoLocal));
|
||||||
DiContainer withRemoteTagRepo() => copyWith(tagRepo: OrNull(tagRepoRemote));
|
DiContainer withRemoteTagRepo() => copyWith(tagRepo: OrNull(tagRepoRemote));
|
||||||
DiContainer withLocalTagRepo() => copyWith(tagRepo: OrNull(tagRepoLocal));
|
DiContainer withLocalTagRepo() => copyWith(tagRepo: OrNull(tagRepoLocal));
|
||||||
DiContainer withRemoteFaceRecognitionPersonRepo() => copyWith(
|
|
||||||
faceRecognitionPersonRepo: OrNull(faceRecognitionPersonRepoRemote));
|
|
||||||
DiContainer withLocalFaceRecognitionPersonRepo() => copyWith(
|
|
||||||
faceRecognitionPersonRepo: OrNull(faceRecognitionPersonRepoLocal));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ class FaceRecognitionPersonSqliteDbDataSource
|
||||||
Future<List<FaceRecognitionPerson>> getPersons(Account account) async {
|
Future<List<FaceRecognitionPerson>> getPersons(Account account) async {
|
||||||
_log.info("[getPersons] $account");
|
_log.info("[getPersons] $account");
|
||||||
final dbPersons = await sqliteDb.use((db) async {
|
final dbPersons = await sqliteDb.use((db) async {
|
||||||
return await db.allPersons(account: sql.ByAccount.app(account));
|
return await db.allFaceRecognitionPersons(account: sql.ByAccount.app(account));
|
||||||
});
|
});
|
||||||
return dbPersons
|
return dbPersons
|
||||||
.map((p) {
|
.map((p) {
|
||||||
|
|
|
@ -164,7 +164,7 @@ class SearchSqliteDbDataSource implements SearchDataSource {
|
||||||
// "Ada" will return results from "Ada Crook" but NOT "Adabelle"
|
// "Ada" will return results from "Ada Crook" but NOT "Adabelle"
|
||||||
try {
|
try {
|
||||||
final dbPersons = await _c.sqliteDb.use((db) async {
|
final dbPersons = await _c.sqliteDb.use((db) async {
|
||||||
return await db.personsByName(
|
return await db.faceRecognitionPersonsByName(
|
||||||
appAccount: account,
|
appAccount: account,
|
||||||
name: criteria.input,
|
name: criteria.input,
|
||||||
);
|
);
|
||||||
|
@ -172,7 +172,7 @@ class SearchSqliteDbDataSource implements SearchDataSource {
|
||||||
if (dbPersons.isEmpty) {
|
if (dbPersons.isEmpty) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
final persons = (await dbPersons.convertToAppPerson())
|
final persons = (await dbPersons.convertToAppFaceRecognitionPerson())
|
||||||
.map((p) => PersonBuilder.byFaceRecognitionPerson(account, p))
|
.map((p) => PersonBuilder.byFaceRecognitionPerson(account, p))
|
||||||
.toList();
|
.toList();
|
||||||
_log.info(
|
_log.info(
|
||||||
|
|
|
@ -18,8 +18,8 @@ import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||||
import 'package:np_codegen/np_codegen.dart';
|
import 'package:np_codegen/np_codegen.dart';
|
||||||
|
|
||||||
part 'database.g.dart';
|
part 'database.g.dart';
|
||||||
part 'database_extension.dart';
|
|
||||||
part 'database/nc_album_extension.dart';
|
part 'database/nc_album_extension.dart';
|
||||||
|
part 'database_extension.dart';
|
||||||
|
|
||||||
// remember to also update the truncate method after adding a new table
|
// remember to also update the truncate method after adding a new table
|
||||||
@npLog
|
@npLog
|
||||||
|
@ -36,7 +36,7 @@ part 'database/nc_album_extension.dart';
|
||||||
Albums,
|
Albums,
|
||||||
AlbumShares,
|
AlbumShares,
|
||||||
Tags,
|
Tags,
|
||||||
Persons,
|
FaceRecognitionPersons,
|
||||||
NcAlbums,
|
NcAlbums,
|
||||||
NcAlbumItems,
|
NcAlbumItems,
|
||||||
],
|
],
|
||||||
|
@ -47,7 +47,7 @@ class SqliteDb extends _$SqliteDb {
|
||||||
}) : super(executor ?? platform.openSqliteConnection());
|
}) : super(executor ?? platform.openSqliteConnection());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
get schemaVersion => 5;
|
get schemaVersion => 6;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
get migration => MigrationStrategy(
|
get migration => MigrationStrategy(
|
||||||
|
@ -86,7 +86,7 @@ class SqliteDb extends _$SqliteDb {
|
||||||
await transaction(() async {
|
await transaction(() async {
|
||||||
if (from < 2) {
|
if (from < 2) {
|
||||||
await m.createTable(tags);
|
await m.createTable(tags);
|
||||||
await m.createTable(persons);
|
await m.createTable(faceRecognitionPersons);
|
||||||
await _createIndexV2(m);
|
await _createIndexV2(m);
|
||||||
}
|
}
|
||||||
if (from < 3) {
|
if (from < 3) {
|
||||||
|
@ -100,6 +100,11 @@ class SqliteDb extends _$SqliteDb {
|
||||||
await m.createTable(ncAlbums);
|
await m.createTable(ncAlbums);
|
||||||
await m.createTable(ncAlbumItems);
|
await m.createTable(ncAlbumItems);
|
||||||
}
|
}
|
||||||
|
if (from < 6) {
|
||||||
|
if (from >= 2) {
|
||||||
|
await m.renameTable(faceRecognitionPersons, "persons");
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
_log.shout("[onUpgrade] Failed upgrading sqlite db", e, stackTrace);
|
_log.shout("[onUpgrade] Failed upgrading sqlite db", e, stackTrace);
|
||||||
|
@ -119,8 +124,8 @@ class SqliteDb extends _$SqliteDb {
|
||||||
Future<void> _createIndexV2(Migrator m) async {
|
Future<void> _createIndexV2(Migrator m) async {
|
||||||
await m.createIndex(Index("tags_server_index",
|
await m.createIndex(Index("tags_server_index",
|
||||||
"CREATE INDEX tags_server_index ON tags(server);"));
|
"CREATE INDEX tags_server_index ON tags(server);"));
|
||||||
await m.createIndex(Index("persons_account_index",
|
await m.createIndex(Index("face_recognition_persons_account_index",
|
||||||
"CREATE INDEX persons_account_index ON persons(account);"));
|
"CREATE INDEX face_recognition_persons_account_index ON face_recognition_persons(account);"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _createIndexV3(Migrator m) async {
|
Future<void> _createIndexV3(Migrator m) async {
|
||||||
|
|
|
@ -3905,11 +3905,12 @@ class TagsCompanion extends UpdateCompanion<Tag> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class $PersonsTable extends Persons with TableInfo<$PersonsTable, Person> {
|
class $FaceRecognitionPersonsTable extends FaceRecognitionPersons
|
||||||
|
with TableInfo<$FaceRecognitionPersonsTable, FaceRecognitionPerson> {
|
||||||
@override
|
@override
|
||||||
final GeneratedDatabase attachedDatabase;
|
final GeneratedDatabase attachedDatabase;
|
||||||
final String? _alias;
|
final String? _alias;
|
||||||
$PersonsTable(this.attachedDatabase, [this._alias]);
|
$FaceRecognitionPersonsTable(this.attachedDatabase, [this._alias]);
|
||||||
static const VerificationMeta _rowIdMeta = const VerificationMeta('rowId');
|
static const VerificationMeta _rowIdMeta = const VerificationMeta('rowId');
|
||||||
@override
|
@override
|
||||||
late final GeneratedColumn<int> rowId = GeneratedColumn<int>(
|
late final GeneratedColumn<int> rowId = GeneratedColumn<int>(
|
||||||
|
@ -3948,11 +3949,12 @@ class $PersonsTable extends Persons with TableInfo<$PersonsTable, Person> {
|
||||||
List<GeneratedColumn> get $columns =>
|
List<GeneratedColumn> get $columns =>
|
||||||
[rowId, account, name, thumbFaceId, count];
|
[rowId, account, name, thumbFaceId, count];
|
||||||
@override
|
@override
|
||||||
String get aliasedName => _alias ?? 'persons';
|
String get aliasedName => _alias ?? 'face_recognition_persons';
|
||||||
@override
|
@override
|
||||||
String get actualTableName => 'persons';
|
String get actualTableName => 'face_recognition_persons';
|
||||||
@override
|
@override
|
||||||
VerificationContext validateIntegrity(Insertable<Person> instance,
|
VerificationContext validateIntegrity(
|
||||||
|
Insertable<FaceRecognitionPerson> instance,
|
||||||
{bool isInserting = false}) {
|
{bool isInserting = false}) {
|
||||||
final context = VerificationContext();
|
final context = VerificationContext();
|
||||||
final data = instance.toColumns(true);
|
final data = instance.toColumns(true);
|
||||||
|
@ -3996,9 +3998,9 @@ class $PersonsTable extends Persons with TableInfo<$PersonsTable, Person> {
|
||||||
{account, name},
|
{account, name},
|
||||||
];
|
];
|
||||||
@override
|
@override
|
||||||
Person map(Map<String, dynamic> data, {String? tablePrefix}) {
|
FaceRecognitionPerson map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||||
return Person(
|
return FaceRecognitionPerson(
|
||||||
rowId: attachedDatabase.typeMapping
|
rowId: attachedDatabase.typeMapping
|
||||||
.read(DriftSqlType.int, data['${effectivePrefix}row_id'])!,
|
.read(DriftSqlType.int, data['${effectivePrefix}row_id'])!,
|
||||||
account: attachedDatabase.typeMapping
|
account: attachedDatabase.typeMapping
|
||||||
|
@ -4013,18 +4015,19 @@ class $PersonsTable extends Persons with TableInfo<$PersonsTable, Person> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
$PersonsTable createAlias(String alias) {
|
$FaceRecognitionPersonsTable createAlias(String alias) {
|
||||||
return $PersonsTable(attachedDatabase, alias);
|
return $FaceRecognitionPersonsTable(attachedDatabase, alias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Person extends DataClass implements Insertable<Person> {
|
class FaceRecognitionPerson extends DataClass
|
||||||
|
implements Insertable<FaceRecognitionPerson> {
|
||||||
final int rowId;
|
final int rowId;
|
||||||
final int account;
|
final int account;
|
||||||
final String name;
|
final String name;
|
||||||
final int thumbFaceId;
|
final int thumbFaceId;
|
||||||
final int count;
|
final int count;
|
||||||
const Person(
|
const FaceRecognitionPerson(
|
||||||
{required this.rowId,
|
{required this.rowId,
|
||||||
required this.account,
|
required this.account,
|
||||||
required this.name,
|
required this.name,
|
||||||
|
@ -4041,8 +4044,8 @@ class Person extends DataClass implements Insertable<Person> {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
PersonsCompanion toCompanion(bool nullToAbsent) {
|
FaceRecognitionPersonsCompanion toCompanion(bool nullToAbsent) {
|
||||||
return PersonsCompanion(
|
return FaceRecognitionPersonsCompanion(
|
||||||
rowId: Value(rowId),
|
rowId: Value(rowId),
|
||||||
account: Value(account),
|
account: Value(account),
|
||||||
name: Value(name),
|
name: Value(name),
|
||||||
|
@ -4051,10 +4054,10 @@ class Person extends DataClass implements Insertable<Person> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
factory Person.fromJson(Map<String, dynamic> json,
|
factory FaceRecognitionPerson.fromJson(Map<String, dynamic> json,
|
||||||
{ValueSerializer? serializer}) {
|
{ValueSerializer? serializer}) {
|
||||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
return Person(
|
return FaceRecognitionPerson(
|
||||||
rowId: serializer.fromJson<int>(json['rowId']),
|
rowId: serializer.fromJson<int>(json['rowId']),
|
||||||
account: serializer.fromJson<int>(json['account']),
|
account: serializer.fromJson<int>(json['account']),
|
||||||
name: serializer.fromJson<String>(json['name']),
|
name: serializer.fromJson<String>(json['name']),
|
||||||
|
@ -4074,13 +4077,13 @@ class Person extends DataClass implements Insertable<Person> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Person copyWith(
|
FaceRecognitionPerson copyWith(
|
||||||
{int? rowId,
|
{int? rowId,
|
||||||
int? account,
|
int? account,
|
||||||
String? name,
|
String? name,
|
||||||
int? thumbFaceId,
|
int? thumbFaceId,
|
||||||
int? count}) =>
|
int? count}) =>
|
||||||
Person(
|
FaceRecognitionPerson(
|
||||||
rowId: rowId ?? this.rowId,
|
rowId: rowId ?? this.rowId,
|
||||||
account: account ?? this.account,
|
account: account ?? this.account,
|
||||||
name: name ?? this.name,
|
name: name ?? this.name,
|
||||||
|
@ -4089,7 +4092,7 @@ class Person extends DataClass implements Insertable<Person> {
|
||||||
);
|
);
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return (StringBuffer('Person(')
|
return (StringBuffer('FaceRecognitionPerson(')
|
||||||
..write('rowId: $rowId, ')
|
..write('rowId: $rowId, ')
|
||||||
..write('account: $account, ')
|
..write('account: $account, ')
|
||||||
..write('name: $name, ')
|
..write('name: $name, ')
|
||||||
|
@ -4104,7 +4107,7 @@ class Person extends DataClass implements Insertable<Person> {
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
identical(this, other) ||
|
identical(this, other) ||
|
||||||
(other is Person &&
|
(other is FaceRecognitionPerson &&
|
||||||
other.rowId == this.rowId &&
|
other.rowId == this.rowId &&
|
||||||
other.account == this.account &&
|
other.account == this.account &&
|
||||||
other.name == this.name &&
|
other.name == this.name &&
|
||||||
|
@ -4112,20 +4115,21 @@ class Person extends DataClass implements Insertable<Person> {
|
||||||
other.count == this.count);
|
other.count == this.count);
|
||||||
}
|
}
|
||||||
|
|
||||||
class PersonsCompanion extends UpdateCompanion<Person> {
|
class FaceRecognitionPersonsCompanion
|
||||||
|
extends UpdateCompanion<FaceRecognitionPerson> {
|
||||||
final Value<int> rowId;
|
final Value<int> rowId;
|
||||||
final Value<int> account;
|
final Value<int> account;
|
||||||
final Value<String> name;
|
final Value<String> name;
|
||||||
final Value<int> thumbFaceId;
|
final Value<int> thumbFaceId;
|
||||||
final Value<int> count;
|
final Value<int> count;
|
||||||
const PersonsCompanion({
|
const FaceRecognitionPersonsCompanion({
|
||||||
this.rowId = const Value.absent(),
|
this.rowId = const Value.absent(),
|
||||||
this.account = const Value.absent(),
|
this.account = const Value.absent(),
|
||||||
this.name = const Value.absent(),
|
this.name = const Value.absent(),
|
||||||
this.thumbFaceId = const Value.absent(),
|
this.thumbFaceId = const Value.absent(),
|
||||||
this.count = const Value.absent(),
|
this.count = const Value.absent(),
|
||||||
});
|
});
|
||||||
PersonsCompanion.insert({
|
FaceRecognitionPersonsCompanion.insert({
|
||||||
this.rowId = const Value.absent(),
|
this.rowId = const Value.absent(),
|
||||||
required int account,
|
required int account,
|
||||||
required String name,
|
required String name,
|
||||||
|
@ -4135,7 +4139,7 @@ class PersonsCompanion extends UpdateCompanion<Person> {
|
||||||
name = Value(name),
|
name = Value(name),
|
||||||
thumbFaceId = Value(thumbFaceId),
|
thumbFaceId = Value(thumbFaceId),
|
||||||
count = Value(count);
|
count = Value(count);
|
||||||
static Insertable<Person> custom({
|
static Insertable<FaceRecognitionPerson> custom({
|
||||||
Expression<int>? rowId,
|
Expression<int>? rowId,
|
||||||
Expression<int>? account,
|
Expression<int>? account,
|
||||||
Expression<String>? name,
|
Expression<String>? name,
|
||||||
|
@ -4151,13 +4155,13 @@ class PersonsCompanion extends UpdateCompanion<Person> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
PersonsCompanion copyWith(
|
FaceRecognitionPersonsCompanion copyWith(
|
||||||
{Value<int>? rowId,
|
{Value<int>? rowId,
|
||||||
Value<int>? account,
|
Value<int>? account,
|
||||||
Value<String>? name,
|
Value<String>? name,
|
||||||
Value<int>? thumbFaceId,
|
Value<int>? thumbFaceId,
|
||||||
Value<int>? count}) {
|
Value<int>? count}) {
|
||||||
return PersonsCompanion(
|
return FaceRecognitionPersonsCompanion(
|
||||||
rowId: rowId ?? this.rowId,
|
rowId: rowId ?? this.rowId,
|
||||||
account: account ?? this.account,
|
account: account ?? this.account,
|
||||||
name: name ?? this.name,
|
name: name ?? this.name,
|
||||||
|
@ -4189,7 +4193,7 @@ class PersonsCompanion extends UpdateCompanion<Person> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return (StringBuffer('PersonsCompanion(')
|
return (StringBuffer('FaceRecognitionPersonsCompanion(')
|
||||||
..write('rowId: $rowId, ')
|
..write('rowId: $rowId, ')
|
||||||
..write('account: $account, ')
|
..write('account: $account, ')
|
||||||
..write('name: $name, ')
|
..write('name: $name, ')
|
||||||
|
@ -5297,7 +5301,8 @@ abstract class _$SqliteDb extends GeneratedDatabase {
|
||||||
late final $AlbumsTable albums = $AlbumsTable(this);
|
late final $AlbumsTable albums = $AlbumsTable(this);
|
||||||
late final $AlbumSharesTable albumShares = $AlbumSharesTable(this);
|
late final $AlbumSharesTable albumShares = $AlbumSharesTable(this);
|
||||||
late final $TagsTable tags = $TagsTable(this);
|
late final $TagsTable tags = $TagsTable(this);
|
||||||
late final $PersonsTable persons = $PersonsTable(this);
|
late final $FaceRecognitionPersonsTable faceRecognitionPersons =
|
||||||
|
$FaceRecognitionPersonsTable(this);
|
||||||
late final $NcAlbumsTable ncAlbums = $NcAlbumsTable(this);
|
late final $NcAlbumsTable ncAlbums = $NcAlbumsTable(this);
|
||||||
late final $NcAlbumItemsTable ncAlbumItems = $NcAlbumItemsTable(this);
|
late final $NcAlbumItemsTable ncAlbumItems = $NcAlbumItemsTable(this);
|
||||||
@override
|
@override
|
||||||
|
@ -5316,7 +5321,7 @@ abstract class _$SqliteDb extends GeneratedDatabase {
|
||||||
albums,
|
albums,
|
||||||
albumShares,
|
albumShares,
|
||||||
tags,
|
tags,
|
||||||
persons,
|
faceRecognitionPersons,
|
||||||
ncAlbums,
|
ncAlbums,
|
||||||
ncAlbumItems
|
ncAlbumItems
|
||||||
];
|
];
|
||||||
|
@ -5411,7 +5416,7 @@ abstract class _$SqliteDb extends GeneratedDatabase {
|
||||||
on: TableUpdateQuery.onTableName('accounts',
|
on: TableUpdateQuery.onTableName('accounts',
|
||||||
limitUpdateKind: UpdateKind.delete),
|
limitUpdateKind: UpdateKind.delete),
|
||||||
result: [
|
result: [
|
||||||
TableUpdate('persons', kind: UpdateKind.delete),
|
TableUpdate('face_recognition_persons', kind: UpdateKind.delete),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
WritePropagation(
|
WritePropagation(
|
||||||
|
|
|
@ -526,17 +526,18 @@ extension SqliteDbExtension on SqliteDb {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Person>> allPersons({
|
Future<List<FaceRecognitionPerson>> allFaceRecognitionPersons({
|
||||||
required ByAccount account,
|
required ByAccount account,
|
||||||
}) {
|
}) {
|
||||||
assert((account.sqlAccount != null) != (account.appAccount != null));
|
assert((account.sqlAccount != null) != (account.appAccount != null));
|
||||||
if (account.sqlAccount != null) {
|
if (account.sqlAccount != null) {
|
||||||
final query = select(persons)
|
final query = select(faceRecognitionPersons)
|
||||||
..where((t) => t.account.equals(account.sqlAccount!.rowId));
|
..where((t) => t.account.equals(account.sqlAccount!.rowId));
|
||||||
return query.get();
|
return query.get();
|
||||||
} else {
|
} else {
|
||||||
final query = select(persons).join([
|
final query = select(faceRecognitionPersons).join([
|
||||||
innerJoin(accounts, accounts.rowId.equalsExp(persons.account),
|
innerJoin(
|
||||||
|
accounts, accounts.rowId.equalsExp(faceRecognitionPersons.account),
|
||||||
useColumns: false),
|
useColumns: false),
|
||||||
innerJoin(servers, servers.rowId.equalsExp(accounts.server),
|
innerJoin(servers, servers.rowId.equalsExp(accounts.server),
|
||||||
useColumns: false),
|
useColumns: false),
|
||||||
|
@ -544,18 +545,18 @@ extension SqliteDbExtension on SqliteDb {
|
||||||
..where(servers.address.equals(account.appAccount!.url))
|
..where(servers.address.equals(account.appAccount!.url))
|
||||||
..where(accounts.userId
|
..where(accounts.userId
|
||||||
.equals(account.appAccount!.userId.toCaseInsensitiveString()));
|
.equals(account.appAccount!.userId.toCaseInsensitiveString()));
|
||||||
return query.map((r) => r.readTable(persons)).get();
|
return query.map((r) => r.readTable(faceRecognitionPersons)).get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Person>> personsByName({
|
Future<List<FaceRecognitionPerson>> faceRecognitionPersonsByName({
|
||||||
Account? sqlAccount,
|
Account? sqlAccount,
|
||||||
app.Account? appAccount,
|
app.Account? appAccount,
|
||||||
required String name,
|
required String name,
|
||||||
}) {
|
}) {
|
||||||
assert((sqlAccount != null) != (appAccount != null));
|
assert((sqlAccount != null) != (appAccount != null));
|
||||||
if (sqlAccount != null) {
|
if (sqlAccount != null) {
|
||||||
final query = select(persons)
|
final query = select(faceRecognitionPersons)
|
||||||
..where((t) => t.account.equals(sqlAccount.rowId))
|
..where((t) => t.account.equals(sqlAccount.rowId))
|
||||||
..where((t) =>
|
..where((t) =>
|
||||||
t.name.like(name) |
|
t.name.like(name) |
|
||||||
|
@ -563,8 +564,9 @@ extension SqliteDbExtension on SqliteDb {
|
||||||
t.name.like("$name %"));
|
t.name.like("$name %"));
|
||||||
return query.get();
|
return query.get();
|
||||||
} else {
|
} else {
|
||||||
final query = select(persons).join([
|
final query = select(faceRecognitionPersons).join([
|
||||||
innerJoin(accounts, accounts.rowId.equalsExp(persons.account),
|
innerJoin(
|
||||||
|
accounts, accounts.rowId.equalsExp(faceRecognitionPersons.account),
|
||||||
useColumns: false),
|
useColumns: false),
|
||||||
innerJoin(servers, servers.rowId.equalsExp(accounts.server),
|
innerJoin(servers, servers.rowId.equalsExp(accounts.server),
|
||||||
useColumns: false),
|
useColumns: false),
|
||||||
|
@ -572,10 +574,10 @@ extension SqliteDbExtension on SqliteDb {
|
||||||
..where(servers.address.equals(appAccount!.url))
|
..where(servers.address.equals(appAccount!.url))
|
||||||
..where(
|
..where(
|
||||||
accounts.userId.equals(appAccount.userId.toCaseInsensitiveString()))
|
accounts.userId.equals(appAccount.userId.toCaseInsensitiveString()))
|
||||||
..where(persons.name.like(name) |
|
..where(faceRecognitionPersons.name.like(name) |
|
||||||
persons.name.like("% $name") |
|
faceRecognitionPersons.name.like("% $name") |
|
||||||
persons.name.like("$name %"));
|
faceRecognitionPersons.name.like("$name %"));
|
||||||
return query.map((r) => r.readTable(persons)).get();
|
return query.map((r) => r.readTable(faceRecognitionPersons)).get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,7 +640,7 @@ extension SqliteDbExtension on SqliteDb {
|
||||||
await delete(albums).go();
|
await delete(albums).go();
|
||||||
await delete(albumShares).go();
|
await delete(albumShares).go();
|
||||||
await delete(tags).go();
|
await delete(tags).go();
|
||||||
await delete(persons).go();
|
await delete(faceRecognitionPersons).go();
|
||||||
await delete(ncAlbums).go();
|
await delete(ncAlbums).go();
|
||||||
await delete(ncAlbumItems).go();
|
await delete(ncAlbumItems).go();
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,7 @@ class Tags extends Table {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
class Persons extends Table {
|
class FaceRecognitionPersons extends Table {
|
||||||
IntColumn get rowId => integer().autoIncrement()();
|
IntColumn get rowId => integer().autoIncrement()();
|
||||||
IntColumn get account =>
|
IntColumn get account =>
|
||||||
integer().references(Accounts, #rowId, onDelete: KeyAction.cascade)();
|
integer().references(Accounts, #rowId, onDelete: KeyAction.cascade)();
|
||||||
|
|
|
@ -35,19 +35,20 @@ extension AppTagListExtension on List<Tag> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SqlPersonListExtension on List<sql.Person> {
|
extension SqlFaceRecognitionPersonListExtension
|
||||||
Future<List<FaceRecognitionPerson>> convertToAppPerson() {
|
on List<sql.FaceRecognitionPerson> {
|
||||||
|
Future<List<FaceRecognitionPerson>> convertToAppFaceRecognitionPerson() {
|
||||||
return computeAll(SqliteFaceRecognitionPersonConverter.fromSql);
|
return computeAll(SqliteFaceRecognitionPersonConverter.fromSql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AppPersonListExtension on List<FaceRecognitionPerson> {
|
extension AppFaceRecognitionPersonListExtension on List<FaceRecognitionPerson> {
|
||||||
Future<List<sql.PersonsCompanion>> convertToPersonCompanion(
|
Future<List<sql.FaceRecognitionPersonsCompanion>>
|
||||||
sql.Account? dbAccount) {
|
convertToFaceRecognitionPersonCompanion(sql.Account? dbAccount) {
|
||||||
return map((p) => {
|
return map((p) => {
|
||||||
"account": dbAccount,
|
"account": dbAccount,
|
||||||
"person": p,
|
"person": p,
|
||||||
}).computeAll(_convertAppPerson);
|
}).computeAll(_convertAppFaceRecognitionPerson);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,16 +240,16 @@ class SqliteTagConverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
class SqliteFaceRecognitionPersonConverter {
|
class SqliteFaceRecognitionPersonConverter {
|
||||||
static FaceRecognitionPerson fromSql(sql.Person person) =>
|
static FaceRecognitionPerson fromSql(sql.FaceRecognitionPerson person) =>
|
||||||
FaceRecognitionPerson(
|
FaceRecognitionPerson(
|
||||||
name: person.name,
|
name: person.name,
|
||||||
thumbFaceId: person.thumbFaceId,
|
thumbFaceId: person.thumbFaceId,
|
||||||
count: person.count,
|
count: person.count,
|
||||||
);
|
);
|
||||||
|
|
||||||
static sql.PersonsCompanion toSql(
|
static sql.FaceRecognitionPersonsCompanion toSql(
|
||||||
sql.Account? dbAccount, FaceRecognitionPerson person) =>
|
sql.Account? dbAccount, FaceRecognitionPerson person) =>
|
||||||
sql.PersonsCompanion(
|
sql.FaceRecognitionPersonsCompanion(
|
||||||
account:
|
account:
|
||||||
dbAccount == null ? const Value.absent() : Value(dbAccount.rowId),
|
dbAccount == null ? const Value.absent() : Value(dbAccount.rowId),
|
||||||
name: Value(person.name),
|
name: Value(person.name),
|
||||||
|
@ -331,7 +332,7 @@ sql.TagsCompanion _convertAppTag(Map map) {
|
||||||
return SqliteTagConverter.toSql(account, tag);
|
return SqliteTagConverter.toSql(account, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
sql.PersonsCompanion _convertAppPerson(Map map) {
|
sql.FaceRecognitionPersonsCompanion _convertAppFaceRecognitionPerson(Map map) {
|
||||||
final account = map["account"] as sql.Account?;
|
final account = map["account"] as sql.Account?;
|
||||||
final person = map["person"] as FaceRecognitionPerson;
|
final person = map["person"] as FaceRecognitionPerson;
|
||||||
return SqliteFaceRecognitionPersonConverter.toSql(account, person);
|
return SqliteFaceRecognitionPersonConverter.toSql(account, person);
|
||||||
|
|
|
@ -56,26 +56,26 @@ class SyncFaceRecognitionPerson {
|
||||||
await db.batch((batch) {
|
await db.batch((batch) {
|
||||||
for (final d in deletes) {
|
for (final d in deletes) {
|
||||||
batch.deleteWhere(
|
batch.deleteWhere(
|
||||||
db.persons,
|
db.faceRecognitionPersons,
|
||||||
(sql.$PersonsTable p) =>
|
(sql.$FaceRecognitionPersonsTable p) =>
|
||||||
p.account.equals(dbAccount.rowId) & p.name.equals(d.name),
|
p.account.equals(dbAccount.rowId) & p.name.equals(d.name),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (final u in updates) {
|
for (final u in updates) {
|
||||||
batch.update(
|
batch.update(
|
||||||
db.persons,
|
db.faceRecognitionPersons,
|
||||||
sql.PersonsCompanion(
|
sql.FaceRecognitionPersonsCompanion(
|
||||||
name: sql.Value(u.name),
|
name: sql.Value(u.name),
|
||||||
thumbFaceId: sql.Value(u.thumbFaceId),
|
thumbFaceId: sql.Value(u.thumbFaceId),
|
||||||
count: sql.Value(u.count),
|
count: sql.Value(u.count),
|
||||||
),
|
),
|
||||||
where: (sql.$PersonsTable p) =>
|
where: (sql.$FaceRecognitionPersonsTable p) =>
|
||||||
p.account.equals(dbAccount.rowId) & p.name.equals(u.name),
|
p.account.equals(dbAccount.rowId) & p.name.equals(u.name),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (final i in inserts) {
|
for (final i in inserts) {
|
||||||
batch.insert(
|
batch.insert(
|
||||||
db.persons,
|
db.faceRecognitionPersons,
|
||||||
SqliteFaceRecognitionPersonConverter.toSql(dbAccount, i),
|
SqliteFaceRecognitionPersonConverter.toSql(dbAccount, i),
|
||||||
mode: sql.InsertMode.insertOrIgnore,
|
mode: sql.InsertMode.insertOrIgnore,
|
||||||
);
|
);
|
||||||
|
|
|
@ -319,7 +319,7 @@ Future<void> _truncate() async {
|
||||||
"albums",
|
"albums",
|
||||||
"album_shares",
|
"album_shares",
|
||||||
"tags",
|
"tags",
|
||||||
"persons",
|
"face_recognition_persons",
|
||||||
"nc_albums",
|
"nc_albums",
|
||||||
"nc_album_items",
|
"nc_album_items",
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,8 +43,8 @@ Future<void> _new() async {
|
||||||
await c.sqliteDb.insertAccountOf(account);
|
await c.sqliteDb.insertAccountOf(account);
|
||||||
await c.sqliteDb.batch((batch) {
|
await c.sqliteDb.batch((batch) {
|
||||||
batch.insert(
|
batch.insert(
|
||||||
c.sqliteDb.persons,
|
c.sqliteDb.faceRecognitionPersons,
|
||||||
sql.PersonsCompanion.insert(
|
sql.FaceRecognitionPersonsCompanion.insert(
|
||||||
account: 1, name: "test1", thumbFaceId: 1, count: 1),
|
account: 1, name: "test1", thumbFaceId: 1, count: 1),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -83,12 +83,12 @@ Future<void> _remove() async {
|
||||||
await c.sqliteDb.transaction(() async {
|
await c.sqliteDb.transaction(() async {
|
||||||
await c.sqliteDb.insertAccountOf(account);
|
await c.sqliteDb.insertAccountOf(account);
|
||||||
await c.sqliteDb.batch((batch) {
|
await c.sqliteDb.batch((batch) {
|
||||||
batch.insertAll(c.sqliteDb.persons, [
|
batch.insertAll(c.sqliteDb.faceRecognitionPersons, [
|
||||||
sql.PersonsCompanion.insert(
|
sql.FaceRecognitionPersonsCompanion.insert(
|
||||||
account: 1, name: "test1", thumbFaceId: 1, count: 1),
|
account: 1, name: "test1", thumbFaceId: 1, count: 1),
|
||||||
sql.PersonsCompanion.insert(
|
sql.FaceRecognitionPersonsCompanion.insert(
|
||||||
account: 1, name: "test2", thumbFaceId: 2, count: 10),
|
account: 1, name: "test2", thumbFaceId: 2, count: 10),
|
||||||
sql.PersonsCompanion.insert(
|
sql.FaceRecognitionPersonsCompanion.insert(
|
||||||
account: 1, name: "test3", thumbFaceId: 3, count: 100),
|
account: 1, name: "test3", thumbFaceId: 3, count: 100),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
@ -127,10 +127,10 @@ Future<void> _update() async {
|
||||||
await c.sqliteDb.transaction(() async {
|
await c.sqliteDb.transaction(() async {
|
||||||
await c.sqliteDb.insertAccountOf(account);
|
await c.sqliteDb.insertAccountOf(account);
|
||||||
await c.sqliteDb.batch((batch) {
|
await c.sqliteDb.batch((batch) {
|
||||||
batch.insertAll(c.sqliteDb.persons, [
|
batch.insertAll(c.sqliteDb.faceRecognitionPersons, [
|
||||||
sql.PersonsCompanion.insert(
|
sql.FaceRecognitionPersonsCompanion.insert(
|
||||||
account: 1, name: "test1", thumbFaceId: 1, count: 1),
|
account: 1, name: "test1", thumbFaceId: 1, count: 1),
|
||||||
sql.PersonsCompanion.insert(
|
sql.FaceRecognitionPersonsCompanion.insert(
|
||||||
account: 1, name: "test2", thumbFaceId: 2, count: 10),
|
account: 1, name: "test2", thumbFaceId: 2, count: 10),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
@ -150,11 +150,13 @@ Future<void> _update() async {
|
||||||
|
|
||||||
Future<Map<String, Set<FaceRecognitionPerson>>> _listSqliteDbPersons(
|
Future<Map<String, Set<FaceRecognitionPerson>>> _listSqliteDbPersons(
|
||||||
sql.SqliteDb db) async {
|
sql.SqliteDb db) async {
|
||||||
final query = db.select(db.persons).join([
|
final query = db.select(db.faceRecognitionPersons).join([
|
||||||
sql.innerJoin(db.accounts, db.accounts.rowId.equalsExp(db.persons.account)),
|
sql.innerJoin(db.accounts,
|
||||||
|
db.accounts.rowId.equalsExp(db.faceRecognitionPersons.account)),
|
||||||
]);
|
]);
|
||||||
final result = await query
|
final result = await query
|
||||||
.map((r) => Tuple2(r.readTable(db.accounts), r.readTable(db.persons)))
|
.map((r) => Tuple2(
|
||||||
|
r.readTable(db.accounts), r.readTable(db.faceRecognitionPersons)))
|
||||||
.get();
|
.get();
|
||||||
final product = <String, Set<FaceRecognitionPerson>>{};
|
final product = <String, Set<FaceRecognitionPerson>>{};
|
||||||
for (final r in result) {
|
for (final r in result) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue