Skip to content

Commit

Permalink
feat(next): [stats] ingnore new replies after ticket closed
Browse files Browse the repository at this point in the history
  • Loading branch information
sdjdd committed Feb 22, 2024
1 parent 5f1fb4b commit 1fbaf07
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions next/api/src/cloud/ticketStats/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ export const getTicketDataById = async (id: string, endDate: Date) => {
cursor?: typeof cursor;
}> = [];
timeLine.forEach((replyOrOpsLog) => {
const lastLifeLog = _.last(lifeLogs);
const ticketClosed =
!!lastLifeLog && (lastLifeLog.action === 'close' || lastLifeLog.action === 'resolve');

if (_isOpsLog(replyOrOpsLog)) {
const lastTimeLog = _.last(lifeLogs);
switch (replyOrOpsLog.action) {
case 'selectAssignee':
case 'changeAssignee':
Expand All @@ -157,7 +160,7 @@ export const getTicketDataById = async (id: string, endDate: Date) => {
authorId: replyOrOpsLog.data?.operator?.objectId,
createdAt: replyOrOpsLog.createdAt,
cursor:
!!replyOrOpsLog.internal || cursor.lastReplyType === 'customerService'
!!replyOrOpsLog.internal || cursor.lastReplyType === 'customerService' || ticketClosed
? undefined
: {
...cursor,
Expand All @@ -167,12 +170,12 @@ export const getTicketDataById = async (id: string, endDate: Date) => {
break;
case 'resolve':
case 'close':
if (!lastTimeLog || lastTimeLog.action === 'reopen') {
if (!ticketClosed) {
lifeLogs.push(replyOrOpsLog);
}
break;
case 'reopen':
if (lastTimeLog && (lastTimeLog.action === 'close' || lastTimeLog.action === 'resolve')) {
if (ticketClosed) {
lifeLogs.push(replyOrOpsLog);
}
if (_getReplyOrOpsLogType(replyOrOpsLog, ticket.authorId) === 'staff') {
Expand All @@ -196,7 +199,7 @@ export const getTicketDataById = async (id: string, endDate: Date) => {
authorId: replyOrOpsLog.authorId,
createdAt: replyOrOpsLog.createdAt,
cursor:
!!replyOrOpsLog.internal || cursor.lastReplyType === 'customerService'
!!replyOrOpsLog.internal || cursor.lastReplyType === 'customerService' || ticketClosed
? undefined
: {
...cursor,
Expand Down

0 comments on commit 1fbaf07

Please sign in to comment.