Browse Source

Fixed double insertion of results when worker handles campaign (looks like a bug in gorm)

Removed handy abbreviation due to latest commit in gorm (this is why we can't have nice things :smile)
pull/24/head
Jordan 7 years ago
parent
commit
851ba9de30
2 changed files with 3 additions and 2 deletions
  1. +2
    -1
      models/campaign.go
  2. +1
    -1
      models/group.go

+ 2
- 1
models/campaign.go View File

@ -89,7 +89,8 @@ func PostCampaign(c *Campaign, uid int64) error {
}
func UpdateCampaignStatus(c *Campaign, s string) error {
return db.Model(c).UpdateColumn("status", s).Error
// This could be made simpler, but I think there's a bug in gorm
return db.Debug().Table("campaigns").Where("id=?", c.Id).Update("status", s).Error
}
//DeleteCampaign deletes the specified campaign

+ 1
- 1
models/group.go View File

@ -189,6 +189,6 @@ func insertTargetIntoGroup(t Target, gid int64) error {
func GetTargets(gid int64) ([]Target, error) {
ts := []Target{}
err := db.Table("targets t").Select("t.id, t.email").Joins("left join group_targets gt ON t.id = gt.target_id").Where("gt.group_id=?", gid).Scan(&ts).Error
err := db.Table("targets").Select("targets.id, targets.email").Joins("left join group_targets gt ON targets.id = gt.target_id").Where("gt.group_id=?", gid).Scan(&ts).Error
return ts, err
}

Loading…
Cancel
Save