mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-28 00:23:08 +02:00
d071d18dd7
* wip * wip * fix * clean up * Update tsconfig.json * Update activitypub.ts * wip
15 lines
570 B
TypeScript
15 lines
570 B
TypeScript
import Bull from 'bull';
|
|
|
|
export function getJobInfo(job: Bull.Job, increment = false) {
|
|
const age = Date.now() - job.timestamp;
|
|
|
|
const formated = age > 60000 ? `${Math.floor(age / 1000 / 60)}m`
|
|
: age > 10000 ? `${Math.floor(age / 1000)}s`
|
|
: `${age}ms`;
|
|
|
|
// onActiveとかonCompletedのattemptsMadeがなぜか0始まりなのでインクリメントする
|
|
const currentAttempts = job.attemptsMade + (increment ? 1 : 0);
|
|
const maxAttempts = job.opts ? job.opts.attempts : 0;
|
|
|
|
return `id=${job.id} attempts=${currentAttempts}/${maxAttempts} age=${formated}`;
|
|
}
|