mirror of
https://fast.feibisi.com/https://github.com/parcelvoy/platform.git
synced 2025-09-01 12:26:08 +08:00
chore: reduce state job processing
This commit is contained in:
parent
04a9f3f229
commit
2701aef923
1 changed files with 8 additions and 1 deletions
|
@ -7,6 +7,10 @@ import App from '../app'
|
|||
export default class CampaignStateJob extends Job {
|
||||
static $name = 'campaign_state_job'
|
||||
|
||||
static from(): CampaignStateJob {
|
||||
return new this().deduplicationKey(this.$name)
|
||||
}
|
||||
|
||||
static async handler() {
|
||||
|
||||
// Fetch anything that is currently running, has finished
|
||||
|
@ -18,7 +22,10 @@ export default class CampaignStateJob extends Job {
|
|||
qb.where('state', 'finished')
|
||||
.where('send_at', '>', subDays(Date.now(), 2))
|
||||
})
|
||||
.orWhereIn('id', openedCampaignIds),
|
||||
.orWhere(function(qb) {
|
||||
qb.whereIn('id', openedCampaignIds)
|
||||
.whereNotIn('state', ['draft', 'aborted'])
|
||||
}),
|
||||
)
|
||||
|
||||
for (const campaign of campaigns) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue