From bf55c03fc9d16acf872db31ed395f0250790b360 Mon Sep 17 00:00:00 2001 From: Jordan Wright Date: Wed, 17 Feb 2016 21:25:06 -0600 Subject: [PATCH] Adding position attribute for models.Result. Fixes #163. --- .../20160217211342_0.1.2_create_from_col_results.sql | 8 ++++++++ models/campaign.go | 2 +- models/result.go | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 db/migrations/20160217211342_0.1.2_create_from_col_results.sql diff --git a/db/migrations/20160217211342_0.1.2_create_from_col_results.sql b/db/migrations/20160217211342_0.1.2_create_from_col_results.sql new file mode 100644 index 00000000..42f828fe --- /dev/null +++ b/db/migrations/20160217211342_0.1.2_create_from_col_results.sql @@ -0,0 +1,8 @@ + +-- +goose Up +-- SQL in section 'Up' is executed when this migration is applied +ALTER TABLE results ADD COLUMN position VARCHAR(255); + +-- +goose Down +-- SQL section 'Down' is executed when this migration is rolled back + diff --git a/models/campaign.go b/models/campaign.go index 69726650..bd39074e 100644 --- a/models/campaign.go +++ b/models/campaign.go @@ -228,7 +228,7 @@ func PostCampaign(c *Campaign, uid int64) error { for _, g := range c.Groups { // Insert a result for each target in the group for _, t := range g.Targets { - r := &Result{Email: t.Email, Status: STATUS_SENDING, CampaignId: c.Id, UserId: c.UserId, FirstName: t.FirstName, LastName: t.LastName} + r := &Result{Email: t.Email, Position: t.Position, Status: STATUS_SENDING, CampaignId: c.Id, UserId: c.UserId, FirstName: t.FirstName, LastName: t.LastName} r.GenerateId() err = db.Save(r).Error if err != nil { diff --git a/models/result.go b/models/result.go index c7ab8575..ef804adb 100644 --- a/models/result.go +++ b/models/result.go @@ -30,6 +30,7 @@ type Result struct { Email string `json:"email"` FirstName string `json:"first_name"` LastName string `json:"last_name"` + Position string `json:"position"` Status string `json:"status" sql:"not null"` IP string `json:"ip"` Latitude float64 `json:"latitude"`