New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TTAHUB-925]remove-erroneous-records #972
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks right to me, though I'm wondering if we might want to leave the erroneous records as full permanent tables for now just in case we make a mistake here and want to restore certain records. We can drop the tables later.
AND args."grantId" = r."grantId" | ||
WHERE r.id is null; | ||
------------------------------------------------------------------------------------ | ||
CREATE TEMP TABLE "erroneousObjectives" AS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more standard and scalable way to do something like this is:
CREATE TEMP TABLE err_obj AS
WITH correct_aros AS (
SELECT DISTINCT
o.id "objectiveId",
aro.id "aroId"
FROM "Objectives" o
JOIN "ActivityReportObjectives" aro
ON o.id = aro."objectiveId"
EXCEPT
SELECT DISTINCT
"objectiveId",
"aroId"
FROM "erroneousAROs"
),
correct_objectives AS (SELECT DISTINCT "objectiveId" FROM correct_aros)
SELECT
o.id "objectiveId",
o."goalId"
FROM "Objectives" o
LEFT JOIN correct_aros c
ON c."objectiveId" = o.id
WHERE c."objectiveId" IS NULL
added dedupe of objectives on csv file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great! Should we add a test case for the objectives roll up?
I already modified the current tests to include a roll up objective. |
+1 |
Description of change
A bas assumption was made during the migration that caused addition erroneous records to be created. This will remove these records.
How to test
Issue(s)
Checklists
Every PR
Production Deploy
After merge/deploy