Open LizziOh opened 5 months ago
I believe its an issue that when 'Survey not done' is TRUE then that method gets recorded as done.
Hi Lizzi, you are almost right: As you said, M2 is correctly recorded as 'survey_not_done' in the survey_method table: | survey_method_id | survey_id | method_id | block_num | survey_not_done |
---|---|---|---|---|---|
12485 | 912351271 | 2 | 1 | true | |
12486 | 912351271 | 1 | 1 | false | |
12487 | 912351271 | 1 | 2 | false | |
12488 | 912351271 | 2 | 2 | true | |
56987 | 912351272 | 2 | 2 | true | |
56988 | 912351272 | 1 | 1 | false | |
56989 | 912351272 | 2 | 1 | true | |
56990 | 912351272 | 1 | 2 | false |
This code snippet of the ep_survey_list endpoint provides the list of methods done in a survey:
SELECT string_agg(DISTINCT sm1.method_id::character varying(3)::text, ', '::text
ORDER BY (sm1.method_id::character varying(3)::text)) AS string_agg
FROM nrmn.survey_method sm1
WHERE sm1.survey_id = sur.survey_id
GROUP BY sm1.survey_id
As you can see, it simply aggregates all the methods listed in the survey_method table above without excluding records where survey_not_done is True. Adding a condition as below will produce the correct output:
SELECT string_agg(DISTINCT sm1.method_id::character varying(3)::text, ', '::text
ORDER BY (sm1.method_id::character varying(3)::text)) AS string_agg
FROM nrmn.survey_method sm1
WHERE sm1.survey_id = sur.survey_id AND sm1.survey_not_done=false
GROUP BY sm1.survey_id
Thanks for looking into this Bene, Yes adding that condition would be good please!
For example survey
912351271 and 912351272 - neither have method 2 observations however have 1,2 in the methods field in the survey_list endpoint.
They display correctly in the UI
@bpasquer @atcooper1