|
|
|
|
@ -192,7 +192,7 @@ export class AssetRepository {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GenerateSql({ params: [DummyValue.UUID, { day: 1, month: 1 }] })
|
|
|
|
|
getByDayOfYear(ownerIds: string[], { day, month }: MonthDay): Promise<DayOfYearAssets[]> {
|
|
|
|
|
getByDayOfYear(ownerIds: string[], { day, month }: MonthDay) {
|
|
|
|
|
return this.db
|
|
|
|
|
.with('res', (qb) =>
|
|
|
|
|
qb
|
|
|
|
|
@ -239,16 +239,12 @@ export class AssetRepository {
|
|
|
|
|
.select((eb) => eb.fn.toJson(eb.table('exif')).as('exifInfo')),
|
|
|
|
|
)
|
|
|
|
|
.selectFrom('res')
|
|
|
|
|
.select(
|
|
|
|
|
sql<number>`((now() at time zone 'UTC')::date - ("localDateTime" at time zone 'UTC')::date) / 365`.as(
|
|
|
|
|
'yearsAgo',
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.select(sql<number>`date_part('year', ("localDateTime" at time zone 'UTC')::date)::int`.as('year'))
|
|
|
|
|
.select((eb) => eb.fn.jsonAgg(eb.table('res')).as('assets'))
|
|
|
|
|
.groupBy(sql`("localDateTime" at time zone 'UTC')::date`)
|
|
|
|
|
.orderBy(sql`("localDateTime" at time zone 'UTC')::date`, 'desc')
|
|
|
|
|
.limit(10)
|
|
|
|
|
.execute() as any as Promise<DayOfYearAssets[]>;
|
|
|
|
|
.execute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GenerateSql({ params: [[DummyValue.UUID]] })
|
|
|
|
|
|