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

Update Sims Template Validations #812

Merged
merged 14 commits into from
Sep 9, 2022
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
import { Knex } from 'knex';
import { goatRecruitmentCompositionJSON } from './template_methodology_species_validations/goat_population_recruitment_composition_survey_1';
import { mooseCompositionJSON } from './template_methodology_species_validations/moose_composition_survey_1';
import { mooseSrbJSON } from './template_methodology_species_validations/moose_srb_survey_1';
import { mooseTransectDistanceJSON } from './template_methodology_species_validations/moose_transect_distance_survey_1';
import { sheepRecruitmentCompositionJSON } from './template_methodology_species_validations/sheep_population_recruitment_composition_survey_1';

const DB_SCHEMA = process.env.DB_SCHEMA;

const moose_composition_validation = mooseCompositionJSON;
const moose_srb_validation = mooseSrbJSON;
const moose_transect_distance_validation = mooseTransectDistanceJSON;
const sheep_population_recruitment_compostion_validation = sheepRecruitmentCompositionJSON;
const goat_population_recruitment_compostion_validation = goatRecruitmentCompositionJSON;

enum COMMON_SURVEY_METHODOLOGY {
COMPOSITION = 'Composition',
STRATIFIED_RANDOM_BLOCK = 'Stratified Random Block'
STRATIFIED_RANDOM_BLOCK = 'Stratified Random Block',
TRANSECT = 'Encounter Transects',
POPULATION_COUNT = 'Total Count'
}

enum TEMPLATE_NAME {
MOOSE_COMPOSITION_SURVEY = 'Moose Composition Survey',
MOOSE_SRB_SURVEY = 'Moose SRB Survey'
MOOSE_SRB_SURVEY = 'Moose SRB Survey',
MOOSE_TRANSECT_DISTANCE_SURVEY = 'Moose Transect Distance Survey',
SHEEP_POPULATION_TOTAL_COUNT = 'Sheep Population Total Count Recruitment Composition Survey',
GOAT_POPULATION_TOTAL_COUNT = 'Goat Population Total Count Recruitment Composition Survey'
}

const validationSchema = [
// Common Survey Methodology: Composition, SRB
//Common Survey Methodology: Composition, SRB, Transect, Population Recruitment
{
v_schema: JSON.stringify(moose_composition_validation),
field_method: COMMON_SURVEY_METHODOLOGY.COMPOSITION,
Expand All @@ -28,6 +39,21 @@ const validationSchema = [
v_schema: JSON.stringify(moose_srb_validation),
field_method: COMMON_SURVEY_METHODOLOGY.STRATIFIED_RANDOM_BLOCK,
template: TEMPLATE_NAME.MOOSE_SRB_SURVEY
},
{
v_schema: JSON.stringify(moose_transect_distance_validation),
field_method: COMMON_SURVEY_METHODOLOGY.TRANSECT,
template: TEMPLATE_NAME.MOOSE_TRANSECT_DISTANCE_SURVEY
},
{
v_schema: JSON.stringify(sheep_population_recruitment_compostion_validation),
field_method: COMMON_SURVEY_METHODOLOGY.POPULATION_COUNT,
template: TEMPLATE_NAME.SHEEP_POPULATION_TOTAL_COUNT
},
{
v_schema: JSON.stringify(goat_population_recruitment_compostion_validation),
field_method: COMMON_SURVEY_METHODOLOGY.POPULATION_COUNT,
template: TEMPLATE_NAME.GOAT_POPULATION_TOTAL_COUNT
}
];

Expand All @@ -52,6 +78,21 @@ export async function up(knex: Knex): Promise<void> {
${DB_SCHEMA}.template (name, version, record_effective_date, description)
values
('${TEMPLATE_NAME.MOOSE_SRB_SURVEY}', '1.0', now(), 'Moose SRB Survey');

insert into
${DB_SCHEMA}.template (name, version, record_effective_date, description)
values
('${TEMPLATE_NAME.MOOSE_TRANSECT_DISTANCE_SURVEY}', '1.0', now(), 'Moose Transect Distance Survey');

insert into
${DB_SCHEMA}.template (name, version, record_effective_date, description)
values
('${TEMPLATE_NAME.SHEEP_POPULATION_TOTAL_COUNT}', '1.0', now(), 'Sheep Population Total Count Recruitment Composition Survey');

insert into
${DB_SCHEMA}.template (name, version, record_effective_date, description)
values
('${TEMPLATE_NAME.GOAT_POPULATION_TOTAL_COUNT}', '1.0', now(), 'Goat Population Total Count Recruitment Composition Survey');
`);

for (const v_schema of validationSchema) {
Expand Down
Loading