Skip to content

Commit

Permalink
Merge pull request #106 from nyaruka/latest_goflow
Browse files Browse the repository at this point in the history
Update to latest goflow that replaces input_cleaners with input_collation
  • Loading branch information
rowanseymour authored Aug 21, 2023
2 parents 9ed5ec8 + c989f30 commit 15edf4c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion core/models/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func NewOrgAssets(ctx context.Context, rt *runtime.Runtime, orgID OrgID, prev *O
}

if prev == nil || refresh&RefreshLocations > 0 {
oa.locations, err = loadLocations(ctx, db, orgID)
oa.locations, err = loadLocations(ctx, db, oa)
oa.locationsBuiltAt = time.Now()
if err != nil {
return nil, errors.Wrapf(err, "error loading group locations for org %d", orgID)
Expand Down
10 changes: 5 additions & 5 deletions core/models/locations.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ func (l *Location) Aliases() []string { return l.Aliases_ }
func (l *Location) Children() []*Location { return l.Children_ }

// loadLocations loads all the locations for this org returning the root node
func loadLocations(ctx context.Context, db sqlx.Queryer, orgID OrgID) ([]assets.LocationHierarchy, error) {
func loadLocations(ctx context.Context, db sqlx.Queryer, oa *OrgAssets) ([]assets.LocationHierarchy, error) {
start := time.Now()

rows, err := db.Query(loadLocationsSQL, orgID)
rows, err := db.Query(loadLocationsSQL, oa.orgID)
if err != nil {
return nil, errors.Wrapf(err, "error querying locations for org: %d", orgID)
return nil, errors.Wrapf(err, "error querying locations for org: %d", oa.orgID)
}
defer rows.Close()

Expand Down Expand Up @@ -103,12 +103,12 @@ func loadLocations(ctx context.Context, db sqlx.Queryer, orgID OrgID) ([]assets.
}

// then read it in
hierarchy, err := envs.ReadLocationHierarchy(locationJSON)
hierarchy, err := envs.ReadLocationHierarchy(oa.Env(), locationJSON)
if err != nil {
return nil, errors.Wrapf(err, "error unmarshalling hierarchy: %s", string(locationJSON))
}

logrus.WithField("elapsed", time.Since(start)).WithField("org_id", orgID).Debug("loaded locations")
logrus.WithField("elapsed", time.Since(start)).WithField("org_id", oa.orgID).Debug("loaded locations")

return []assets.LocationHierarchy{hierarchy}, nil
}
Expand Down
4 changes: 2 additions & 2 deletions core/models/locations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestLocations(t *testing.T) {
root, err := oa.Locations()
require.NoError(t, err)

locations := root[0].FindByName("Nigeria", 0, nil)
locations := root[0].FindByName(oa.Env(), "Nigeria", 0, nil)

assert.Equal(t, 1, len(locations))
assert.Equal(t, "Nigeria", locations[0].Name())
Expand All @@ -47,7 +47,7 @@ func TestLocations(t *testing.T) {
}

for _, tc := range tcs {
locations = root[0].FindByName(tc.Name, tc.Level, nigeria)
locations = root[0].FindByName(oa.Env(), tc.Name, tc.Level, nigeria)
assert.Equal(t, 1, len(locations))
state := locations[0]

Expand Down
2 changes: 1 addition & 1 deletion core/models/orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ SELECT ROW_TO_JSON(o) FROM (SELECT
timezone,
(SELECT CASE is_anon WHEN TRUE THEN 'urns' WHEN FALSE THEN 'none' END) AS redaction_policy,
flow_languages AS allowed_languages,
input_cleaners,
'default' AS input_collation,
COALESCE(
(
SELECT country FROM channels_channel c
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/lib/pq v1.10.9
github.com/nyaruka/ezconf v0.2.1
github.com/nyaruka/gocommon v1.38.2
github.com/nyaruka/goflow v0.191.0
github.com/nyaruka/goflow v0.192.0
github.com/nyaruka/logrus_sentry v0.8.2-0.20190129182604-c2962b80ba7d
github.com/nyaruka/null/v2 v2.0.3
github.com/nyaruka/redisx v0.3.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ github.com/nyaruka/ezconf v0.2.1 h1:TDXWoqjqYya1uhou1mAJZg7rgFYL98EB0Tb3+BWtUh0=
github.com/nyaruka/ezconf v0.2.1/go.mod h1:ey182kYkw2MIi4XiWe1FR/mzI33WCmTWuceDYYxgnQw=
github.com/nyaruka/gocommon v1.38.2 h1:67GwC2XRIaPZV5uSif0PkQ6XI327dL18v/GaZYu7SG0=
github.com/nyaruka/gocommon v1.38.2/go.mod h1:wdDXnl5UrjFHOmsxJNID4h4U92u4hFto8xsXFBRfzdA=
github.com/nyaruka/goflow v0.191.0 h1:IWZtsq9T0XTcl5Gk3/1pMKpdH5r/glJjzAHGcVn2z00=
github.com/nyaruka/goflow v0.191.0/go.mod h1:tpi8zlxpBK/CpAmJc7an8NoajoKAMowoLHNJBXDbhx8=
github.com/nyaruka/goflow v0.192.0 h1:1JPGtvTeK4Bj4ot9A9VnCne5o5CJI6mhBrg5Sd9iyP4=
github.com/nyaruka/goflow v0.192.0/go.mod h1:tpi8zlxpBK/CpAmJc7an8NoajoKAMowoLHNJBXDbhx8=
github.com/nyaruka/librato v1.0.0 h1:Vznj9WCeC1yZXbBYyYp40KnbmXLbEkjKmHesV/v2SR0=
github.com/nyaruka/librato v1.0.0/go.mod h1:pkRNLFhFurOz0QqBz6/DuTFhHHxAubWxs4Jx+J7yUgg=
github.com/nyaruka/logrus_sentry v0.8.2-0.20190129182604-c2962b80ba7d h1:hyp9u36KIwbTCo2JAJ+TuJcJBc+UZzEig7RI/S5Dvkc=
Expand Down

0 comments on commit 15edf4c

Please sign in to comment.