Skip to content

Commit

Permalink
Merge branch 'dev' into double-standards
Browse files Browse the repository at this point in the history
  • Loading branch information
mauberti-bc authored Aug 10, 2024
2 parents 253ef45 + 2adb4ff commit 2d8f3a4
Show file tree
Hide file tree
Showing 83 changed files with 1,908 additions and 2,055 deletions.
3 changes: 1 addition & 2 deletions api/src/models/biohub-create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ describe('PostSurveySubmissionToBioHubObject', () => {
const purpose_and_methodology: GetSurveyPurposeAndMethodologyData = {
intended_outcome_ids: [],
additional_details: 'A description of the purpose',
revision_count: 0,
vantage_code_ids: []
revision_count: 0
};

const survey_geometry: FeatureCollection = {
Expand Down
22 changes: 2 additions & 20 deletions api/src/models/survey-create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,13 @@ describe('PostSpeciesData', () => {
it('sets focal_species', () => {
expect(data.focal_species).to.eql([]);
});

it('sets ancillary_species', () => {
expect(data.ancillary_species).to.eql([]);
});
});

describe('All values provided', () => {
let data: PostSpeciesData;

const obj = {
focal_species: [1, 2],
ancillary_species: [3]
focal_species: [1, 2]
};

before(() => {
Expand All @@ -213,10 +208,6 @@ describe('PostSpeciesData', () => {
it('sets focal_species', () => {
expect(data.focal_species).to.eql([1, 2]);
});

it('sets ancillary_species', () => {
expect(data.ancillary_species).to.eql([3]);
});
});
});

Expand Down Expand Up @@ -376,19 +367,14 @@ describe('PostPurposeAndMethodologyData', () => {
it('sets additional_details', () => {
expect(data.additional_details).to.equal(null);
});

it('sets vantage_code_ids', () => {
expect(data.vantage_code_ids).to.eql([]);
});
});

describe('All values provided with first nations id', () => {
let data: PostPurposeAndMethodologyData;

const obj = {
intended_outcome_ids: [1],
additional_details: 'additional_detail',
vantage_code_ids: [4, 5]
additional_details: 'additional_detail'
};

before(() => {
Expand All @@ -402,10 +388,6 @@ describe('PostPurposeAndMethodologyData', () => {
it('sets additional_details', () => {
expect(data.additional_details).to.eql(obj.additional_details);
});

it('sets vantage_code_ids', () => {
expect(data.vantage_code_ids).to.eql(obj.vantage_code_ids);
});
});
});

Expand Down
4 changes: 0 additions & 4 deletions api/src/models/survey-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ export class PostSurveyDetailsData {

export class PostSpeciesData {
focal_species: ITaxonomy[];
ancillary_species: ITaxonomy[];

constructor(obj?: any) {
this.focal_species = (obj?.focal_species?.length && obj.focal_species) || [];
this.ancillary_species = (obj?.ancillary_species?.length && obj.ancillary_species) || [];
}
}

Expand Down Expand Up @@ -126,12 +124,10 @@ export class PostProprietorData {
export class PostPurposeAndMethodologyData {
intended_outcome_ids: number[];
additional_details: string;
vantage_code_ids: number[];

constructor(obj?: any) {
this.intended_outcome_ids = obj?.intended_outcome_ids || [];
this.additional_details = obj?.additional_details || null;
this.vantage_code_ids = obj?.vantage_code_ids || [];
}
}

Expand Down
20 changes: 1 addition & 19 deletions api/src/models/survey-update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,13 @@ describe('PutSpeciesData', () => {
it('sets focal_species', () => {
expect(data.focal_species).to.eql([]);
});

it('sets ancillary_species', () => {
expect(data.ancillary_species).to.eql([]);
});
});

describe('All values provided', () => {
let data: PutSurveySpeciesData;

const obj = {
focal_species: [1, 2],
ancillary_species: [3]
focal_species: [1, 2]
};

before(() => {
Expand All @@ -171,10 +166,6 @@ describe('PutSpeciesData', () => {
it('sets focal_species', () => {
expect(data.focal_species).to.eql([1, 2]);
});

it('sets ancillary_species', () => {
expect(data.ancillary_species).to.eql([3]);
});
});
});

Expand Down Expand Up @@ -340,10 +331,6 @@ describe('PutPurposeAndMethodologyData', () => {
expect(data.additional_details).to.equal(null);
});

it('sets vantage_code_ids', () => {
expect(data.vantage_code_ids).to.eql([]);
});

it('sets revision_count', () => {
expect(data.revision_count).to.equal(null);
});
Expand All @@ -355,7 +342,6 @@ describe('PutPurposeAndMethodologyData', () => {
const obj = {
intended_outcome_ids: [1],
additional_details: 'additional_detail',
vantage_code_ids: [4, 5],
revision_count: 0
};

Expand All @@ -371,10 +357,6 @@ describe('PutPurposeAndMethodologyData', () => {
expect(data.additional_details).to.equal(obj.additional_details);
});

it('sets vantage_code_ids', () => {
expect(data.vantage_code_ids).to.eql(obj.vantage_code_ids);
});

it('sets revision_count', () => {
expect(data.revision_count).to.equal(obj.revision_count);
});
Expand Down
4 changes: 0 additions & 4 deletions api/src/models/survey-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,9 @@ export class PutSurveyDetailsData {

export class PutSurveySpeciesData {
focal_species: ITaxonomy[];
ancillary_species: ITaxonomy[];

constructor(obj?: any) {
this.focal_species = (obj?.focal_species?.length && obj?.focal_species) || [];
this.ancillary_species = (obj?.ancillary_species?.length && obj?.ancillary_species) || [];
}
}

Expand Down Expand Up @@ -136,13 +134,11 @@ export class PutSurveyProprietorData {
export class PutSurveyPurposeAndMethodologyData {
intended_outcome_ids: number[];
additional_details: string;
vantage_code_ids: number[];
revision_count: number;

constructor(obj?: any) {
this.intended_outcome_ids = (obj?.intended_outcome_ids?.length && obj?.intended_outcome_ids) || [];
this.additional_details = obj?.additional_details || null;
this.vantage_code_ids = (obj?.vantage_code_ids?.length && obj.vantage_code_ids) || [];
this.revision_count = obj?.revision_count ?? null;
}
}
Expand Down
44 changes: 0 additions & 44 deletions api/src/models/survey-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { expect } from 'chai';
import { describe } from 'mocha';
import { IPermitModel } from '../repositories/permit-repository';
import {
GetAncillarySpeciesData,
GetAttachmentsData,
GetFocalSpeciesData,
GetPermitData,
Expand Down Expand Up @@ -101,40 +100,6 @@ describe('GetFocalSpeciesData', () => {
});
});

describe('GetAncillarySpeciesData', () => {
describe('No values provided', () => {
let data: GetAncillarySpeciesData;

before(() => {
data = new GetAncillarySpeciesData();
});

it('sets ancillary_species', () => {
expect(data.ancillary_species).to.eql([]);
});
});

describe('All values provided', () => {
let data: GetAncillarySpeciesData;

const obj = [
{ tsn: 1, commonNames: ['species1'] },
{ tsn: 2, commonNames: ['species2'] }
];

before(() => {
data = new GetAncillarySpeciesData(obj);
});

it('sets ancillary_species', () => {
expect(data.ancillary_species).to.eql([
{ tsn: 1, commonNames: ['species1'] },
{ tsn: 2, commonNames: ['species2'] }
]);
});
});
});

describe('GetPermitData', () => {
describe('No values provided', () => {
let data: GetPermitData;
Expand Down Expand Up @@ -325,10 +290,6 @@ describe('GetSurveyPurposeAndMethodologyData', () => {
it('sets additional_details', () => {
expect(data.additional_details).to.equal('');
});

it('sets vantage_code_ids', () => {
expect(data.vantage_code_ids).to.eql([]);
});
});

describe('All values provided with first nations id', () => {
Expand All @@ -337,7 +298,6 @@ describe('GetSurveyPurposeAndMethodologyData', () => {
const obj = {
intended_outcome_ids: [1],
additional_details: 'additional_detail',
vantage_ids: [4, 5],
revision_count: 'count'
};

Expand All @@ -353,10 +313,6 @@ describe('GetSurveyPurposeAndMethodologyData', () => {
expect(data.additional_details).to.eql(obj.additional_details);
});

it('sets vantage_code_ids', () => {
expect(data.vantage_code_ids).to.eql(obj.vantage_ids);
});

it('sets revision_count', function () {
expect(data.revision_count).to.equal('count');
});
Expand Down
16 changes: 1 addition & 15 deletions api/src/models/survey-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type FindSurveysResponse = z.infer<typeof FindSurveysResponse>;

export type SurveyObject = {
survey_details: GetSurveyData;
species: GetFocalSpeciesData & GetAncillarySpeciesData;
species: GetFocalSpeciesData;
permit: GetPermitData;
funding_sources: GetSurveyFundingSourceData[];
purpose_and_methodology: GetSurveyPurposeAndMethodologyData;
Expand Down Expand Up @@ -113,18 +113,6 @@ export class GetFocalSpeciesData {
}
}

export class GetAncillarySpeciesData {
ancillary_species: ITaxonomy[];

constructor(obj?: any[]) {
this.ancillary_species = [];

obj?.length &&
obj.forEach((item: any) => {
this.ancillary_species.push(item);
});
}
}
export class GetPermitData {
permits: {
permit_id: IPermitModel['permit_id'];
Expand All @@ -146,12 +134,10 @@ export class GetSurveyPurposeAndMethodologyData {
intended_outcome_ids: number[];
additional_details: string;
revision_count: number;
vantage_code_ids: number[];

constructor(obj?: any) {
this.intended_outcome_ids = (obj?.intended_outcome_ids?.length && obj?.intended_outcome_ids) || [];
this.additional_details = obj?.additional_details || '';
this.vantage_code_ids = (obj?.vantage_ids?.length && obj.vantage_ids) || [];
this.revision_count = obj?.revision_count ?? 0;
}
}
Expand Down
50 changes: 2 additions & 48 deletions api/src/openapi/schemas/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,50 +141,12 @@ export const focalSpeciesSchema: OpenAPIV3.SchemaObject = {
}
};

export const ancillarySpeciesSchema: OpenAPIV3.SchemaObject = {
title: 'ancillary species response object',
type: 'object',
additionalProperties: false,
required: ['tsn', 'commonNames', 'scientificName'],
properties: {
tsn: {
description: 'Taxonomy tsn',
type: 'number'
},
commonNames: {
description: 'Taxonomy common names',
type: 'array',
items: {
type: 'string'
},
nullable: true
},
scientificName: {
description: 'Taxonomy scientific name',
type: 'string'
},
rank: {
description: 'Taxonomy rank name',
type: 'string'
},
kingdom: {
description: 'Taxonomy kingdom name',
type: 'string'
}
}
};

export const surveySpeciesSchema: OpenAPIV3.SchemaObject = {
description: 'Survey Species',
type: 'object',
additionalProperties: false,
required: ['focal_species', 'ancillary_species'],
required: ['focal_species'],
properties: {
ancillary_species: {
nullable: true,
type: 'array',
items: ancillarySpeciesSchema
},
focal_species: {
type: 'array',
items: focalSpeciesSchema
Expand Down Expand Up @@ -282,7 +244,7 @@ export const surveyPurposeAndMethodologySchema: OpenAPIV3.SchemaObject = {
title: 'survey purpose and methodology response object',
type: 'object',
additionalProperties: false,
required: ['intended_outcome_ids', 'additional_details', 'vantage_code_ids'],
required: ['intended_outcome_ids', 'additional_details'],
properties: {
intended_outcome_ids: {
description: 'Intended outcome ids',
Expand All @@ -301,14 +263,6 @@ export const surveyPurposeAndMethodologySchema: OpenAPIV3.SchemaObject = {
description: 'The integer of times the record has been revised.',
type: 'integer',
minimum: 0
},
vantage_code_ids: {
description: 'Vantage code ids',
type: 'array',
items: {
type: 'integer',
minimum: 1
}
}
}
};
Expand Down
Loading

0 comments on commit 2d8f3a4

Please sign in to comment.