From 0837776d1f9e7b9c41a2f09b4631a33bcb54bfd4 Mon Sep 17 00:00:00 2001 From: Jorge Miguel Lobo Escalona Date: Wed, 27 Mar 2024 10:26:13 +0100 Subject: [PATCH] M OpenNebula/One#5905: fix list tickets show the last 100 tickets (#3014) Signed-off-by: Jorge Lobo --- .../server/routes/api/zendesk/functions.js | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/src/fireedge/src/server/routes/api/zendesk/functions.js b/src/fireedge/src/server/routes/api/zendesk/functions.js index 348210e04e..0963bc255a 100644 --- a/src/fireedge/src/server/routes/api/zendesk/functions.js +++ b/src/fireedge/src/server/routes/api/zendesk/functions.js @@ -203,35 +203,38 @@ const list = ( if (session.zendesk && session.zendesk.id) { /** LIST ZENDESK */ const zendeskClient = zendesk.createClient(session.zendesk) - zendeskClient.requests.listOpen((err, _, result) => { - let method = ok - let data = '' + zendeskClient.requests.getRequest( + { sort_by: 'id', sort_order: 'desc' }, + (err, _, result) => { + let method = ok + let data = '' - if (err) { - method = internalServerError - data = parseBufferError(err) - } else if (result) { - const ticketCount = { - new: 0, - open: 0, - pending: 0, - hold: 0, - solved: 0, - closed: 0, - } - const tickets = Array.isArray(result) ? result : result - tickets.forEach((ticket) => { - ticket?.status && (ticketCount[ticket.status] += 1) - }) - data = { - tickets: result, - ...ticketCount, + if (err) { + method = internalServerError + data = parseBufferError(err) + } else if (result) { + const ticketCount = { + new: 0, + open: 0, + pending: 0, + hold: 0, + solved: 0, + closed: 0, + } + const tickets = Array.isArray(result) ? result : result + tickets.forEach((ticket) => { + ticket?.status && (ticketCount[ticket.status] += 1) + }) + data = { + tickets: result, + ...ticketCount, + } } + + response.locals.httpCode = httpResponse(method, data) + next() } - - response.locals.httpCode = httpResponse(method, data) - next() - }) + ) } else { response.locals.httpCode = httpResponse(unauthorized) next()