mirror of
https://fast.feibisi.com/https://github.com/parcelvoy/platform.git
synced 2025-09-01 12:26:08 +08:00
chore: prevent scheduled job duplicates
This commit is contained in:
parent
858c3a894a
commit
1c7a2f0166
4 changed files with 10 additions and 2 deletions
|
@ -6,6 +6,10 @@ import CampaignEnqueueSendsJob from './CampaignEnqueueSendsJob'
|
|||
export default class ProcessCampaignsJob extends Job {
|
||||
static $name = 'process_campaigns_job'
|
||||
|
||||
static from(): ProcessCampaignsJob {
|
||||
return new this().deduplicationKey(this.$name)
|
||||
}
|
||||
|
||||
static async handler() {
|
||||
|
||||
const campaigns = await Campaign.query()
|
||||
|
|
|
@ -14,7 +14,7 @@ export default class ListStatsJob extends Job {
|
|||
listId: number,
|
||||
projectId: number,
|
||||
): ListStatsJob {
|
||||
return new this({ listId, projectId })
|
||||
return new this({ listId, projectId }).deduplicationKey(`${this.name}_${listId}`)
|
||||
}
|
||||
|
||||
static async handler({ listId, projectId }: ListStatsParams) {
|
||||
|
|
|
@ -5,6 +5,10 @@ import ListStatsJob from './ListStatsJob'
|
|||
export default class ProcessListsJob extends Job {
|
||||
static $name = 'process_lists_job'
|
||||
|
||||
static from(): ProcessListsJob {
|
||||
return new this().deduplicationKey(this.$name)
|
||||
}
|
||||
|
||||
static async handler() {
|
||||
|
||||
const lists = await List.all(qb => qb.whereNot('state', 'loading').whereNull('deleted_at'))
|
||||
|
|
|
@ -66,7 +66,7 @@ export default class Job implements EncodedJob {
|
|||
return this.$static.handler(this.data, this)
|
||||
}
|
||||
|
||||
constructor(data: any) {
|
||||
constructor(data: any = {}) {
|
||||
this.data = data
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue