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
|
||||
.selectFrom('asset as stacked')
|
||||
.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.id', '!=', 'stack.primaryAssetId')
|
||||
.where('stacked.deletedAt', 'is', null)
|
||||
.where('stacked.visibility', '=', AssetVisibility.Timeline)
|
||||
.orderBy('stacked.fileCreatedAt', 'asc')
|
||||
.groupBy('stack.id')
|
||||
.as('stacked_assets'),
|
||||
(join) => join.on('stack.id', 'is not', null),
|
||||
|
|
|
|||
Loading…
Reference in New Issue