We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 540b8d6 commit 761d584Copy full SHA for 761d584
src/job/touch.ts
@@ -1,3 +1,4 @@
1
+import { JobError } from 'src/utils';
2
import { Job } from '.';
3
4
export type TouchMethod = (progress?: number) => Promise<Job>;
@@ -8,6 +9,9 @@ export type TouchMethod = (progress?: number) => Promise<Job>;
8
9
* @param progress 0 to 100
10
*/
11
export const touch: TouchMethod = async function (this: Job, progress?): Promise<Job> {
12
+ if (progress && (progress < 0 || progress > 100)) {
13
+ throw new JobError('Progress must be a number between 0 and 100');
14
+ }
15
this.attrs.lockedAt = new Date();
16
this.attrs.progress = progress;
17
return this.save();
0 commit comments