mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
refactor(mobile): simplify _localOnlyFilter, introduce query helper
This commit is contained in:
parent
11d5988af4
commit
11df8d2491
1 changed files with 19 additions and 30 deletions
|
|
@ -127,39 +127,28 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|||
origin: TimelineOrigin.main,
|
||||
);
|
||||
|
||||
Expression<bool> _localOnlyFilter() {
|
||||
Expression<bool> _inAlbumWithBackupSelection(BackupSelection selection) {
|
||||
return existsQuery(
|
||||
_db.localAlbumAssetEntity.selectOnly()
|
||||
..addColumns([_db.localAlbumAssetEntity.assetId])
|
||||
..join([
|
||||
innerJoin(
|
||||
_db.localAlbumEntity,
|
||||
_db.localAlbumEntity.id.equalsExp(_db.localAlbumAssetEntity.albumId),
|
||||
useColumns: false,
|
||||
),
|
||||
])
|
||||
..where(
|
||||
_db.localAlbumAssetEntity.assetId.equalsExp(_db.localAssetEntity.id) &
|
||||
_db.localAlbumEntity.backupSelection.equalsValue(BackupSelection.selected),
|
||||
),
|
||||
) &
|
||||
existsQuery(
|
||||
_db.localAlbumAssetEntity.selectOnly()
|
||||
..addColumns([_db.localAlbumAssetEntity.assetId])
|
||||
..join([
|
||||
innerJoin(
|
||||
_db.localAlbumEntity,
|
||||
_db.localAlbumEntity.id.equalsExp(_db.localAlbumAssetEntity.albumId),
|
||||
useColumns: false,
|
||||
),
|
||||
])
|
||||
..where(
|
||||
_db.localAlbumAssetEntity.assetId.equalsExp(_db.localAssetEntity.id) &
|
||||
_db.localAlbumEntity.backupSelection.equalsValue(BackupSelection.excluded),
|
||||
),
|
||||
).not();
|
||||
_db.localAlbumAssetEntity.selectOnly()
|
||||
..addColumns([_db.localAlbumAssetEntity.assetId])
|
||||
..join([
|
||||
innerJoin(
|
||||
_db.localAlbumEntity,
|
||||
_db.localAlbumEntity.id.equalsExp(_db.localAlbumAssetEntity.albumId),
|
||||
useColumns: false,
|
||||
),
|
||||
])
|
||||
..where(
|
||||
_db.localAlbumAssetEntity.assetId.equalsExp(_db.localAssetEntity.id) &
|
||||
_db.localAlbumEntity.backupSelection.equalsValue(selection),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Expression<bool> _localOnlyFilter() =>
|
||||
_inAlbumWithBackupSelection(BackupSelection.selected) &
|
||||
_inAlbumWithBackupSelection(BackupSelection.excluded).not();
|
||||
|
||||
Stream<List<Bucket>> _watchLocalOnlyBucket({GroupAssetsBy groupBy = GroupAssetsBy.day}) {
|
||||
if (groupBy == GroupAssetsBy.none) {
|
||||
return _db.localAssetEntity.count(where: (_) => _localOnlyFilter()).map(_generateBuckets).watchSingle();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue