feat(web): timeline bucket for albums (4) (#3604)

* feat: server changes for album timeline

* feat(web): album timeline view

* chore: open api

* chore: remove archive action

* fix: favorite for non-owners
This commit is contained in:
Jason Rasmussen
2023-08-11 12:00:51 -04:00
committed by GitHub
parent 36dc7bd924
commit 5cd13227ad
47 changed files with 1014 additions and 757 deletions

View File

@@ -181,6 +181,7 @@ export class AlbumRepository implements IAlbumRepository {
relations: {
owner: true,
sharedUsers: true,
sharedLinks: true,
assets: true,
},
});

View File

@@ -366,10 +366,10 @@ export class AssetRepository implements IAssetRepository {
return result;
}
getTimeBuckets(userId: string, options: TimeBucketOptions): Promise<TimeBucketItem[]> {
getTimeBuckets(options: TimeBucketOptions): Promise<TimeBucketItem[]> {
const truncateValue = truncateMap[options.size];
return this.getBuilder(userId, options)
return this.getBuilder(options)
.select(`COUNT(asset.id)::int`, 'count')
.addSelect(`date_trunc('${truncateValue}', "fileCreatedAt")`, 'timeBucket')
.groupBy(`date_trunc('${truncateValue}', "fileCreatedAt")`)
@@ -377,27 +377,30 @@ export class AssetRepository implements IAssetRepository {
.getRawMany();
}
getByTimeBucket(userId: string, timeBucket: string, options: TimeBucketOptions): Promise<AssetEntity[]> {
getByTimeBucket(timeBucket: string, options: TimeBucketOptions): Promise<AssetEntity[]> {
const truncateValue = truncateMap[options.size];
return this.getBuilder(userId, options)
return this.getBuilder(options)
.andWhere(`date_trunc('${truncateValue}', "fileCreatedAt") = :timeBucket`, { timeBucket })
.orderBy('asset.fileCreatedAt', 'DESC')
.getMany();
}
private getBuilder(userId: string, options: TimeBucketOptions) {
const { isArchived, isFavorite, albumId, personId } = options;
private getBuilder(options: TimeBucketOptions) {
const { isArchived, isFavorite, albumId, personId, userId } = options;
let builder = this.repository
.createQueryBuilder('asset')
.where('asset.ownerId = :userId', { userId })
.andWhere('asset.isVisible = true')
.where('asset.isVisible = true')
.leftJoinAndSelect('asset.exifInfo', 'exifInfo');
if (albumId) {
builder = builder.leftJoin('asset.albums', 'album').andWhere('album.id = :albumId', { albumId });
}
if (userId) {
builder = builder.where('asset.ownerId = :userId', { userId });
}
if (isArchived != undefined) {
builder = builder.andWhere('asset.isArchived = :isArchived', { isArchived });
}