@bull-board/api
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -21,4 +21,3 @@ "use strict"; | ||
}, {}); | ||
validMetrics.total_system_memory = | ||
redisInfo.total_system_memory || redisInfo.maxmemory; | ||
validMetrics.total_system_memory = redisInfo.total_system_memory || redisInfo.maxmemory; | ||
return validMetrics; | ||
@@ -28,2 +27,3 @@ }; | ||
const jobProps = job.toJSON(); | ||
const stacktrace = jobProps.stacktrace ? jobProps.stacktrace.filter(Boolean) : []; | ||
return { | ||
@@ -38,3 +38,3 @@ id: jobProps.id, | ||
failedReason: jobProps.failedReason, | ||
stacktrace: jobProps.stacktrace ? jobProps.stacktrace.filter(Boolean) : [], | ||
stacktrace, | ||
opts: jobProps.opts, | ||
@@ -46,19 +46,30 @@ data: queue.format('data', jobProps.data), | ||
}; | ||
const statuses = [ | ||
'active', | ||
'completed', | ||
'delayed', | ||
'failed', | ||
'paused', | ||
'waiting', | ||
]; | ||
const allStatuses = ['active', 'completed', 'delayed', 'failed', 'paused', 'waiting']; | ||
const JOB_PER_PAGE = 10; | ||
function getPagination(statuses, counts, currentPage) { | ||
const isLatestStatus = statuses.length > 1; | ||
const total = isLatestStatus | ||
? statuses.reduce((total, status) => total + Math.min(counts[status], JOB_PER_PAGE), 0) | ||
: counts[statuses[0]]; | ||
const start = isLatestStatus ? 0 : (currentPage - 1) * JOB_PER_PAGE; | ||
const pageCount = isLatestStatus ? 1 : Math.ceil(total / JOB_PER_PAGE); | ||
return { | ||
pageCount, | ||
range: { start, end: start + JOB_PER_PAGE - 1 }, | ||
}; | ||
} | ||
async function getAppQueues(pairs, query) { | ||
return await Promise.all(pairs.map(async ([name, queue]) => { | ||
const counts = await queue.getJobCounts(...statuses); | ||
const status = query[name] === 'latest' ? statuses : query[name]; | ||
const jobs = await queue.getJobs(status, 0, 10); | ||
return await Promise.all(pairs.map(async ([queueName, queue]) => { | ||
const status = !query[queueName] || query[queueName] === 'latest' | ||
? allStatuses | ||
: [query[queueName]]; | ||
const currentPage = +query.page || 1; | ||
const counts = await queue.getJobCounts(...allStatuses); | ||
const pagination = getPagination(status, counts, currentPage); | ||
const jobs = await queue.getJobs(status, pagination.range.start, pagination.range.end); | ||
return { | ||
name, | ||
name: queueName, | ||
counts: counts, | ||
jobs: jobs.filter(Boolean).map((job) => formatJob(job, queue)), | ||
pagination, | ||
readOnlyMode: queue.readOnlyMode, | ||
@@ -65,0 +76,0 @@ }; |
{ | ||
"name": "@bull-board/api", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Core server APIs of bull-board", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
import { BaseAdapter } from '../src/queueAdapters/base'; | ||
import { STATUSES } from '../src/constants/statuses'; | ||
export type JobCleanStatus = | ||
| 'completed' | ||
| 'wait' | ||
| 'active' | ||
| 'delayed' | ||
| 'failed'; | ||
export type JobCleanStatus = 'completed' | 'wait' | 'active' | 'delayed' | 'failed'; | ||
@@ -84,2 +79,3 @@ export type Status = keyof typeof STATUSES; | ||
jobs: AppJob[]; | ||
pagination: Pagination; | ||
readOnlyMode: boolean; | ||
@@ -136,7 +132,13 @@ } | ||
setErrorHandler( | ||
handler: (error: Error) => ControllerHandlerReturnType | ||
): IServerAdapter; | ||
setErrorHandler(handler: (error: Error) => ControllerHandlerReturnType): IServerAdapter; | ||
setApiRoutes(routes: AppControllerRoute[]): IServerAdapter; | ||
} | ||
export interface Pagination { | ||
pageCount: number; | ||
range: { | ||
start: number; | ||
end: number; | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39618
649