|
|
|
|
@ -124,6 +124,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
innerJoin(
|
|
|
|
|
_db.localAlbumAssetEntity,
|
|
|
|
|
_db.localAlbumAssetEntity.assetId.equalsExp(_db.localAssetEntity.id),
|
|
|
|
|
useColumns: false,
|
|
|
|
|
),
|
|
|
|
|
])
|
|
|
|
|
..where(_db.localAlbumAssetEntity.albumId.equals(albumId))
|
|
|
|
|
@ -147,6 +148,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
innerJoin(
|
|
|
|
|
_db.localAlbumAssetEntity,
|
|
|
|
|
_db.localAlbumAssetEntity.assetId.equalsExp(_db.localAssetEntity.id),
|
|
|
|
|
useColumns: false,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
@ -179,9 +181,13 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
_db.remoteAlbumAssetEntity,
|
|
|
|
|
_db.remoteAlbumAssetEntity.assetId
|
|
|
|
|
.equalsExp(_db.remoteAssetEntity.id),
|
|
|
|
|
useColumns: false,
|
|
|
|
|
),
|
|
|
|
|
])
|
|
|
|
|
..where(_db.remoteAlbumAssetEntity.albumId.equals(albumId))
|
|
|
|
|
..where(
|
|
|
|
|
_db.remoteAssetEntity.deletedAt.isNull() &
|
|
|
|
|
_db.remoteAlbumAssetEntity.albumId.equals(albumId),
|
|
|
|
|
)
|
|
|
|
|
..groupBy([dateExp])
|
|
|
|
|
..orderBy([OrderingTerm.desc(dateExp)]);
|
|
|
|
|
|
|
|
|
|
@ -203,10 +209,14 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
_db.remoteAlbumAssetEntity,
|
|
|
|
|
_db.remoteAlbumAssetEntity.assetId
|
|
|
|
|
.equalsExp(_db.remoteAssetEntity.id),
|
|
|
|
|
useColumns: false,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
..where(_db.remoteAlbumAssetEntity.albumId.equals(albumId))
|
|
|
|
|
..where(
|
|
|
|
|
_db.remoteAssetEntity.deletedAt.isNull() &
|
|
|
|
|
_db.remoteAlbumAssetEntity.albumId.equals(albumId),
|
|
|
|
|
)
|
|
|
|
|
..orderBy([OrderingTerm.desc(_db.remoteAssetEntity.createdAt)])
|
|
|
|
|
..limit(count, offset: offset);
|
|
|
|
|
return query
|
|
|
|
|
@ -214,15 +224,17 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Stream<List<Bucket>> watchFavoriteBucket(
|
|
|
|
|
String userId, {
|
|
|
|
|
Stream<List<Bucket>> watchRemoteBucket(
|
|
|
|
|
String ownerId, {
|
|
|
|
|
GroupAssetsBy groupBy = GroupAssetsBy.day,
|
|
|
|
|
}) {
|
|
|
|
|
if (groupBy == GroupAssetsBy.none) {
|
|
|
|
|
return _db.remoteAssetEntity
|
|
|
|
|
.count(
|
|
|
|
|
where: (row) =>
|
|
|
|
|
row.isFavorite.equals(true) & row.ownerId.equals(userId),
|
|
|
|
|
row.deletedAt.isNull() &
|
|
|
|
|
row.visibility.equalsValue(AssetVisibility.timeline) &
|
|
|
|
|
row.ownerId.equals(ownerId),
|
|
|
|
|
)
|
|
|
|
|
.map(_generateBuckets)
|
|
|
|
|
.watchSingle();
|
|
|
|
|
@ -234,8 +246,10 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
final query = _db.remoteAssetEntity.selectOnly()
|
|
|
|
|
..addColumns([assetCountExp, dateExp])
|
|
|
|
|
..where(
|
|
|
|
|
_db.remoteAssetEntity.ownerId.equals(userId) &
|
|
|
|
|
_db.remoteAssetEntity.isFavorite.equals(true),
|
|
|
|
|
_db.remoteAssetEntity.deletedAt.isNull() &
|
|
|
|
|
_db.remoteAssetEntity.visibility
|
|
|
|
|
.equalsValue(AssetVisibility.timeline) &
|
|
|
|
|
_db.remoteAssetEntity.ownerId.equals(ownerId),
|
|
|
|
|
)
|
|
|
|
|
..groupBy([dateExp])
|
|
|
|
|
..orderBy([OrderingTerm.desc(dateExp)]);
|
|
|
|
|
@ -247,14 +261,17 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
}).watch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<List<BaseAsset>> getFavoriteBucketAssets(
|
|
|
|
|
String userId, {
|
|
|
|
|
Future<List<BaseAsset>> getRemoteBucketAssets(
|
|
|
|
|
String ownerId, {
|
|
|
|
|
required int offset,
|
|
|
|
|
required int count,
|
|
|
|
|
}) {
|
|
|
|
|
final query = _db.remoteAssetEntity.select()
|
|
|
|
|
..where(
|
|
|
|
|
(row) => row.isFavorite.equals(true) & row.ownerId.equals(userId),
|
|
|
|
|
(row) =>
|
|
|
|
|
row.deletedAt.isNull() &
|
|
|
|
|
row.visibility.equalsValue(AssetVisibility.timeline) &
|
|
|
|
|
row.ownerId.equals(ownerId),
|
|
|
|
|
)
|
|
|
|
|
..orderBy([(row) => OrderingTerm.desc(row.createdAt)])
|
|
|
|
|
..limit(count, offset: offset);
|
|
|
|
|
@ -262,7 +279,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
return query.map((row) => row.toDto()).get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Stream<List<Bucket>> watchTrashBucket(
|
|
|
|
|
Stream<List<Bucket>> watchFavoriteBucket(
|
|
|
|
|
String userId, {
|
|
|
|
|
GroupAssetsBy groupBy = GroupAssetsBy.day,
|
|
|
|
|
}) {
|
|
|
|
|
@ -270,7 +287,9 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
return _db.remoteAssetEntity
|
|
|
|
|
.count(
|
|
|
|
|
where: (row) =>
|
|
|
|
|
row.deletedAt.isNotNull() & row.ownerId.equals(userId),
|
|
|
|
|
row.deletedAt.isNull() &
|
|
|
|
|
row.isFavorite.equals(true) &
|
|
|
|
|
row.ownerId.equals(userId),
|
|
|
|
|
)
|
|
|
|
|
.map(_generateBuckets)
|
|
|
|
|
.watchSingle();
|
|
|
|
|
@ -282,8 +301,9 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
final query = _db.remoteAssetEntity.selectOnly()
|
|
|
|
|
..addColumns([assetCountExp, dateExp])
|
|
|
|
|
..where(
|
|
|
|
|
_db.remoteAssetEntity.ownerId.equals(userId) &
|
|
|
|
|
_db.remoteAssetEntity.deletedAt.isNotNull(),
|
|
|
|
|
_db.remoteAssetEntity.deletedAt.isNull() &
|
|
|
|
|
_db.remoteAssetEntity.ownerId.equals(userId) &
|
|
|
|
|
_db.remoteAssetEntity.isFavorite.equals(true),
|
|
|
|
|
)
|
|
|
|
|
..groupBy([dateExp])
|
|
|
|
|
..orderBy([OrderingTerm.desc(dateExp)]);
|
|
|
|
|
@ -295,14 +315,17 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
}).watch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<List<BaseAsset>> getTrashBucketAssets(
|
|
|
|
|
Future<List<BaseAsset>> getFavoriteBucketAssets(
|
|
|
|
|
String userId, {
|
|
|
|
|
required int offset,
|
|
|
|
|
required int count,
|
|
|
|
|
}) {
|
|
|
|
|
final query = _db.remoteAssetEntity.select()
|
|
|
|
|
..where(
|
|
|
|
|
(row) => row.deletedAt.isNotNull() & row.ownerId.equals(userId),
|
|
|
|
|
(row) =>
|
|
|
|
|
row.deletedAt.isNull() &
|
|
|
|
|
row.isFavorite.equals(true) &
|
|
|
|
|
row.ownerId.equals(userId),
|
|
|
|
|
)
|
|
|
|
|
..orderBy([(row) => OrderingTerm.desc(row.createdAt)])
|
|
|
|
|
..limit(count, offset: offset);
|
|
|
|
|
@ -310,7 +333,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
return query.map((row) => row.toDto()).get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Stream<List<Bucket>> watchArchiveBucket(
|
|
|
|
|
Stream<List<Bucket>> watchTrashBucket(
|
|
|
|
|
String userId, {
|
|
|
|
|
GroupAssetsBy groupBy = GroupAssetsBy.day,
|
|
|
|
|
}) {
|
|
|
|
|
@ -318,8 +341,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
return _db.remoteAssetEntity
|
|
|
|
|
.count(
|
|
|
|
|
where: (row) =>
|
|
|
|
|
row.visibility.equalsValue(AssetVisibility.archive) &
|
|
|
|
|
row.ownerId.equals(userId),
|
|
|
|
|
row.deletedAt.isNotNull() & row.ownerId.equals(userId),
|
|
|
|
|
)
|
|
|
|
|
.map(_generateBuckets)
|
|
|
|
|
.watchSingle();
|
|
|
|
|
@ -332,8 +354,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
..addColumns([assetCountExp, dateExp])
|
|
|
|
|
..where(
|
|
|
|
|
_db.remoteAssetEntity.ownerId.equals(userId) &
|
|
|
|
|
_db.remoteAssetEntity.visibility
|
|
|
|
|
.equalsValue(AssetVisibility.archive),
|
|
|
|
|
_db.remoteAssetEntity.deletedAt.isNotNull(),
|
|
|
|
|
)
|
|
|
|
|
..groupBy([dateExp])
|
|
|
|
|
..orderBy([OrderingTerm.desc(dateExp)]);
|
|
|
|
|
@ -345,16 +366,14 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
}).watch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<List<BaseAsset>> getArchiveBucketAssets(
|
|
|
|
|
Future<List<BaseAsset>> getTrashBucketAssets(
|
|
|
|
|
String userId, {
|
|
|
|
|
required int offset,
|
|
|
|
|
required int count,
|
|
|
|
|
}) {
|
|
|
|
|
final query = _db.remoteAssetEntity.select()
|
|
|
|
|
..where(
|
|
|
|
|
(row) =>
|
|
|
|
|
row.ownerId.equals(userId) &
|
|
|
|
|
row.visibility.equalsValue(AssetVisibility.archive),
|
|
|
|
|
(row) => row.deletedAt.isNotNull() & row.ownerId.equals(userId),
|
|
|
|
|
)
|
|
|
|
|
..orderBy([(row) => OrderingTerm.desc(row.createdAt)])
|
|
|
|
|
..limit(count, offset: offset);
|
|
|
|
|
@ -362,7 +381,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
return query.map((row) => row.toDto()).get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Stream<List<Bucket>> watchLockedFolderBucket(
|
|
|
|
|
Stream<List<Bucket>> watchArchiveBucket(
|
|
|
|
|
String userId, {
|
|
|
|
|
GroupAssetsBy groupBy = GroupAssetsBy.day,
|
|
|
|
|
}) {
|
|
|
|
|
@ -370,7 +389,8 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
return _db.remoteAssetEntity
|
|
|
|
|
.count(
|
|
|
|
|
where: (row) =>
|
|
|
|
|
row.visibility.equalsValue(AssetVisibility.locked) &
|
|
|
|
|
row.deletedAt.isNull() &
|
|
|
|
|
row.visibility.equalsValue(AssetVisibility.archive) &
|
|
|
|
|
row.ownerId.equals(userId),
|
|
|
|
|
)
|
|
|
|
|
.map(_generateBuckets)
|
|
|
|
|
@ -383,9 +403,10 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
final query = _db.remoteAssetEntity.selectOnly()
|
|
|
|
|
..addColumns([assetCountExp, dateExp])
|
|
|
|
|
..where(
|
|
|
|
|
_db.remoteAssetEntity.ownerId.equals(userId) &
|
|
|
|
|
_db.remoteAssetEntity.deletedAt.isNull() &
|
|
|
|
|
_db.remoteAssetEntity.ownerId.equals(userId) &
|
|
|
|
|
_db.remoteAssetEntity.visibility
|
|
|
|
|
.equalsValue(AssetVisibility.locked),
|
|
|
|
|
.equalsValue(AssetVisibility.archive),
|
|
|
|
|
)
|
|
|
|
|
..groupBy([dateExp])
|
|
|
|
|
..orderBy([OrderingTerm.desc(dateExp)]);
|
|
|
|
|
@ -397,7 +418,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
}).watch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<List<BaseAsset>> getLockedFolderBucketAssets(
|
|
|
|
|
Future<List<BaseAsset>> getArchiveBucketAssets(
|
|
|
|
|
String userId, {
|
|
|
|
|
required int offset,
|
|
|
|
|
required int count,
|
|
|
|
|
@ -405,8 +426,9 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
final query = _db.remoteAssetEntity.select()
|
|
|
|
|
..where(
|
|
|
|
|
(row) =>
|
|
|
|
|
row.visibility.equalsValue(AssetVisibility.locked) &
|
|
|
|
|
row.ownerId.equals(userId),
|
|
|
|
|
row.deletedAt.isNull() &
|
|
|
|
|
row.ownerId.equals(userId) &
|
|
|
|
|
row.visibility.equalsValue(AssetVisibility.archive),
|
|
|
|
|
)
|
|
|
|
|
..orderBy([(row) => OrderingTerm.desc(row.createdAt)])
|
|
|
|
|
..limit(count, offset: offset);
|
|
|
|
|
@ -414,7 +436,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
return query.map((row) => row.toDto()).get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Stream<List<Bucket>> watchVideoBucket(
|
|
|
|
|
Stream<List<Bucket>> watchLockedFolderBucket(
|
|
|
|
|
String userId, {
|
|
|
|
|
GroupAssetsBy groupBy = GroupAssetsBy.day,
|
|
|
|
|
}) {
|
|
|
|
|
@ -422,8 +444,8 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
return _db.remoteAssetEntity
|
|
|
|
|
.count(
|
|
|
|
|
where: (row) =>
|
|
|
|
|
row.type.equalsValue(AssetType.video) &
|
|
|
|
|
row.visibility.equalsValue(AssetVisibility.timeline) &
|
|
|
|
|
row.deletedAt.isNull() &
|
|
|
|
|
row.visibility.equalsValue(AssetVisibility.locked) &
|
|
|
|
|
row.ownerId.equals(userId),
|
|
|
|
|
)
|
|
|
|
|
.map(_generateBuckets)
|
|
|
|
|
@ -436,10 +458,10 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
final query = _db.remoteAssetEntity.selectOnly()
|
|
|
|
|
..addColumns([assetCountExp, dateExp])
|
|
|
|
|
..where(
|
|
|
|
|
_db.remoteAssetEntity.ownerId.equals(userId) &
|
|
|
|
|
_db.remoteAssetEntity.type.equalsValue(AssetType.video) &
|
|
|
|
|
_db.remoteAssetEntity.deletedAt.isNull() &
|
|
|
|
|
_db.remoteAssetEntity.ownerId.equals(userId) &
|
|
|
|
|
_db.remoteAssetEntity.visibility
|
|
|
|
|
.equalsValue(AssetVisibility.timeline),
|
|
|
|
|
.equalsValue(AssetVisibility.locked),
|
|
|
|
|
)
|
|
|
|
|
..groupBy([dateExp])
|
|
|
|
|
..orderBy([OrderingTerm.desc(dateExp)]);
|
|
|
|
|
@ -451,7 +473,7 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
}).watch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<List<BaseAsset>> getVideoBucketAssets(
|
|
|
|
|
Future<List<BaseAsset>> getLockedFolderBucketAssets(
|
|
|
|
|
String userId, {
|
|
|
|
|
required int offset,
|
|
|
|
|
required int count,
|
|
|
|
|
@ -459,10 +481,9 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
final query = _db.remoteAssetEntity.select()
|
|
|
|
|
..where(
|
|
|
|
|
(row) =>
|
|
|
|
|
_db.remoteAssetEntity.type.equalsValue(AssetType.video) &
|
|
|
|
|
_db.remoteAssetEntity.visibility
|
|
|
|
|
.equalsValue(AssetVisibility.timeline) &
|
|
|
|
|
_db.remoteAssetEntity.ownerId.equals(userId),
|
|
|
|
|
row.deletedAt.isNull() &
|
|
|
|
|
row.visibility.equalsValue(AssetVisibility.locked) &
|
|
|
|
|
row.ownerId.equals(userId),
|
|
|
|
|
)
|
|
|
|
|
..orderBy([(row) => OrderingTerm.desc(row.createdAt)])
|
|
|
|
|
..limit(count, offset: offset);
|
|
|
|
|
@ -470,8 +491,8 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
return query.map((row) => row.toDto()).get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Stream<List<Bucket>> watchRemoteBucket(
|
|
|
|
|
List<String> userIds, {
|
|
|
|
|
Stream<List<Bucket>> watchVideoBucket(
|
|
|
|
|
String userId, {
|
|
|
|
|
GroupAssetsBy groupBy = GroupAssetsBy.day,
|
|
|
|
|
}) {
|
|
|
|
|
if (groupBy == GroupAssetsBy.none) {
|
|
|
|
|
@ -479,8 +500,9 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
.count(
|
|
|
|
|
where: (row) =>
|
|
|
|
|
row.deletedAt.isNull() &
|
|
|
|
|
row.type.equalsValue(AssetType.video) &
|
|
|
|
|
row.visibility.equalsValue(AssetVisibility.timeline) &
|
|
|
|
|
row.ownerId.isIn(userIds),
|
|
|
|
|
row.ownerId.equals(userId),
|
|
|
|
|
)
|
|
|
|
|
.map(_generateBuckets)
|
|
|
|
|
.watchSingle();
|
|
|
|
|
@ -493,9 +515,10 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
..addColumns([assetCountExp, dateExp])
|
|
|
|
|
..where(
|
|
|
|
|
_db.remoteAssetEntity.deletedAt.isNull() &
|
|
|
|
|
_db.remoteAssetEntity.ownerId.equals(userId) &
|
|
|
|
|
_db.remoteAssetEntity.type.equalsValue(AssetType.video) &
|
|
|
|
|
_db.remoteAssetEntity.visibility
|
|
|
|
|
.equalsValue(AssetVisibility.timeline) &
|
|
|
|
|
_db.remoteAssetEntity.ownerId.isIn(userIds),
|
|
|
|
|
.equalsValue(AssetVisibility.timeline),
|
|
|
|
|
)
|
|
|
|
|
..groupBy([dateExp])
|
|
|
|
|
..orderBy([OrderingTerm.desc(dateExp)]);
|
|
|
|
|
@ -507,8 +530,8 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
}).watch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<List<BaseAsset>> getRemoteBucketAssets(
|
|
|
|
|
List<String> userIds, {
|
|
|
|
|
Future<List<BaseAsset>> getVideoBucketAssets(
|
|
|
|
|
String userId, {
|
|
|
|
|
required int offset,
|
|
|
|
|
required int count,
|
|
|
|
|
}) {
|
|
|
|
|
@ -516,10 +539,11 @@ class DriftTimelineRepository extends DriftDatabaseRepository {
|
|
|
|
|
..where(
|
|
|
|
|
(row) =>
|
|
|
|
|
row.deletedAt.isNull() &
|
|
|
|
|
row.type.equalsValue(AssetType.video) &
|
|
|
|
|
row.visibility.equalsValue(AssetVisibility.timeline) &
|
|
|
|
|
row.ownerId.isIn(userIds),
|
|
|
|
|
row.ownerId.equals(userId),
|
|
|
|
|
)
|
|
|
|
|
..orderBy([(t) => OrderingTerm.desc(t.createdAt)])
|
|
|
|
|
..orderBy([(row) => OrderingTerm.desc(row.createdAt)])
|
|
|
|
|
..limit(count, offset: offset);
|
|
|
|
|
|
|
|
|
|
return query.map((row) => row.toDto()).get();
|
|
|
|
|
|