mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
M OpenNebula/One#5905: fix list tickets show the last 100 tickets (#3014)
Signed-off-by: Jorge Lobo <jlobo@opennebula.io>
This commit is contained in:
parent
d62ac11a3b
commit
0837776d1f
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user