mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor code
rollback changes in BackgroundServicePlugin
This commit is contained in:
parent
558e1e7654
commit
a89a35beed
4 changed files with 7 additions and 48 deletions
|
|
@ -66,7 +66,7 @@ class DriftLocalAssetRepository extends DriftDatabaseRepository {
|
|||
return _db.managers.localAssetEntity.filter((e) => e.checksum.isNull().not()).count();
|
||||
}
|
||||
|
||||
Future<List<LocalAsset>> getAssetsByChecksums(Iterable<String> checksums) {
|
||||
Future<List<LocalAsset>> getByChecksums(Iterable<String> checksums) {
|
||||
if (checksums.isEmpty) return Future.value([]);
|
||||
final query = _db.localAssetEntity.select()..where((lae) => lae.checksum.isIn(checksums));
|
||||
return query.map((row) => row.toDto()).get();
|
||||
|
|
|
|||
|
|
@ -254,22 +254,12 @@ class RemoteAssetRepository extends DriftDatabaseRepository {
|
|||
return _db.managers.remoteAssetEntity.count();
|
||||
}
|
||||
|
||||
Future<List<RemoteAsset>> getAssetsByChecksums(Iterable<String> checksums, {bool? isTrashed}) {
|
||||
Future<List<RemoteAsset>> getByChecksums(Iterable<String> checksums, {bool? isTrashed}) {
|
||||
if (checksums.isEmpty) return Future.value([]);
|
||||
final conditions = <Expression<bool>>[
|
||||
_db.remoteAssetEntity.checksum.isIn(checksums),
|
||||
];
|
||||
|
||||
final query = _db.remoteAssetEntity.select()..where((rae) => rae.checksum.isIn(checksums));
|
||||
if (isTrashed != null) {
|
||||
if (isTrashed) {
|
||||
conditions.add(_db.remoteAssetEntity.deletedAt.isNotNull());
|
||||
} else {
|
||||
conditions.add(_db.remoteAssetEntity.deletedAt.isNull());
|
||||
}
|
||||
query.where((rae) => isTrashed ? rae.deletedAt.isNotNull() : rae.deletedAt.isNull());
|
||||
}
|
||||
|
||||
final query = _db.remoteAssetEntity.select()..where((rae) => conditions.reduce((a, b) => a & b));
|
||||
return query.map((row) => row.toDto()).get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue