Skip to content

Commit

Permalink
fix(repo): trace list ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsNotGoodName committed Sep 18, 2023
1 parent be4cbe0 commit 96d576b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal/repo/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,16 @@ func TraceList(ctx context.Context, db database.Querier, page pagination.Page, r
Count int `sql:"primary_key"`
Trace []models.Trace
}
err := SELECT(tracePJ, Raw("t.count").AS("count")).
query := SELECT(tracePJ, Raw("t.count").AS("count")).
FROM(subQuery.AsTable("t").
LEFT_JOIN(Traces, RawString("t.request_id").EQ(Traces.RequestID))).
QueryContext(ctx, db, &res)
LEFT_JOIN(Traces, RawString("t.request_id").EQ(Traces.RequestID)))
// Order
if req.Ascending {
query = query.ORDER_BY(Traces.Seq.ASC())
} else {
query = query.ORDER_BY(Traces.Seq.DESC())
}
err := query.QueryContext(ctx, db, &res)
if err != nil && !errors.Is(err, ErrNoRows) {
return models.DTOTraceListResult{}, err
}
Expand Down

0 comments on commit 96d576b

Please sign in to comment.