Skip to content

Commit

Permalink
feat(next/api): evaluation rate formula
Browse files Browse the repository at this point in the history
  • Loading branch information
sdjdd committed Nov 23, 2023
1 parent 6f3dc2c commit eefaa3e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion next/api/src/router/ticket-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ router.get('/', async (ctx) => {
...rest,
});

ctx.body = { ...(data || {}), ...evaluationStats };
const created = data?.created || 0;

ctx.body = {
...data,
...evaluationStats,
// overwrite likeRate and dislikeRate with new formula: evaluationCount / ticketCount
likeRate: created ? evaluationStats.likeCount / created : 0,
dislikeRate: created ? evaluationStats.dislikeCount / created : 0,
};
});

const fieldStatsSchema = yup.object(BaseSchema).shape({
Expand Down

0 comments on commit eefaa3e

Please sign in to comment.