Skip to content

Commit

Permalink
feat: progress value to touch functio
Browse files Browse the repository at this point in the history
  • Loading branch information
code-xhyun committed Jul 15, 2024
1 parent 540b8d6 commit 761d584
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/job/touch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { JobError } from 'src/utils';
import { Job } from '.';

export type TouchMethod = (progress?: number) => Promise<Job>;
Expand All @@ -8,6 +9,9 @@ export type TouchMethod = (progress?: number) => Promise<Job>;
* @param progress 0 to 100
*/
export const touch: TouchMethod = async function (this: Job, progress?): Promise<Job> {
if (progress && (progress < 0 || progress > 100)) {
throw new JobError('Progress must be a number between 0 and 100');
}
this.attrs.lockedAt = new Date();
this.attrs.progress = progress;
return this.save();
Expand Down

0 comments on commit 761d584

Please sign in to comment.