Fix new records being added on completing a campaign (#2599)

There were new records with name '[Deleted]' being added when a campaign was
completed. This used to happen when the resource associated with a campaign
(template, page, profile) was deleted before marking the campaign as
completed. The save gorm call used to upsert these values and ended up adding
rogue records.
pull/2631/head
Vivek Kekuda 2022-10-13 20:46:37 +05:30 committed by GitHub
parent 095a9ba20c
commit cec2da5128
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -661,7 +661,8 @@ func CompleteCampaign(id int64, uid int64) error {
// Mark the campaign as complete // Mark the campaign as complete
c.CompletedDate = time.Now().UTC() c.CompletedDate = time.Now().UTC()
c.Status = CampaignComplete c.Status = CampaignComplete
err = db.Where("id=? and user_id=?", id, uid).Save(&c).Error err = db.Model(&Campaign{}).Where("id=? and user_id=?", id, uid).
Select([]string{"completed_date", "status"}).UpdateColumns(&c).Error
if err != nil { if err != nil {
log.Error(err) log.Error(err)
} }