@@ -153,7 +153,7 @@ export class RunListPresenter extends BasePresenter {
153
153
const periodMs = period ? parse ( period ) : undefined ;
154
154
155
155
//get the runs with tags, there will be multiple rows for each run if it has multiple tags
156
- const runsWithTags = await this . _replica . $queryRaw <
156
+ const runs = await this . _replica . $queryRaw <
157
157
{
158
158
id : string ;
159
159
number : BigInt ;
@@ -174,7 +174,7 @@ export class RunListPresenter extends BasePresenter {
174
174
expiredAt : Date | null ;
175
175
costInCents : number ;
176
176
usageDurationMs : BigInt ;
177
- tagName : string | null ;
177
+ tags : string [ ] ;
178
178
} [ ]
179
179
> `
180
180
SELECT
@@ -197,7 +197,7 @@ export class RunListPresenter extends BasePresenter {
197
197
tr."expiredAt" AS "expiredAt",
198
198
tr."costInCents" AS "costInCents",
199
199
tr."usageDurationMs" AS "usageDurationMs",
200
- tag.name AS "tagName "
200
+ array_remove(array_agg( tag.name), NULL) AS "tags "
201
201
FROM
202
202
${ sqlDatabaseSchema } ."TaskRun" tr
203
203
LEFT JOIN
@@ -271,26 +271,12 @@ WHERE
271
271
)`
272
272
: Prisma . empty
273
273
}
274
+ GROUP BY
275
+ tr.id, bw.version
274
276
ORDER BY
275
277
${ direction === "forward" ? Prisma . sql `tr.id DESC` : Prisma . sql `tr.id ASC` }
276
278
LIMIT ${ pageSize + 1 } ` ;
277
279
278
- //flatten the tags into a single row per run. Needs to be an array and keep the order
279
- const runs = runsWithTags . reduce ( ( acc , run ) => {
280
- const existingRun = acc . find ( ( r ) => r . id === run . id ) ;
281
- if ( existingRun ) {
282
- if ( run . tagName ) {
283
- existingRun . tags . push ( run . tagName ) ;
284
- }
285
- } else {
286
- acc . push ( {
287
- ...run ,
288
- tags : run . tagName ? [ run . tagName ] : [ ] ,
289
- } ) ;
290
- }
291
- return acc ;
292
- } , [ ] as ( Omit < ( typeof runsWithTags ) [ number ] , "tagId" | "tagName" > & { tags : string [ ] } ) [ ] ) ;
293
-
294
280
const hasMore = runs . length > pageSize ;
295
281
296
282
//get cursors for next and previous pages
0 commit comments