Skip to content

Commit

Permalink
BHBC-1688: Add survey radio field (#746)
Browse files Browse the repository at this point in the history
* BHBC-1688: Add new radio button field to survey.
* Add github action to write openshift urls
  • Loading branch information
NickPhura authored Apr 21, 2022
1 parent ce62af8 commit 11ed419
Show file tree
Hide file tree
Showing 26 changed files with 459 additions and 118 deletions.
30 changes: 5 additions & 25 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
# Overview

## Links to jira tickets
## Links to Jira tickets

- {Include links to all of the applicable Jira tickets}
- {List all applicable Jira tickets}

## This PR contains the following changes
## Description of relevant changes

- {List all the relevant changes. If there are many changes across many Jira tickets, organize the changes by Jira ticket}
- {List all relevant changes, in particular anything that will help the reviewers test/verify this PR}

## This PR contains the following types of changes

- [ ] New feature (change which adds functionality)
- [ ] Enhancement (improvements to existing functionality)
- [ ] Bug fix (change which fixes an issue)
- [ ] Misc cleanup / Refactoring / Documentation
- [ ] Version change

## Checklist
## PR Checklist

A list of items that are good to consider when making any changes.

_Note: this list is not exhaustive, and not all items are always applicable._

### General

- [ ] I have performed a self-review of my own code

### Code

- [ ] New files/classes/functions have appropriately descriptive names and comment blocks to describe their use/behaviour
Expand Down Expand Up @@ -60,11 +48,3 @@ _Note: this list is not exhaustive, and not all items are always applicable._
### SonarCloud

- [ ] I have addressed all SonarCloud Bugs, Vulnerabilities, Security Hotspots, and Code Smells

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

## Screenshots

Please add any relevant UI screenshots, if applicable.
23 changes: 23 additions & 0 deletions .github/workflows/addComments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Add automated comments to the PR
name: Add Comments

on:
pull_request:
types: [opened]
branches:
- dev

jobs:
addOpenshiftURLComment:
name: Add Openshift URL Comment
runs-on: ubuntu-latest
steps:
- name: Add Comment
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.number }}
body: |
Openshift URLs for the PR Deployment:
- App Route: https://biohubbc-app-${{ github.event.number }}-af2668-dev.apps.silver.devops.gov.bc.ca/
- Api Route: https://biohubbc-api-${{ github.event.number }}-af2668-dev.apps.silver.devops.gov.bc.ca/
- Pods: https://console.apps.silver.devops.gov.bc.ca/k8s/ns/af2668-dev/pods?name=${{ github.event.number }}
18 changes: 16 additions & 2 deletions api/src/models/survey-create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ describe('PostSurveyObject', () => {
it('sets survey_proprietor', () => {
expect(data.survey_proprietor).to.equal(undefined);
});

it('sets surveyed_all_areas', () => {
expect(data.surveyed_all_areas).to.equal(false);
});
});

describe('All values provided with survey data proprietary is false', () => {
Expand Down Expand Up @@ -97,7 +101,8 @@ describe('PostSurveyObject', () => {
first_nations_id: null,
category_rationale: null,
proprietor_name: null,
data_sharing_agreement_required: 'false'
data_sharing_agreement_required: 'false',
surveyed_all_areas: 'true'
};

before(() => {
Expand Down Expand Up @@ -155,6 +160,10 @@ describe('PostSurveyObject', () => {
it('sets the geometry', () => {
expect(data.geometry).to.eql(surveyObj.geometry);
});

it('sets surveyed_all_areas', () => {
expect(data.surveyed_all_areas).to.equal(true);
});
});

describe('All values provided with survey data proprietary is true', () => {
Expand All @@ -178,7 +187,8 @@ describe('PostSurveyObject', () => {
first_nations_id: null,
category_rationale: 'rationale',
proprietor_name: 'name',
data_sharing_agreement_required: 'true'
data_sharing_agreement_required: 'true',
surveyed_all_areas: 'true'
};

before(() => {
Expand Down Expand Up @@ -238,6 +248,10 @@ describe('PostSurveyObject', () => {
disa_required: true
});
});

it('sets surveyed_all_areas', () => {
expect(data.surveyed_all_areas).to.equal(true);
});
});
});

Expand Down
2 changes: 2 additions & 0 deletions api/src/models/survey-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class PostSurveyObject {
field_method_id: number;
ecological_season_id: number;
vantage_code_ids: number[];
surveyed_all_areas: boolean;
start_date: string;
end_date: string;
survey_area_name: string;
Expand Down Expand Up @@ -63,6 +64,7 @@ export class PostSurveyObject {
this.ecological_season_id = obj?.ecological_season_id || null;
this.additional_details = obj?.additional_details || null;
this.vantage_code_ids = (obj?.vantage_code_ids?.length && obj.vantage_code_ids) || [];
this.surveyed_all_areas = obj?.surveyed_all_areas === 'true' || false;
this.geometry = (obj?.geometry?.length && obj.geometry) || [];
this.survey_proprietor =
(obj && obj.survey_data_proprietary === 'true' && new PostSurveyProprietorData(obj)) || undefined;
Expand Down
15 changes: 12 additions & 3 deletions api/src/models/survey-update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,13 @@ describe('PutSurveyPurposeAndMethodologyData', () => {
expect(data.ecological_season_id).to.equal(null);
});

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

it('sets surveyed_all_areas', () => {
expect(data.surveyed_all_areas).to.equal(false);
});

it('sets revision_count', () => {
expect(data.revision_count).to.equal(null);
Expand All @@ -416,6 +420,7 @@ describe('PutSurveyPurposeAndMethodologyData', () => {
vantage_code_ids: [1, 2],
ecological_season_id: 1,
intended_outcome_id: 1,
surveyed_all_areas: 'true',
revision_count: 1
};

Expand Down Expand Up @@ -447,6 +452,10 @@ describe('PutSurveyPurposeAndMethodologyData', () => {
expect(data.vantage_code_ids).to.equal(purposeAndMethodologyData.vantage_code_ids);
});

it('sets surveyed_all_areas', () => {
expect(data.surveyed_all_areas).to.equal(true);
});

it('sets revision_count', () => {
expect(data.revision_count).to.equal(purposeAndMethodologyData.revision_count);
});
Expand Down
2 changes: 2 additions & 0 deletions api/src/models/survey-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export class PutSurveyPurposeAndMethodologyData {
additional_details: string;
ecological_season_id: number;
vantage_code_ids: number[];
surveyed_all_areas: boolean;
revision_count: number;

constructor(obj?: any) {
Expand All @@ -169,6 +170,7 @@ export class PutSurveyPurposeAndMethodologyData {
this.additional_details = obj?.additional_details || null;
this.ecological_season_id = obj?.ecological_season_id || null;
this.vantage_code_ids = (obj?.vantage_code_ids?.length && obj.vantage_code_ids) || [];
this.surveyed_all_areas = obj?.surveyed_all_areas === 'true' || false;
this.revision_count = obj?.revision_count ?? null;
}
}
9 changes: 9 additions & 0 deletions api/src/models/survey-view-update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ describe('GetSurveyProprietorData', () => {
it('sets data_sharing_agreement_required', () => {
expect(data.data_sharing_agreement_required).to.equal('false');
});

it('sets survey_data_proprietary', () => {
expect(data.survey_data_proprietary).to.equal('false');
});
});

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

const proprietorData = {
id: 1,
proprietor_type_name: 'type',
first_nations_name: 'fn name',
category_rationale: 'rationale',
Expand Down Expand Up @@ -65,5 +70,9 @@ describe('GetSurveyProprietorData', () => {
it('sets data_sharing_agreement_required', () => {
expect(data.data_sharing_agreement_required).to.equal('true');
});

it('sets survey_data_proprietary', () => {
expect(data.survey_data_proprietary).to.equal('true');
});
});
});
7 changes: 4 additions & 3 deletions api/src/models/survey-view-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class GetSurveyProprietorData {
first_nations_id: number;
category_rationale: string;
proprietor_name: string;
survey_data_proprietary: string;
data_sharing_agreement_required: string;
survey_data_proprietary: string;
revision_count: number;

constructor(data?: any) {
Expand All @@ -34,8 +34,8 @@ export class GetSurveyProprietorData {
this.first_nations_id = data?.first_nations_id ?? null;
this.category_rationale = data?.category_rationale || '';
this.proprietor_name = data?.proprietor_name || '';
this.survey_data_proprietary = data?.survey_data_proprietary || 'true';
this.data_sharing_agreement_required = data?.disa_required ? 'true' : 'false';
this.survey_data_proprietary = (data?.id && 'true') || 'false'; // The existence of a survey proprietor record indicates the survey data is proprietary
this.revision_count = data?.revision_count ?? null;
}
}
Expand All @@ -59,7 +59,8 @@ export class GetSurveyPurposeAndMethodologyData {
field_method_id: item.field_method_id,
ecological_season_id: item.ecological_season_id,
revision_count: item.revision_count,
vantage_code_ids: [item.vantage_id]
vantage_code_ids: [item.vantage_id],
surveyed_all_areas: (item.surveyed_all_areas && 'true') || 'false'
};
} else {
obj[item.id].vantage_code_ids.push(item.vantage_id);
Expand Down
18 changes: 15 additions & 3 deletions api/src/paths/project/{projectId}/survey/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ POST.apiDoc = {
'biologist_first_name',
'biologist_last_name',
'survey_area_name',
'survey_data_proprietary'
'survey_data_proprietary',
'foippa_requirements_accepted',
'sedis_procedures_accepted'
],
properties: {
survey_name: {
Expand Down Expand Up @@ -100,6 +102,10 @@ POST.apiDoc = {
ecological_season_id: {
type: 'number'
},
surveyed_all_areas: {
type: 'string',
enum: ['true', 'false']
},
biologist_first_name: {
type: 'string'
},
Expand Down Expand Up @@ -128,10 +134,16 @@ POST.apiDoc = {
type: 'string'
},
foippa_requirements_accepted: {
type: 'boolean'
type: 'boolean',
enum: [true],
description:
'Data meets or exceeds the Freedom of Information and Protection of Privacy Act (FOIPPA) Requirements'
},
sedis_procedures_accepted: {
type: 'boolean'
type: 'boolean',
enum: [true],
description:
'Data is in accordance with the Species and Ecosystems Data and Information Security (SEDIS) Procedures'
},
funding_sources: {
type: 'array',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,9 @@ describe('getSurveyForUpdate', () => {
additional_details: 'details',
ecological_season_id: 1,
intended_outcome_id: 8,
revision_count: 0,
vantage_id: 2
surveyed_all_areas: true,
vantage_id: 2,
revision_count: 0
};

const survey_proprietor = {
Expand Down Expand Up @@ -325,6 +326,7 @@ describe('getSurveyForUpdate', () => {
additional_details: 'details',
ecological_season_id: 1,
vantage_code_ids: [2],
surveyed_all_areas: 'true',
revision_count: 0
},
survey_proprietor: {
Expand Down
34 changes: 28 additions & 6 deletions api/src/paths/project/{projectId}/survey/{surveyId}/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ GET.apiDoc = {
survey_purpose_and_methodology: {
description: 'Survey Details',
type: 'object',
required: [
'field_method_id',
'intended_outcome_id',
'ecological_season_id',
'vantage_code_ids',
'surveyed_all_areas'
],
properties: {
id: {
type: 'number'
Expand All @@ -244,14 +251,18 @@ GET.apiDoc = {
ecological_season_id: {
type: 'number'
},
revision_count: {
type: 'number'
},
vantage_code_ids: {
type: 'array',
items: {
type: 'number'
}
},
surveyed_all_areas: {
type: 'string',
enum: ['true', 'false']
},
revision_count: {
type: 'number'
}
}
},
Expand Down Expand Up @@ -439,6 +450,13 @@ PUT.apiDoc = {
survey_purpose_and_methodology: {
description: 'Survey Details',
type: 'object',
required: [
'field_method_id',
'intended_outcome_id',
'ecological_season_id',
'vantage_code_ids',
'surveyed_all_areas'
],
properties: {
id: {
type: 'number'
Expand All @@ -455,14 +473,18 @@ PUT.apiDoc = {
ecological_season_id: {
type: 'number'
},
revision_count: {
type: 'number'
},
vantage_code_ids: {
type: 'array',
items: {
type: 'number'
}
},
surveyed_all_areas: {
type: 'string',
enum: ['true', 'false']
},
revision_count: {
type: 'number'
}
}
},
Expand Down
Loading

0 comments on commit 11ed419

Please sign in to comment.