refactor: update asset aggregation to include JSON formatting and ordering by creation date
parent
52887e47f6
commit
ce31a70d06
|
|
@ -431,12 +431,13 @@ export class AssetRepository {
|
||||||
eb
|
eb
|
||||||
.selectFrom('asset as stacked')
|
.selectFrom('asset as stacked')
|
||||||
.selectAll('stack')
|
.selectAll('stack')
|
||||||
.select((eb) => eb.fn('array_agg', [eb.table('stacked')]).as('assets'))
|
.select(
|
||||||
|
sql<unknown[]>`array_agg(to_json(stacked) ORDER BY stacked."fileCreatedAt" ASC)`.as('assets'),
|
||||||
|
)
|
||||||
.whereRef('stacked.stackId', '=', 'stack.id')
|
.whereRef('stacked.stackId', '=', 'stack.id')
|
||||||
.whereRef('stacked.id', '!=', 'stack.primaryAssetId')
|
.whereRef('stacked.id', '!=', 'stack.primaryAssetId')
|
||||||
.where('stacked.deletedAt', 'is', null)
|
.where('stacked.deletedAt', 'is', null)
|
||||||
.where('stacked.visibility', '=', AssetVisibility.Timeline)
|
.where('stacked.visibility', '=', AssetVisibility.Timeline)
|
||||||
.orderBy('stacked.fileCreatedAt', 'asc')
|
|
||||||
.groupBy('stack.id')
|
.groupBy('stack.id')
|
||||||
.as('stacked_assets'),
|
.as('stacked_assets'),
|
||||||
(join) => join.on('stack.id', 'is not', null),
|
(join) => join.on('stack.id', 'is not', null),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue