Skip to content

Commit

Permalink
Set FlowStart.UUID in only place we need to
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Feb 7, 2023
1 parent ef6edb7 commit 826b627
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
7 changes: 0 additions & 7 deletions core/models/starts.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,6 @@ type startGroup struct {

// InsertFlowStarts inserts all the passed in starts
func InsertFlowStarts(ctx context.Context, db Queryer, starts []*FlowStart) error {
// TODO figure out if this is needed
for _, s := range starts {
if s.UUID == "" {
s.UUID = uuids.New()
}
}

// insert our starts
err := BulkQuery(ctx, "inserting flow start", db, sqlInsertStart, starts)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions core/tasks/campaigns/cron_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestQueueEventFires(t *testing.T) {
err = campaigns.QueueEventFires(ctx, rt)
assert.NoError(t, err)

queuedTasks := testsuite.CurrentOrgTasks(t, rp)
queuedTasks := testsuite.CurrentTasks(t, rp)
org1Tasks := queuedTasks[testdata.Org1.ID]

assert.Equal(t, 2, len(org1Tasks))
Expand Down Expand Up @@ -202,7 +202,7 @@ func TestIVRCampaigns(t *testing.T) {
}

func assertFireTasks(t *testing.T, rp *redis.Pool, org *testdata.Org, expected [][]models.FireID) {
allTasks := testsuite.CurrentOrgTasks(t, rp)
allTasks := testsuite.CurrentTasks(t, rp)
actual := make([][]models.FireID, len(allTasks[org.ID]))

for i, task := range allTasks[org.ID] {
Expand Down
2 changes: 2 additions & 0 deletions core/tasks/schedules/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"time"

"github.com/nyaruka/gocommon/uuids"
"github.com/nyaruka/mailroom"
"github.com/nyaruka/mailroom/core/models"
"github.com/nyaruka/mailroom/core/queue"
Expand Down Expand Up @@ -85,6 +86,7 @@ func checkSchedules(ctx context.Context, rt *runtime.Runtime) error {

} else if s.FlowStart() != nil {
start := s.FlowStart()
start.UUID = uuids.New()

// insert our flow start
err := models.InsertFlowStarts(ctx, tx, []*models.FlowStart{start})
Expand Down

0 comments on commit 826b627

Please sign in to comment.