mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
refactor: implement suggestions
This commit is contained in:
@@ -27,19 +27,20 @@ class DriftMapRepository extends DriftDatabaseRepository {
|
||||
condition = condition & _db.remoteAssetEntity.isFavorite.equals(true);
|
||||
}
|
||||
|
||||
final from = options.timeRange.from;
|
||||
final to = options.timeRange.to;
|
||||
final timeRange = options.timeRange;
|
||||
final hasCustomRange = timeRange.from.isSome || timeRange.to.isSome;
|
||||
|
||||
if (from != null || to != null) {
|
||||
if (from != null) {
|
||||
if (hasCustomRange) {
|
||||
timeRange.from.ifSome((from) {
|
||||
condition = condition & _db.remoteAssetEntity.createdAt.isBiggerOrEqualValue(from);
|
||||
}
|
||||
if (to != null) {
|
||||
});
|
||||
|
||||
timeRange.to.ifSome((to) {
|
||||
condition = condition & _db.remoteAssetEntity.createdAt.isSmallerOrEqualValue(to);
|
||||
}
|
||||
});
|
||||
} else if (options.relativeDays > 0) {
|
||||
final fromDate = DateTime.now().subtract(Duration(days: options.relativeDays));
|
||||
condition = condition & _db.remoteAssetEntity.createdAt.isBiggerOrEqualValue(fromDate);
|
||||
final cutoffDate = DateTime.now().toUtc().subtract(Duration(days: options.relativeDays));
|
||||
condition = condition & _db.remoteAssetEntity.createdAt.isBiggerOrEqualValue(cutoffDate);
|
||||
}
|
||||
|
||||
return condition;
|
||||
|
||||
@@ -552,20 +552,21 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
||||
query.where(_db.remoteAssetEntity.isFavorite.equals(true));
|
||||
}
|
||||
|
||||
final from = options.timeRange.from;
|
||||
final to = options.timeRange.to;
|
||||
final timeRange = options.timeRange;
|
||||
|
||||
if (from != null || to != null) {
|
||||
// Use custom from/to filters
|
||||
if (from != null) {
|
||||
final hasCustomRange = timeRange.from.isSome || timeRange.to.isSome;
|
||||
|
||||
if (hasCustomRange) {
|
||||
timeRange.from.ifSome((from) {
|
||||
query.where(_db.remoteAssetEntity.createdAt.isBiggerOrEqualValue(from));
|
||||
}
|
||||
if (to != null) {
|
||||
});
|
||||
|
||||
timeRange.to.ifSome((to) {
|
||||
query.where(_db.remoteAssetEntity.createdAt.isSmallerOrEqualValue(to));
|
||||
}
|
||||
});
|
||||
} else if (options.relativeDays > 0) {
|
||||
// Use relative days
|
||||
final cutoffDate = DateTime.now().toUtc().subtract(Duration(days: options.relativeDays));
|
||||
|
||||
query.where(_db.remoteAssetEntity.createdAt.isBiggerOrEqualValue(cutoffDate));
|
||||
}
|
||||
|
||||
@@ -606,20 +607,21 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
||||
query.where(_db.remoteAssetEntity.isFavorite.equals(true));
|
||||
}
|
||||
|
||||
final from = options.timeRange.from;
|
||||
final to = options.timeRange.to;
|
||||
final timeRange = options.timeRange;
|
||||
|
||||
if (from != null || to != null) {
|
||||
// Use custom from/to filters
|
||||
if (from != null) {
|
||||
final hasCustomRange = timeRange.from.isSome || timeRange.to.isSome;
|
||||
|
||||
if (hasCustomRange) {
|
||||
timeRange.from.ifSome((from) {
|
||||
query.where(_db.remoteAssetEntity.createdAt.isBiggerOrEqualValue(from));
|
||||
}
|
||||
if (to != null) {
|
||||
});
|
||||
|
||||
timeRange.to.ifSome((to) {
|
||||
query.where(_db.remoteAssetEntity.createdAt.isSmallerOrEqualValue(to));
|
||||
}
|
||||
});
|
||||
} else if (options.relativeDays > 0) {
|
||||
// Use relative days
|
||||
final cutoffDate = DateTime.now().toUtc().subtract(Duration(days: options.relativeDays));
|
||||
|
||||
query.where(_db.remoteAssetEntity.createdAt.isBiggerOrEqualValue(cutoffDate));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user