mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-24 13:09:07 +01:00
37cd41e0c9
* Fix #5580 * Improve AP logging
16 lines
575 B
TypeScript
16 lines
575 B
TypeScript
import * as 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}`;
|
|
}
|