Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8879790054 | |||
| 071b271484 |
@@ -0,0 +1,7 @@
|
|||||||
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||||
|
import 'package:immich_mobile/interfaces/database.interface.dart';
|
||||||
|
import 'package:isar/isar.dart';
|
||||||
|
|
||||||
|
abstract interface class IArchiveRepository implements IDatabaseRepository {
|
||||||
|
QueryBuilder<Asset, Asset, QAfterSortBy> getTimelineQuery(int userIsarId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||||
|
import 'package:immich_mobile/interfaces/archive.interface.dart';
|
||||||
|
import 'package:immich_mobile/providers/db.provider.dart';
|
||||||
|
import 'package:immich_mobile/repositories/database.repository.dart';
|
||||||
|
import 'package:isar/isar.dart';
|
||||||
|
|
||||||
|
final archiveRepositoryProvider =
|
||||||
|
Provider((ref) => ArchiveRepository(ref.watch(dbProvider)));
|
||||||
|
|
||||||
|
class ArchiveRepository extends DatabaseRepository
|
||||||
|
implements IArchiveRepository {
|
||||||
|
ArchiveRepository(super.db);
|
||||||
|
|
||||||
|
@override
|
||||||
|
QueryBuilder<Asset, Asset, QAfterSortBy> getTimelineQuery(int userIsarId) {
|
||||||
|
return db.assets
|
||||||
|
.where()
|
||||||
|
.ownerIdEqualToAnyChecksum(userIsarId)
|
||||||
|
.filter()
|
||||||
|
.isArchivedEqualTo(true)
|
||||||
|
.isTrashedEqualTo(false)
|
||||||
|
.sortByFileCreatedAtDesc();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:immich_mobile/repositories/archive.repository.dart';
|
||||||
|
|
||||||
|
final archiveServiceProvider = Provider((ref) {
|
||||||
|
return ArchiveService(ref.watch(archiveRepositoryProvider));
|
||||||
|
});
|
||||||
|
|
||||||
|
class ArchiveService {
|
||||||
|
final ArchiveRepository repository;
|
||||||
|
ArchiveService(this.repository);
|
||||||
|
|
||||||
|
getTimelineQuery(int userIsarId) {
|
||||||
|
return repository.getTimelineQuery(userIsarId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -605,10 +605,10 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
.where((eb) => eb.or([eb('assets.stackId', 'is', null), eb(eb.table('asset_stack'), 'is not', null)])),
|
.where((eb) => eb.or([eb('assets.stackId', 'is', null), eb(eb.table('asset_stack'), 'is not', null)])),
|
||||||
)
|
)
|
||||||
.$if(!!options.userIds, (qb) => qb.where('assets.ownerId', '=', anyUuid(options.userIds!)))
|
.$if(!!options.userIds, (qb) => qb.where('assets.ownerId', '=', anyUuid(options.userIds!)))
|
||||||
.$if(!!options.isArchived, (qb) => qb.where('assets.isArchived', '=', options.isArchived!))
|
.$if(options.isArchived !== undefined, (qb) => qb.where('assets.isArchived', '=', options.isArchived!))
|
||||||
.$if(!!options.isFavorite, (qb) => qb.where('assets.isFavorite', '=', options.isFavorite!))
|
.$if(options.isFavorite !== undefined, (qb) => qb.where('assets.isFavorite', '=', options.isFavorite!))
|
||||||
.$if(!!options.assetType, (qb) => qb.where('assets.type', '=', options.assetType!))
|
.$if(!!options.assetType, (qb) => qb.where('assets.type', '=', options.assetType!))
|
||||||
.$if(!!options.isDuplicate, (qb) =>
|
.$if(options.isDuplicate !== undefined, (qb) =>
|
||||||
qb.where('assets.duplicateId', options.isDuplicate ? 'is not' : 'is', null),
|
qb.where('assets.duplicateId', options.isDuplicate ? 'is not' : 'is', null),
|
||||||
)
|
)
|
||||||
.$if(!!options.tagId, (qb) => withTagId(qb, options.tagId!)),
|
.$if(!!options.tagId, (qb) => withTagId(qb, options.tagId!)),
|
||||||
@@ -622,7 +622,7 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
*/
|
*/
|
||||||
.select((eb) => eb.fn.countAll().as('count'))
|
.select((eb) => eb.fn.countAll().as('count'))
|
||||||
.groupBy('timeBucket')
|
.groupBy('timeBucket')
|
||||||
.orderBy('timeBucket', 'desc')
|
.orderBy('timeBucket', options.order ?? 'desc')
|
||||||
.execute() as any as Promise<TimeBucketItem[]>
|
.execute() as any as Promise<TimeBucketItem[]>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -666,7 +666,7 @@ export class AssetRepository implements IAssetRepository {
|
|||||||
.where('assets.deletedAt', options.isTrashed ? 'is not' : 'is', null)
|
.where('assets.deletedAt', options.isTrashed ? 'is not' : 'is', null)
|
||||||
.where('assets.isVisible', '=', true)
|
.where('assets.isVisible', '=', true)
|
||||||
.where(truncatedDate(options.size), '=', timeBucket.replace(/^[+-]/, ''))
|
.where(truncatedDate(options.size), '=', timeBucket.replace(/^[+-]/, ''))
|
||||||
.orderBy('assets.localDateTime', 'desc')
|
.orderBy('assets.localDateTime', options.order ?? 'desc')
|
||||||
.execute() as any as Promise<AssetEntity[]>;
|
.execute() as any as Promise<AssetEntity[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user