Skip to content

Commit

Permalink
feat(next/api): cascade record duration metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
sdjdd committed Aug 9, 2023
1 parent 528733c commit 1316063
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion next/api/src/controller/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class TicketController {
@ResponseBody(TicketListItemResponse)
getAssociatedTickets(@Ctx() ctx: Context) {
const ticket = ctx.state.ticket as Ticket;
return ticket.getAssociatedTickets({ useMasterKey: true });
return ticket.getAssociatedTickets();
}

@Post(':id/associated-tickets')
Expand Down
9 changes: 4 additions & 5 deletions next/api/src/model/Ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,14 @@ export class Ticket extends Model {
const associateTickets = await this.getAssociatedTickets();

const result = await Promise.all(
(options?.cascade ? [...associateTickets, this] : [this]).map((ticket) => {
(options?.cascade ? [...associateTickets, this] : [this]).map(async (ticket) => {
const updater = new TicketUpdater(ticket);
updater.operate(action);
return updater.update(operator, options);
const updatedTicket = await updater.operate(action).update(operator, options);
await durationMetricService.recordOperateTicket(ticket, action);
return updatedTicket;
})
);

await durationMetricService.recordOperateTicket(this, action);

return result.find((ticket) => ticket.id === this.id)!;
}

Expand Down

0 comments on commit 1316063

Please sign in to comment.