Skip to content

Commit febd0b4

Browse files
committed
feat: update campaign status
1 parent 976e83f commit febd0b4

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

apps/api/src/chat/services/broadcast.consumer.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,28 @@ export class BroadcastConsumer {
117117
},
118118
},
119119
)
120-
this.logger.log(`Sent broadcast message from ${user.address} to ${sendTo}`)
120+
this.logger.log(
121+
`Sent broadcast message from ${user.address} to ${sendTo} (${campaign.processed}/${campaign.total})`,
122+
)
121123
} catch {}
122124
campaign.processed++
123125
job.progress(campaign.processed / campaign.total)
126+
127+
// update the campaign status every 100 contacts
128+
if (campaign.processed > 0 && campaign.processed % 100 === 0) {
129+
await this.campaignService.updateOneNative(
130+
{
131+
_id: campaign._id,
132+
},
133+
{
134+
$set: {
135+
delivered: campaign.delivered,
136+
processed: campaign.processed,
137+
total: campaign.total,
138+
},
139+
},
140+
)
141+
}
124142
}
125143

126144
await this.campaignService.updateOneNative(

0 commit comments

Comments
 (0)