From d12414fb0121e0b076a9b202b50229cc34cdf566 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Thu, 11 Apr 2024 15:16:26 -0500 Subject: [PATCH] Remove flows_flowrun.submitted_by --- archives/archives_test.go | 12 ++++++------ archives/runs.go | 9 +++------ archives/testdata/runs1.jsonl | 4 ++-- archives/testdata/runs2.jsonl | 2 +- testdb.sql | 17 ++++++++--------- 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/archives/archives_test.go b/archives/archives_test.go index f155b1b..d7718a5 100644 --- a/archives/archives_test.go +++ b/archives/archives_test.go @@ -223,8 +223,8 @@ func TestCreateRunArchive(t *testing.T) { // should have two record assert.Equal(t, 2, task.RecordCount) - assert.Equal(t, int64(472), task.Size) - assert.Equal(t, "734d437e1c66d09e033d698c732178f8", task.Hash) + assert.Equal(t, int64(458), task.Size) + assert.Equal(t, "7220a13c19f5b6065e7d4c419c114635", task.Hash) assertArchiveFile(t, task, "runs1.jsonl") DeleteArchiveFile(task) @@ -243,8 +243,8 @@ func TestCreateRunArchive(t *testing.T) { // should have one record assert.Equal(t, 1, task.RecordCount) - assert.Equal(t, int64(490), task.Size) - assert.Equal(t, "c2138e3c3009a9c09fc55482903d93e4", task.Hash) + assert.Equal(t, int64(465), task.Size) + assert.Equal(t, "40abf2113ea7c25c5476ff3025d54b07", task.Hash) assertArchiveFile(t, task, "runs2.jsonl") DeleteArchiveFile(task) @@ -449,10 +449,10 @@ func TestArchiveOrgRuns(t *testing.T) { assert.Equal(t, 10, len(dailiesCreated)) assertArchive(t, dailiesCreated[0], time.Date(2017, 10, 1, 0, 0, 0, 0, time.UTC), DayPeriod, 0, 23, "f0d79988b7772c003d04a28bd7417a62") - assertArchive(t, dailiesCreated[9], time.Date(2017, 10, 10, 0, 0, 0, 0, time.UTC), DayPeriod, 2, 1984, "869cc00ad4cca0371d07c88d8cf2bf26") + assertArchive(t, dailiesCreated[9], time.Date(2017, 10, 10, 0, 0, 0, 0, time.UTC), DayPeriod, 2, 1953, "95475b968ceff15f2f90d539e1bd3d20") assert.Equal(t, 2, len(monthliesCreated)) - assertArchive(t, monthliesCreated[0], time.Date(2017, 8, 1, 0, 0, 0, 0, time.UTC), MonthPeriod, 1, 490, "c2138e3c3009a9c09fc55482903d93e4") + assertArchive(t, monthliesCreated[0], time.Date(2017, 8, 1, 0, 0, 0, 0, time.UTC), MonthPeriod, 1, 465, "40abf2113ea7c25c5476ff3025d54b07") assertArchive(t, monthliesCreated[1], time.Date(2017, 9, 1, 0, 0, 0, 0, time.UTC), MonthPeriod, 0, 23, "f0d79988b7772c003d04a28bd7417a62") assert.Equal(t, 12, len(deleted)) diff --git a/archives/runs.go b/archives/runs.go index 9a35957..46e76fa 100644 --- a/archives/runs.go +++ b/archives/runs.go @@ -48,14 +48,11 @@ FROM ( WHEN status = 'X' THEN 'expired' WHEN status = 'F' THEN 'failed' ELSE NULL - END as exit_type, - a.username as submitted_by + END as exit_type FROM flows_flowrun fr - LEFT JOIN auth_user a ON a.id = fr.submitted_by_id - JOIN LATERAL (SELECT uuid, name FROM flows_flow WHERE flows_flow.id = fr.flow_id) AS flow_struct ON True - JOIN LATERAL (SELECT uuid, name FROM contacts_contact cc WHERE cc.id = fr.contact_id) AS contact_struct ON True - + JOIN LATERAL (SELECT uuid, name FROM flows_flow WHERE flows_flow.id = fr.flow_id) AS flow_struct ON True + JOIN LATERAL (SELECT uuid, name FROM contacts_contact cc WHERE cc.id = fr.contact_id) AS contact_struct ON True WHERE fr.org_id = $1 AND fr.modified_on >= $2 AND fr.modified_on < $3 ORDER BY fr.modified_on ASC, id ASC ) as rec;` diff --git a/archives/testdata/runs1.jsonl b/archives/testdata/runs1.jsonl index 3e7f8ea..51f81dd 100644 --- a/archives/testdata/runs1.jsonl +++ b/archives/testdata/runs1.jsonl @@ -1,2 +1,2 @@ -{"id":1,"uuid":"4ced1260-9cfe-4b7f-81dd-b637108f15b9","flow":{"uuid":"6639286a-9120-45d4-aa39-03ae3942a4a6","name":"Flow 1"},"contact":{"uuid":"3e814add-e614-41f7-8b5d-a07f670a698f","name":"Ajodinabiff Dane"},"responded":true,"path":[],"values":{},"created_on":"2017-08-12T19:11:59.890662+00:00","modified_on":"2017-08-12T19:11:59.890662+00:00","exited_on":"2017-08-12T19:11:59.890662+00:00","exit_type":"completed","submitted_by":null} -{"id":2,"uuid":"7d68469c-0494-498a-bdf3-bac68321fd6d","flow":{"uuid":"6639286a-9120-45d4-aa39-03ae3942a4a6","name":"Flow 1"},"contact":{"uuid":"3e814add-e614-41f7-8b5d-a07f670a698f","name":"Ajodinabiff Dane"},"responded":true,"path":[{"node": "10896d63-8df7-4022-88dd-a9d93edf355b", "time": "2017-08-12T13:07:24.049815+00:00"}],"values":{"agree": {"name": "Do you agree?", "node": "a0434c54-3e26-4eb0-bafc-46cdeaf435ac", "time": "2017-05-03T12:25:21.714339+00:00", "input": "A", "value": "A", "category": "Strongly agree"}},"created_on":"2017-08-12T19:11:59.890662+00:00","modified_on":"2017-08-12T19:11:59.890662+00:00","exited_on":"2017-08-12T19:11:59.890662+00:00","exit_type":"completed","submitted_by":null} +{"id":1,"uuid":"4ced1260-9cfe-4b7f-81dd-b637108f15b9","flow":{"uuid":"6639286a-9120-45d4-aa39-03ae3942a4a6","name":"Flow 1"},"contact":{"uuid":"3e814add-e614-41f7-8b5d-a07f670a698f","name":"Ajodinabiff Dane"},"responded":true,"path":[],"values":{},"created_on":"2017-08-12T19:11:59.890662+00:00","modified_on":"2017-08-12T19:11:59.890662+00:00","exited_on":"2017-08-12T19:11:59.890662+00:00","exit_type":"completed"} +{"id":2,"uuid":"7d68469c-0494-498a-bdf3-bac68321fd6d","flow":{"uuid":"6639286a-9120-45d4-aa39-03ae3942a4a6","name":"Flow 1"},"contact":{"uuid":"3e814add-e614-41f7-8b5d-a07f670a698f","name":"Ajodinabiff Dane"},"responded":true,"path":[{"node": "10896d63-8df7-4022-88dd-a9d93edf355b", "time": "2017-08-12T13:07:24.049815+00:00"}],"values":{"agree": {"name": "Do you agree?", "node": "a0434c54-3e26-4eb0-bafc-46cdeaf435ac", "time": "2017-05-03T12:25:21.714339+00:00", "input": "A", "value": "A", "category": "Strongly agree"}},"created_on":"2017-08-12T19:11:59.890662+00:00","modified_on":"2017-08-12T19:11:59.890662+00:00","exited_on":"2017-08-12T19:11:59.890662+00:00","exit_type":"completed"} diff --git a/archives/testdata/runs2.jsonl b/archives/testdata/runs2.jsonl index 3c82b3c..cfd6714 100644 --- a/archives/testdata/runs2.jsonl +++ b/archives/testdata/runs2.jsonl @@ -1 +1 @@ -{"id":3,"uuid":"de782b35-a398-46ed-8550-34c66053841b","flow":{"uuid":"629db399-a5fb-4fa0-88e6-f479957b63d2","name":"Flow 2"},"contact":{"uuid":"7051dff0-0a27-49d7-af1f-4494239139e6","name":"Joanne Stone"},"responded":true,"path":[{"node": "accbc6e2-b0df-46cd-9a76-bff0fdf4d753", "time": "2017-08-12T13:07:24.049815+00:00"}],"values":{"agree": {"name": "Agree", "node": "084c8cf1-715d-4d0a-b38d-a616ed74e638", "time": "2017-05-03T12:25:21.714339+00:00", "input": "A", "value": "A", "category": "Strongly agree"}, "confirm_agree": {"name": "Do you agree?", "node": "a0434c54-3e26-4eb0-bafc-46cdeaf435ab", "time": "2017-05-03T12:25:21.714339+00:00", "input": "A", "value": "A", "category": "Confirmed Strongly agree"}},"created_on":"2017-08-10T19:11:59.890662+00:00","modified_on":"2017-08-10T19:11:59.890662+00:00","exited_on":"2017-08-10T19:11:59.890662+00:00","exit_type":"completed","submitted_by":"greg@gmail.com"} +{"id":3,"uuid":"de782b35-a398-46ed-8550-34c66053841b","flow":{"uuid":"629db399-a5fb-4fa0-88e6-f479957b63d2","name":"Flow 2"},"contact":{"uuid":"7051dff0-0a27-49d7-af1f-4494239139e6","name":"Joanne Stone"},"responded":true,"path":[{"node": "accbc6e2-b0df-46cd-9a76-bff0fdf4d753", "time": "2017-08-12T13:07:24.049815+00:00"}],"values":{"agree": {"name": "Agree", "node": "084c8cf1-715d-4d0a-b38d-a616ed74e638", "time": "2017-05-03T12:25:21.714339+00:00", "input": "A", "value": "A", "category": "Strongly agree"}, "confirm_agree": {"name": "Do you agree?", "node": "a0434c54-3e26-4eb0-bafc-46cdeaf435ab", "time": "2017-05-03T12:25:21.714339+00:00", "input": "A", "value": "A", "category": "Confirmed Strongly agree"}},"created_on":"2017-08-10T19:11:59.890662+00:00","modified_on":"2017-08-10T19:11:59.890662+00:00","exited_on":"2017-08-10T19:11:59.890662+00:00","exit_type":"completed"} diff --git a/testdb.sql b/testdb.sql index d823ba6..a0513ca 100644 --- a/testdb.sql +++ b/testdb.sql @@ -212,7 +212,6 @@ CREATE TABLE flows_flowrun ( created_on timestamp with time zone NOT NULL, modified_on timestamp with time zone NOT NULL, exited_on timestamp with time zone NULL, - submitted_by_id integer NULL REFERENCES auth_user(id), status varchar(1) NOT NULL, delete_from_results boolean ); @@ -336,23 +335,23 @@ INSERT INTO flows_flowstart_groups(flowstart_id, contactgroup_id) VALUES INSERT INTO flows_flowstart_calls(flowstart_id, call_id) VALUES (1, 1); -INSERT INTO flows_flowrun(id, uuid, org_id, responded, contact_id, flow_id, results, path, created_on, modified_on, exited_on, status, submitted_by_id, start_id) VALUES -(1, '4ced1260-9cfe-4b7f-81dd-b637108f15b9', 2, TRUE, 6, 1, '{}', '[]', '2017-08-12 21:11:59.890662+02:00','2017-08-12 21:11:59.890662+02:00','2017-08-12 21:11:59.890662+02:00', 'C', NULL, 1), +INSERT INTO flows_flowrun(id, uuid, org_id, responded, contact_id, flow_id, results, path, created_on, modified_on, exited_on, status, start_id) VALUES +(1, '4ced1260-9cfe-4b7f-81dd-b637108f15b9', 2, TRUE, 6, 1, '{}', '[]', '2017-08-12 21:11:59.890662+02:00','2017-08-12 21:11:59.890662+02:00','2017-08-12 21:11:59.890662+02:00', 'C', 1), (2, '7d68469c-0494-498a-bdf3-bac68321fd6d', 2, TRUE, 6, 1, '{"agree": {"category": "Strongly agree", "node_uuid": "a0434c54-3e26-4eb0-bafc-46cdeaf435ac", "name": "Do you agree?", "value": "A", "created_on": "2017-05-03T12:25:21.714339+00:00", "input": "A"}}', '[{"uuid": "c3d0b417-db75-417c-8050-33776ec8f620", "node_uuid": "10896d63-8df7-4022-88dd-a9d93edf355b", "arrived_on": "2017-08-12T15:07:24.049815+02:00", "exit_uuid": "2f890507-2ad2-4bd1-92fc-0ca031155fca"}]', -'2017-08-12 21:11:59.890662+02:00','2017-08-12 21:11:59.890662+02:00','2017-08-12 21:11:59.890662+02:00', 'C', NULL, NULL), +'2017-08-12 21:11:59.890662+02:00','2017-08-12 21:11:59.890662+02:00','2017-08-12 21:11:59.890662+02:00', 'C', NULL), (3, 'de782b35-a398-46ed-8550-34c66053841b', 3, TRUE, 7, 2, '{"agree": {"category": "Strongly agree", "node_uuid": "084c8cf1-715d-4d0a-b38d-a616ed74e638", "name": "Agree", "value": "A", "created_on": "2017-05-03T12:25:21.714339+00:00", "input": "A"}, "confirm_agree": {"category": "Confirmed Strongly agree", "node_uuid": "a0434c54-3e26-4eb0-bafc-46cdeaf435ab", "name": "Do you agree?", "value": "A", "created_on": "2017-05-03T12:25:21.714339+00:00", "input": "A"}}', '[{"uuid": "600ac5b4-4895-4161-ad97-6e2f1bb48bcb", "node_uuid": "accbc6e2-b0df-46cd-9a76-bff0fdf4d753", "arrived_on": "2017-08-12T15:07:24.049815+02:00", "exit_uuid": "8249e2dc-c893-4200-b6d2-398d07a459bc"}]', -'2017-08-10 21:11:59.890662+02:00','2017-08-10 21:11:59.890662+02:00','2017-08-10 21:11:59.890662+02:00', 'C', 1, NULL), +'2017-08-10 21:11:59.890662+02:00','2017-08-10 21:11:59.890662+02:00','2017-08-10 21:11:59.890662+02:00', 'C', NULL), (4, '329a5d24-64fc-479c-8d24-9674c9b46530', 3, TRUE, 7, 2, '{"agree": {"category": "Disagree", "node_uuid": "084c8cf1-715d-4d0a-b38d-a616ed74e638", "name": "Agree", "value": "B", "created_on": "2017-10-10T12:25:21.714339+00:00", "input": "B"}}', '[{"uuid": "babf4fc8-e12c-4bb9-a9dd-61178a118b5a", "node_uuid": "accbc6e2-b0df-46cd-9a76-bff0fdf4d753", "arrived_on": "2017-10-12T15:07:24.049815+02:00", "exit_uuid": "8249e2dc-c893-4200-b6d2-398d07a459bc"}]', -'2017-10-10 21:11:59.890662+02:00','2017-10-10 21:11:59.890662+02:00','2017-10-10 21:11:59.890662+02:00', 'C', NULL, NULL), -(5, 'abed67d2-06b8-4749-8bb9-ecda037b673b', 3, TRUE, 7, 2, '{}', '[]', '2017-10-10 21:11:59.890663+02:00','2017-10-10 21:11:59.890662+02:00','2017-10-10 21:11:59.890662+02:00', 'C', NULL, NULL), -(6, '6262eefe-a6e9-4201-9b76-a7f25e3b7f29', 3, TRUE, 7, 2, '{}', '[]', '2017-12-12 21:11:59.890662+02:00','2017-12-12 21:11:59.890662+02:00','2017-12-12 21:11:59.890662+02:00', 'C', NULL, NULL), -(7, '6c0d7db9-076b-4edc-ab4b-38576ae394fc', 2, TRUE, 7, 2, '{}', '[]', '2017-08-13 13:11:59.890662+02:00','2017-08-14 16:11:59.890662+02:00', NULL, 'W', NULL, NULL); +'2017-10-10 21:11:59.890662+02:00','2017-10-10 21:11:59.890662+02:00','2017-10-10 21:11:59.890662+02:00', 'C', NULL), +(5, 'abed67d2-06b8-4749-8bb9-ecda037b673b', 3, TRUE, 7, 2, '{}', '[]', '2017-10-10 21:11:59.890663+02:00','2017-10-10 21:11:59.890662+02:00','2017-10-10 21:11:59.890662+02:00', 'C', NULL), +(6, '6262eefe-a6e9-4201-9b76-a7f25e3b7f29', 3, TRUE, 7, 2, '{}', '[]', '2017-12-12 21:11:59.890662+02:00','2017-12-12 21:11:59.890662+02:00','2017-12-12 21:11:59.890662+02:00', 'C', NULL), +(7, '6c0d7db9-076b-4edc-ab4b-38576ae394fc', 2, TRUE, 7, 2, '{}', '[]', '2017-08-13 13:11:59.890662+02:00','2017-08-14 16:11:59.890662+02:00', NULL, 'W', NULL); -- update run #5 to have a path longer than 500 steps UPDATE flows_flowrun SET path = s.path FROM (