Skip to content

Commit

Permalink
fix campaign even firing for background flows
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Feb 25, 2021
1 parent 48d601e commit e996bd1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions core/models/runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,11 @@ WHERE

// FindActiveSessionOverlap returns the list of contact ids which overlap with those passed in which are active in any other flows
func FindActiveSessionOverlap(ctx context.Context, db *sqlx.DB, flowType FlowType, contacts []ContactID) ([]ContactID, error) {
// background flows should look at messaging flows when determing overlap (background flows can't be active by definition)
if flowType == FlowTypeBackground {
flowType = FlowTypeMessaging
}

var overlap []ContactID
err := db.SelectContext(ctx, &overlap, activeSessionOverlapSQL, flowType, pq.Array(contacts))
return overlap, err
Expand Down
2 changes: 1 addition & 1 deletion core/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestCampaignStarts(t *testing.T) {
db.MustExec(`INSERT INTO campaigns_eventfire(event_id, scheduled, contact_id) VALUES($1, $2, $3),($1, $2, $4),($1, $2, $5);`, models.RemindersEvent2ID, now, models.CathyID, models.BobID, models.AlexandriaID)

// create an active session for Alexandria to test skipping
db.MustExec(`INSERT INTO flows_flowsession(uuid, session_type, org_id, contact_id, status, responded, created_on, current_flow_id) VALUES($1, 'M', $2, $3, 'W', FALSE, NOW(), $4);`, uuids.New(), models.Org1, models.AlexandriaID, models.FavoritesFlowID)
db.MustExec(`INSERT INTO flows_flowsession(uuid, session_type, org_id, contact_id, status, responded, created_on, current_flow_id) VALUES($1, 'M', $2, $3, 'W', FALSE, NOW(), $4);`, uuids.New(), models.Org1, models.AlexandriaID, models.PickNumberFlowID)

// create an active voice call for Cathy to make sure it doesn't get interrupted or cause skipping
db.MustExec(`INSERT INTO flows_flowsession(uuid, session_type, org_id, contact_id, status, responded, created_on, current_flow_id) VALUES($1, 'V', $2, $3, 'W', FALSE, NOW(), $4);`, uuids.New(), models.Org1, models.CathyID, models.IVRFlowID)
Expand Down

0 comments on commit e996bd1

Please sign in to comment.