Skip to content
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

feedback for ticket 1289 #464

Merged
merged 9 commits into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function getOccurenceSubmission(): RequestHandler {
!occurrenceSubmissionData ||
!occurrenceSubmissionData.rows ||
!occurrenceSubmissionData.rows[0] ||
occurrenceSubmissionData.rows[0].soft_delete_timestamp
occurrenceSubmissionData.rows[0].delete_timestamp
) {
return res.status(200).json(null);
}
Expand Down
4 changes: 2 additions & 2 deletions api/src/queries/survey/survey-occurrence-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const getLatestSurveyOccurrenceSubmissionSQL = (surveyId: number): SQLSta
os.occurrence_submission_id as id,
os.survey_id,
os.source,
os.soft_delete_timestamp,
os.delete_timestamp,
os.event_timestamp,
os.key,
os.file_name,
Expand Down Expand Up @@ -246,7 +246,7 @@ export const deleteOccurrenceSubmissionSQL = (occurrenceSubmissionId: number): S

const sqlStatement: SQLStatement = SQL`
UPDATE occurrence_submission
SET soft_delete_timestamp = now()
SET delete_timestamp = now()
WHERE occurrence_submission_id = ${occurrenceSubmissionId};
`;

Expand Down
7 changes: 2 additions & 5 deletions app/src/features/surveys/view/SurveyObservations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,8 @@ const SurveyObservations = () => {
const [isLoading, setIsLoading] = useState(true);
const [isValidating, setIsValidating] = useState(false);
const [isPolling, setIsPolling] = useState(false);

const [pollingFunction, setPollingFunction] = useState<Function>();
const [pollingTime, setPollingTime] = useState<number | null>(0);

useInterval(pollingFunction, pollingTime);

const dialogContext = useContext(DialogContext);

const fetchObservationSubmission = useCallback(async () => {
Expand Down Expand Up @@ -107,14 +103,15 @@ const SurveyObservations = () => {
});
}, [biohubApi.observation, projectId, surveyId]);

useInterval(fetchObservationSubmission, pollingTime);

useEffect(() => {
if (isLoading) {
fetchObservationSubmission();
}

if (isPolling && !pollingTime) {
setPollingTime(2000);
setPollingFunction(() => fetchObservationSubmission);
}
}, [
biohubApi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function up(knex: Knex): Promise<void> {
set schema '${DB_SCHEMA}';
set search_path = ${DB_SCHEMA},public;

ALTER TABLE ${DB_SCHEMA}.occurrence_submission add column soft_delete_timestamp timestamptz(6);
ALTER TABLE ${DB_SCHEMA}.occurrence_submission add column delete_timestamp timestamptz(6);

set search_path = biohub_dapi_v1;

Expand All @@ -30,6 +30,6 @@ export async function down(knex: Knex): Promise<void> {

SET ROLE postgres;

ALTER TABLE ${DB_SCHEMA}.occurrence_submission remove column soft_delete_timestamp;
ALTER TABLE ${DB_SCHEMA}.occurrence_submission remove column delete_timestamp;
`);
}
2 changes: 2 additions & 0 deletions database/src/migrations/release.0.22/vw_survey_status.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ with not_published as (select os.survey_id, max(ss.submission_status_id) as subm
where os2.survey_id = os2.survey_id
and ss2.occurrence_submission_id = os2.occurrence_submission_id
and sst.submission_status_type_id = ss2.submission_status_type_id
and os2.delete_timestamp is NULL
and sst.name = api_get_character_system_constant('OCCURRENCE_SUBMISSION_STATE_PUBLISHED')
and sst.record_end_date is null)
group by os.survey_id),
published as (select os.survey_id, max(ss.submission_status_id) as submission_status_id from occurrence_submission os, submission_status ss, submission_status_type sst
where ss.submission_status_type_id = sst.submission_status_type_id
and os.delete_timestamp is NULL
and sst.name = api_get_character_system_constant('OCCURRENCE_SUBMISSION_STATE_PUBLISHED')
and sst.record_end_date is null
group by os.survey_id)
Expand Down