Skip to content

Commit

Permalink
Merge pull request nyaruka#49 from nyaruka/lang_fix
Browse files Browse the repository at this point in the history
Fix org loading to not include org languages
  • Loading branch information
rowanseymour authored Jun 23, 2021
2 parents 94897dc + 87f5f8c commit 91f56c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
4 changes: 1 addition & 3 deletions archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ type Org struct {
Name string `db:"name"`
CreatedOn time.Time `db:"created_on"`
IsAnon bool `db:"is_anon"`
Language *string `db:"language"`
RetentionPeriod int
}

Expand Down Expand Up @@ -98,9 +97,8 @@ func (a *Archive) coversDate(d time.Time) bool {
}

const lookupActiveOrgs = `
SELECT o.id, o.name, l.iso_code as language, o.created_on, o.is_anon
SELECT o.id, o.name, o.created_on, o.is_anon
FROM orgs_org o
LEFT JOIN orgs_language l ON l.id = primary_language_id
WHERE o.is_active = TRUE order by o.id
`

Expand Down
20 changes: 5 additions & 15 deletions testdb.sql
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
CREATE EXTENSION IF NOT EXISTS HSTORE;

DROP TABLE IF EXISTS orgs_language CASCADE;
CREATE TABLE orgs_language (
id serial primary key,
iso_code character varying(3)
);

DROP TABLE IF EXISTS orgs_org CASCADE;
CREATE TABLE orgs_org (
id serial primary key,
name character varying(255) NOT NULL,
primary_language_id integer references orgs_language(id) on delete cascade,
is_anon boolean NOT NULL,
is_active boolean NOT NULL,
created_on timestamp with time zone NOT NULL
Expand Down Expand Up @@ -219,14 +212,11 @@ CREATE TABLE flows_flowpathrecentrun (
run_id integer NOT NULL references flows_flowrun(id) DEFERRABLE INITIALLY DEFERRED
);

INSERT INTO orgs_language(id, iso_code) VALUES
(1, 'eng');

INSERT INTO orgs_org(id, name, is_active, is_anon, created_on, primary_language_id) VALUES
(1, 'Org 1', TRUE, FALSE, '2017-11-10 21:11:59.890662+00', 1),
(2, 'Org 2', TRUE, FALSE, '2017-08-10 21:11:59.890662+00', 1),
(3, 'Org 3', TRUE, TRUE, '2017-08-10 21:11:59.890662+00', NULL),
(4, 'Org 4', FALSE, TRUE, '2017-08-10 21:11:59.890662+00', 1);
INSERT INTO orgs_org(id, name, is_active, is_anon, created_on) VALUES
(1, 'Org 1', TRUE, FALSE, '2017-11-10 21:11:59.890662+00'),
(2, 'Org 2', TRUE, FALSE, '2017-08-10 21:11:59.890662+00'),
(3, 'Org 3', TRUE, TRUE, '2017-08-10 21:11:59.890662+00'),
(4, 'Org 4', FALSE, TRUE, '2017-08-10 21:11:59.890662+00');

INSERT INTO channels_channel(id, uuid, name, org_id) VALUES
(1, '8c1223c3-bd43-466b-81f1-e7266a9f4465', 'Channel 1', 1),
Expand Down

0 comments on commit 91f56c6

Please sign in to comment.