mirror of
https://github.com/immich-app/immich.git
synced 2026-02-13 20:37:51 +03:00
fix: null local date time in timeline queries (#26133)
* fix: null local date time in timeline queries * refactor effectiveCreatedAt --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
@@ -203,7 +203,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
||||
final album = albums.first;
|
||||
final isAscending = album.order == AlbumAssetOrder.asc;
|
||||
final assetCountExp = _db.remoteAssetEntity.id.count();
|
||||
final dateExp = _db.remoteAssetEntity.localDateTime.dateFmt(groupBy);
|
||||
final dateExp = _db.remoteAssetEntity.effectiveCreatedAt(groupBy);
|
||||
|
||||
final query = _db.remoteAssetEntity.selectOnly()
|
||||
..addColumns([assetCountExp, dateExp])
|
||||
@@ -361,7 +361,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
||||
}
|
||||
|
||||
final assetCountExp = _db.remoteAssetEntity.id.count();
|
||||
final dateExp = _db.remoteAssetEntity.localDateTime.dateFmt(groupBy);
|
||||
final dateExp = _db.remoteAssetEntity.effectiveCreatedAt(groupBy);
|
||||
|
||||
final query = _db.remoteAssetEntity.selectOnly()
|
||||
..addColumns([assetCountExp, dateExp])
|
||||
@@ -431,7 +431,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
||||
}
|
||||
|
||||
final assetCountExp = _db.remoteAssetEntity.id.count();
|
||||
final dateExp = _db.remoteAssetEntity.localDateTime.dateFmt(groupBy);
|
||||
final dateExp = _db.remoteAssetEntity.effectiveCreatedAt(groupBy);
|
||||
|
||||
final query = _db.remoteAssetEntity.selectOnly()
|
||||
..addColumns([assetCountExp, dateExp])
|
||||
@@ -501,7 +501,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
||||
}
|
||||
|
||||
final assetCountExp = _db.remoteAssetEntity.id.count();
|
||||
final dateExp = _db.remoteAssetEntity.localDateTime.dateFmt(groupBy);
|
||||
final dateExp = _db.remoteAssetEntity.effectiveCreatedAt(groupBy);
|
||||
|
||||
final query = _db.remoteAssetEntity.selectOnly()
|
||||
..addColumns([assetCountExp, dateExp])
|
||||
@@ -603,7 +603,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
||||
}
|
||||
|
||||
final assetCountExp = _db.remoteAssetEntity.id.count();
|
||||
final dateExp = _db.remoteAssetEntity.localDateTime.dateFmt(groupBy);
|
||||
final dateExp = _db.remoteAssetEntity.effectiveCreatedAt(groupBy);
|
||||
|
||||
final query = _db.remoteAssetEntity.selectOnly()
|
||||
..addColumns([assetCountExp, dateExp])
|
||||
@@ -678,6 +678,11 @@ extension on Expression<DateTime> {
|
||||
}
|
||||
}
|
||||
|
||||
extension on $RemoteAssetEntityTable {
|
||||
Expression<String> effectiveCreatedAt(GroupAssetsBy groupBy) =>
|
||||
coalesce([localDateTime.dateFmt(groupBy), createdAt.dateFmt(groupBy, toLocal: true)]);
|
||||
}
|
||||
|
||||
extension on String {
|
||||
DateTime truncateDate(GroupAssetsBy groupBy) {
|
||||
final format = switch (groupBy) {
|
||||
|
||||
Reference in New Issue
Block a user