Skip to content

Commit

Permalink
remove references to unused fields
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Jun 13, 2019
1 parent 7233eba commit 5e6fc16
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 28 deletions.
2 changes: 0 additions & 2 deletions campaigns/campaigns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func TestCampaigns(t *testing.T) {
// let's create a campaign event fire for one of our contacts (for now this is totally hacked, they aren't in the group and
// their relative to date isn't relative, but this still tests execution)
db := testsuite.DB()
db.MustExec(`UPDATE flows_flow SET flow_server_enabled=TRUE WHERE id = $1;`, models.FavoritesFlowID)
db.MustExec(`INSERT INTO campaigns_eventfire(scheduled, contact_id, event_id) VALUES (NOW(), $1, $3), (NOW(), $2, $3);`, models.CathyID, models.GeorgeID, models.RemindersEvent1ID)
time.Sleep(10 * time.Millisecond)

Expand Down Expand Up @@ -53,7 +52,6 @@ func TestIVRCampaigns(t *testing.T) {
// let's create a campaign event fire for one of our contacts (for now this is totally hacked, they aren't in the group and
// their relative to date isn't relative, but this still tests execution)
db := testsuite.DB()
db.MustExec(`UPDATE flows_flow SET flow_server_enabled=TRUE WHERE id = $1;`, models.IVRFlowID)
db.MustExec(`UPDATE campaigns_campaignevent SET flow_id = $1 WHERE id = $2`, models.IVRFlowID, models.RemindersEvent1ID)
db.MustExec(`INSERT INTO campaigns_eventfire(scheduled, contact_id, event_id) VALUES (NOW(), $1, $3), (NOW(), $2, $3);`, models.CathyID, models.GeorgeID, models.RemindersEvent1ID)
time.Sleep(10 * time.Millisecond)
Expand Down
2 changes: 1 addition & 1 deletion campaigns/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ WHERE
ef.fired IS NULL AND ef.scheduled <= NOW() AND
ce.id = ef.event_id AND
ce.is_active = TRUE AND
f.id = ce.flow_id AND f.flow_server_enabled = TRUE AND
f.id = ce.flow_id AND
ce.campaign_id = c.id
ORDER BY
DATE_TRUNC('minute', scheduled) ASC,
Expand Down
3 changes: 1 addition & 2 deletions expirations/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ const selectExpiredRunsSQL = `
fr.is_active = TRUE AND
fr.expires_on < NOW() AND
fr.connection_id IS NULL AND
fr.session_id IS NOT NULL AND
o.flow_server_enabled = TRUE
fr.session_id IS NOT NULL
ORDER BY
expires_on ASC
LIMIT 25000
Expand Down
1 change: 0 additions & 1 deletion expirations/cron_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func TestExpirations(t *testing.T) {

// need to create a session that has an expired timeout
db := testsuite.DB()
db.MustExec(`UPDATE orgs_org SET flow_server_enabled=TRUE WHERE id = 1;`)

// create a few sessions
var s1, s2 models.SessionID
Expand Down
Binary file modified mailroom_test.dump
Binary file not shown.
4 changes: 2 additions & 2 deletions models/contacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,9 @@ func CreateContact(ctx context.Context, db *sqlx.DB, org *OrgAssets, assets flow
err = tx.GetContext(ctx, &contactID,
`INSERT INTO
contacts_contact
(org_id, is_active, is_blocked, is_test, is_stopped, uuid, created_on, modified_on, created_by_id, modified_by_id, name)
(org_id, is_active, is_blocked, is_stopped, uuid, created_on, modified_on, created_by_id, modified_by_id, name)
VALUES
($1, TRUE, FALSE, FALSE, FALSE, $2, NOW(), NOW(), 1, 1, '')
($1, TRUE, FALSE, FALSE, $2, NOW(), NOW(), 1, 1, '')
RETURNING id`,
org.OrgID(), utils.NewUUID(),
)
Expand Down
18 changes: 2 additions & 16 deletions models/webhook_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,10 @@ import (

type WebhookEventID int64

type EventType string

type EventStatus string

const (
EventTypeFlow = EventType("flow")

EventStatusComplete = EventStatus("C")
)

// WebhookEvent represents an event that was created, mostly used for resthooks
type WebhookEvent struct {
e struct {
ID WebhookEventID `db:"id"`
EventType EventType `db:"event"`
Status EventStatus `db:"status"`
Data string `db:"data"`
ResthookID ResthookID `db:"resthook_id"`
OrgID OrgID `db:"org_id"`
Expand All @@ -37,8 +25,6 @@ func NewWebhookEvent(orgID OrgID, resthookID ResthookID, data string, createdOn
event := &WebhookEvent{}
e := &event.e

e.EventType = EventTypeFlow
e.Status = EventStatusComplete
e.Data = data
e.OrgID = orgID
e.ResthookID = resthookID
Expand All @@ -48,8 +34,8 @@ func NewWebhookEvent(orgID OrgID, resthookID ResthookID, data string, createdOn
}

const insertWebhookEventsSQL = `
INSERT INTO api_webhookevent( event, status, data, resthook_id, org_id, created_on, try_count, action)
VALUES(:event, :status, :data, :resthook_id, :org_id, :created_on, 1, 'POST')
INSERT INTO api_webhookevent(data, resthook_id, org_id, created_on, action)
VALUES(:data, :resthook_id, :org_id, :created_on, 'POST')
RETURNING id
`

Expand Down
3 changes: 1 addition & 2 deletions models/webhook_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ func TestWebhookEvents(t *testing.T) {
assert.NotZero(t, e.ID())

testsuite.AssertQueryCount(t, db, `
SELECT count(*) FROM api_webhookevent WHERE org_id = $1 AND resthook_id = $2 AND data = $3 AND status = 'C' AND
event = 'flow'
SELECT count(*) FROM api_webhookevent WHERE org_id = $1 AND resthook_id = $2 AND data = $3
`, []interface{}{tc.OrgID, tc.ResthookID, tc.Data}, 1)
}
}
1 change: 0 additions & 1 deletion timeouts/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ const timedoutSessionsSQL = `
WHERE
status = 'W' AND
timeout_on < NOW() AND
o.flow_server_enabled = TRUE AND
connection_id IS NULL
ORDER BY
timeout_on ASC
Expand Down
1 change: 0 additions & 1 deletion timeouts/cron_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func TestTimeouts(t *testing.T) {

// need to create a session that has an expired timeout
db := testsuite.DB()
db.MustExec(`UPDATE orgs_org SET flow_server_enabled=TRUE WHERE id = 1;`)
db.MustExec(`INSERT INTO flows_flowsession(org_id, status, responded, contact_id, created_on, timeout_on) VALUES (1, 'W', TRUE, $1, NOW(), NOW());`, models.CathyID)
db.MustExec(`INSERT INTO flows_flowsession(org_id, status, responded, contact_id, created_on, timeout_on) VALUES (1, 'W', TRUE, $1, NOW(), NOW()+ interval '1' day);`, models.GeorgeID)
time.Sleep(10 * time.Millisecond)
Expand Down

0 comments on commit 5e6fc16

Please sign in to comment.