Skip to content

Commit

Permalink
refactor: delete alias to make SQL statement easier to follow
Browse files Browse the repository at this point in the history
  • Loading branch information
fengelniederhammer committed Jul 8, 2024
1 parent 828d4df commit 6d921d5
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions backend/src/main/resources/db/migration/V1__init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -106,30 +106,30 @@ from

create view sequence_entries_view as
select
se.*,
sepd.started_processing_at,
sepd.finished_processing_at,
sepd.processed_data as processed_data,
sepd.processed_data || em.joint_metadata as joint_metadata,
sepd.errors,
sepd.warnings,
sequence_entries.*,
sequence_entries_preprocessed_data.started_processing_at,
sequence_entries_preprocessed_data.finished_processing_at,
sequence_entries_preprocessed_data.processed_data as processed_data,
sequence_entries_preprocessed_data.processed_data || external_metadata_view.joint_metadata as joint_metadata,
sequence_entries_preprocessed_data.errors,
sequence_entries_preprocessed_data.warnings,
case
when se.released_at is not null then 'APPROVED_FOR_RELEASE'
when se.is_revocation then 'AWAITING_APPROVAL'
when sepd.processing_status = 'IN_PROCESSING' then 'IN_PROCESSING'
when sepd.processing_status = 'HAS_ERRORS' then 'HAS_ERRORS'
when sepd.processing_status = 'FINISHED' then 'AWAITING_APPROVAL'
when sequence_entries.released_at is not null then 'APPROVED_FOR_RELEASE'
when sequence_entries.is_revocation then 'AWAITING_APPROVAL'
when sequence_entries_preprocessed_data.processing_status = 'IN_PROCESSING' then 'IN_PROCESSING'
when sequence_entries_preprocessed_data.processing_status = 'HAS_ERRORS' then 'HAS_ERRORS'
when sequence_entries_preprocessed_data.processing_status = 'FINISHED' then 'AWAITING_APPROVAL'
else 'RECEIVED'
end as status
from
sequence_entries se
left join sequence_entries_preprocessed_data sepd on
se.accession = sepd.accession
and se.version = sepd.version
and sepd.pipeline_version = (select version from current_processing_pipeline)
left join external_metadata_view em on
se.accession = em.accession
and se.version = em.version;
sequence_entries
left join sequence_entries_preprocessed_data on
sequence_entries.accession = sequence_entries_preprocessed_data.accession
and sequence_entries.version = sequence_entries_preprocessed_data.version
and sequence_entries_preprocessed_data.pipeline_version = (select version from current_processing_pipeline)
left join external_metadata_view on
sequence_entries.accession = external_metadata_view.accession
and sequence_entries.version = external_metadata_view.version;

create table metadata_upload_aux_table (
accession text,
Expand Down

0 comments on commit 6d921d5

Please sign in to comment.