Skip to content

Commit

Permalink
feat: pacific spiny lumpsucker 2 (#562)
Browse files Browse the repository at this point in the history
Co-authored-by: Scarlett <[email protected]>
Co-authored-by: afwilcox <[email protected]>
Co-authored-by: jeznorth <[email protected]>
Co-authored-by: dmitri-korin-bcps <[email protected]>
Co-authored-by: gregorylavery <[email protected]>
  • Loading branch information
6 people authored Jul 28, 2024
1 parent 1e6c0cc commit dbafc12
Show file tree
Hide file tree
Showing 114 changed files with 29,039 additions and 2,757 deletions.
56 changes: 56 additions & 0 deletions .github/actions/get-pr-number/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Get PR Number
description: Get PR number for merge queues and squash merges
branding:
icon: package
color: blue

inputs:
token:
description: Specify token (GH or PAT), instead of inheriting one from the calling workflow
default: ${{ github.token }}

outputs:
pr:
description: "Associated pull request number"
value: ${{ steps.vars.outputs.pr }}

runs:
using: composite
steps:
- id: vars
shell: bash
run: |
# Get PR number based on the event type
if [ "${{ github.event_name }}" == 'pull_request' ]; then
echo "Event type: pull request"
pr=${{ github.event.number }}
elif [ "${{ github.event_name }}" == 'merge_group' ]; then
echo "Event type: merge queue"
pr=$(echo ${{ github.event.merge_group.head_ref }} | grep -Eo "queue/main/pr-[0-9]+" | cut -d '-' -f2)
elif [ "${{ github.event_name }}" == 'push' ]; then
echo "Event type: push"
pr=$(\
curl -sL -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ inputs.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}/pulls \
| jq 'map(select(.base.ref == "${{ github.ref_name }}")) | .[0].number'
)
if [ -z "${pr}" ]; then
echo "No PR number found. Was this push triggered by a squashed PR merge?"
pr=""
fi
else
echo "Event type: unknown or unexpected"
pr=""
fi
# Validate PR number
if [[ ! "${pr}" =~ ^[0-9]+$ ]]; then
echo "PR number format incorrect: ${pr}"
exit 1
fi
# Output PR number
echo "Summary ---"
echo -e "\tPR: ${pr}"
echo "pr=${pr}" >> $GITHUB_OUTPUT
3 changes: 1 addition & 2 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
npm ci
npm run test:cov
dir: ${{ matrix.dir }}
node_version: "22"
node_version: "20"
sonar_args: >
-Dsonar.exclusions=**/coverage/**,**/node_modules/**,**/*spec.ts
-Dsonar.organization=bcgov-sonarcloud
Expand Down Expand Up @@ -86,4 +86,3 @@ jobs:
runs-on: ubuntu-22.04
steps:
- run: echo "Success!"

68 changes: 68 additions & 0 deletions .github/workflows/merge-hotfix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Deploys hotfixes to the test environment
name: Merge-Hotfix

on:
push:
branches: [hotfix]
paths-ignore:
- "*.md"
- ".github/**"
- ".github/graphics/**"
- "!.github/workflows/**"
workflow_dispatch:
inputs:
pr_no:
description: "PR-numbered container set to deploy"
type: number
required: true

concurrency:
# Do not interrupt previous workflows
group: ${{ github.workflow }}
cancel-in-progress: false

jobs:
vars:
name: Set Variables
outputs:
pr: ${{ steps.pr.outputs.pr }}
runs-on: ubuntu-22.04
timeout-minutes: 1
steps:
- uses: actions/checkout@v4
# Get PR number for squash merges to release
- name: PR Number
id: pr
uses: ./.github/actions/get-pr-number
- name: Set PR Output
run: echo "pr=${{ steps.pr.outputs.pr }}" >> $GITHUB_OUTPUT

# https://github.com/bcgov/quickstart-openshift-helpers
deploy-hotfix:
name: Deploy (hotfix)
needs: vars
uses: bcgov/quickstart-openshift-helpers/.github/workflows/[email protected]
secrets:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_token: ${{ secrets.OC_TOKEN }}
with:
environment: hotfix
tag: ${{ needs.vars.outputs.pr }}

promote:
name: Promote Images
needs: [deploy-hotfix, vars]
runs-on: ubuntu-22.04
permissions:
packages: write
strategy:
matrix:
package: [migrations, backend, frontend, webeoc]
timeout-minutes: 1
steps:
- uses: shrink/actions-docker-registry-tag@v4
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.package }}
target: ${{ needs.vars.outputs.pr }}
tags: hotfix
19 changes: 7 additions & 12 deletions .github/workflows/merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,25 @@ jobs:
runs-on: ubuntu-22.04
timeout-minutes: 1
steps:
# Get PR number for squash merges to main
- uses: actions/checkout@v4
# Get PR number for squash merges to release
- name: PR Number
id: pr
uses: bcgov-nr/[email protected]
uses: ./.github/actions/get-pr-number
- name: Set PR Output
run: echo "pr=${{ steps.pr.outputs.pr }}" >> $GITHUB_OUTPUT

# https://github.com/bcgov/quickstart-openshift-helpers
deploy-test:
name: Deploy (test)
uses: bcgov/quickstart-openshift-helpers/.github/workflows/[email protected]
secrets:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_token: ${{ secrets.OC_TOKEN }}
with:
environment: test

deploy-prod:
name: Deploy (prod)
needs: [deploy-test, vars]
needs: [vars]
uses: bcgov/quickstart-openshift-helpers/.github/workflows/[email protected]
secrets:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_token: ${{ secrets.OC_TOKEN }}
with:
environment: prod
tag: ${{ needs.vars.outputs.pr }}
params: --set backend.deploymentStrategy=RollingUpdate
--set frontend.deploymentStrategy=RollingUpdate
--set global.autoscaling=true
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/merge-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Merge to Release

on:
push:
branches: [release/*]
paths-ignore:
- "*.md"
- ".github/**"
- ".github/graphics/**"
- "!.github/workflows/**"
workflow_dispatch:
inputs:
pr_no:
description: "PR-numbered container set to deploy"
type: number
required: true

concurrency:
# Do not interrupt previous workflows
group: ${{ github.workflow }}
cancel-in-progress: false

jobs:
vars:
name: Set Variables
outputs:
pr: ${{ steps.pr.outputs.pr }}
runs-on: ubuntu-22.04
timeout-minutes: 1
steps:
- uses: actions/checkout@v4
# Get PR number for squash merges to release
- name: PR Number
id: pr
uses: ./.github/actions/get-pr-number
- name: Set PR Output
run: echo "pr=${{ steps.pr.outputs.pr }}" >> $GITHUB_OUTPUT

# https://github.com/bcgov/quickstart-openshift-helpers
deploy-test:
name: Deploy (test)
needs: vars
uses: bcgov/quickstart-openshift-helpers/.github/workflows/[email protected]
secrets:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_token: ${{ secrets.OC_TOKEN }}
with:
environment: test
tag: ${{ needs.vars.outputs.pr }}

promote:
name: Promote Images
needs: [deploy-test, vars]
runs-on: ubuntu-22.04
permissions:
packages: write
strategy:
matrix:
package: [migrations, backend, frontend, webeoc]
timeout-minutes: 1
steps:
- uses: shrink/actions-docker-registry-tag@v4
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.package }}
target: ${{ needs.vars.outputs.pr }}
tags: test
4 changes: 4 additions & 0 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import { ScheduleModule } from "@nestjs/schedule";
import { ComplaintSequenceResetScheduler } from "./v1/complaint/complaint-sequence-reset.service";
import { DocumentModule } from "./v1/document/document.module";
import { CdogsModule } from "./external_api/cdogs/cdogs.module";
import { GirTypeCodeModule } from "./v1/gir_type_code/gir_type_code.module";
import { GeneralIncidentComplaintModule } from "./v1/gir_complaint/gir_complaint.module";

console.log("Var check - POSTGRESQL_HOST", process.env.POSTGRESQL_HOST);
console.log("Var check - POSTGRESQL_DATABASE", process.env.POSTGRESQL_DATABASE);
Expand Down Expand Up @@ -110,6 +112,8 @@ if (process.env.POSTGRESQL_PASSWORD != null) {
ScheduleModule.forRoot(),
DocumentModule,
CdogsModule,
GirTypeCodeModule,
GeneralIncidentComplaintModule,
],
controllers: [AppController],
providers: [AppService, ComplaintSequenceResetScheduler],
Expand Down
8 changes: 4 additions & 4 deletions backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ async function bootstrap() {

process.env.TZ = "UTC";
const config = new DocumentBuilder()
.setTitle("Compliance and Enforcement - Complaint Management API")
.setDescription("The Complicance and Enforcement - Complaint Management API")
.setVersion("1.0")
.addTag("Compliance and Enforcement - Complaint Management")
.setTitle("NatComplaints - Complaint Management API")
.setDescription("NatComplaints - Complaint Management API")
.setVersion("1.0.0")
.addTag("NatComplaints - Complaint Management API")
.build();

const document = SwaggerModule.createDocument(app, config);
Expand Down
105 changes: 105 additions & 0 deletions backend/src/middleware/maps/automapper-dto-to-entity-maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { WildlifeComplaintDto } from "../../types/models/complaints/wildlife-com
import { ComplaintDto } from "../../types/models/complaints/complaint";
import { AttractantXrefDto } from "../../types/models/complaints/attractant-ref";
import { AllegationComplaintDto } from "../../types/models/complaints/allegation-complaint";
import { GeneralIncidentComplaintDto } from "../../types/models/complaints/gir-complaint";
import { GirComplaint } from "../../v1/gir_complaint/entities/gir_complaint.entity";

export const mapComplaintDtoToComplaint = (mapper: Mapper) => {
createMap<ComplaintDto, Complaint>(
Expand Down Expand Up @@ -484,6 +486,109 @@ export const mapAllegationComplaintDtoToAllegationComplaint = (mapper: Mapper) =
);
};

export const mapGirComplaintDtoToGirComplaint = (mapper: Mapper) => {
createMap<GeneralIncidentComplaintDto, GirComplaint>(
mapper,
"GeneralIncidentComplaintDto",
"GirComplaint",
forMember(
(dest) => dest.complaint_identifier.complaint_identifier,
mapFrom((src) => src.id),
),
forMember(
(dest) => dest.complaint_identifier.detail_text,
mapFrom((src) => src.details),
),
forMember(
(dest) => dest.complaint_identifier.caller_name,
mapFrom((src) => src.name),
),
forMember(
(dest) => dest.complaint_identifier.caller_address,
mapFrom((src) => src.address),
),
forMember(
(dest) => dest.complaint_identifier.caller_email,
mapFrom((src) => src.email),
),
forMember(
(dest) => dest.complaint_identifier.caller_phone_1,
mapFrom((src) => src.phone1),
),
forMember(
(dest) => dest.complaint_identifier.caller_phone_2,
mapFrom((src) => src.phone2),
),
forMember(
(dest) => dest.complaint_identifier.caller_phone_3,
mapFrom((src) => src.phone3),
),
forMember(
(dest) => dest.complaint_identifier.location_geometry_point,
mapFrom((src) => src.location),
),
forMember(
(dest) => dest.complaint_identifier.location_summary_text,
mapFrom((src) => src.locationSummary),
),
forMember(
(dest) => dest.complaint_identifier.location_detailed_text,
mapFrom((src) => src.locationDetail),
),
forMember(
(dest) => dest.complaint_identifier.reported_by_other_text,
mapFrom((src) => src.reportedByOther),
),
forMember(
(dest) => dest.complaint_identifier.incident_utc_datetime,
mapFrom((src) => src.incidentDateTime),
),
forMember(
(dest) => dest.complaint_identifier.incident_reported_utc_timestmp,
mapFrom((src) => src.reportedOn),
),
forMember(
(dest) => dest.complaint_identifier.cos_geo_org_unit,
mapFrom((src) => {
const { area, zone, region } = src.organization;
return { area_code: area, zone_code: zone, region_code: region };
}),
),
forMember(
(dest) => dest.complaint_identifier.geo_organization_unit_code,
mapFrom((src) => {
const { area } = src.organization;
return { geo_organization_unit_code: area };
}),
),
forMember(
(dest) => dest.complaint_identifier.owned_by_agency_code,
mapFrom((src) => {
const { ownedBy } = src || null;
return ownedBy ? { agency_code: ownedBy } : null;
}),
),
forMember(
(dest) => dest.complaint_identifier.reported_by_code,
mapFrom((src) => {
const { reportedBy } = src || null;
return reportedBy ? { reported_by_code: reportedBy } : null;
}),
),
forMember(
(dest) => dest.complaint_identifier.complaint_status_code,
mapFrom((src) => {
const { status } = src;
return { complaint_status_code: status };
}),
),
forMember(
(dest) => dest.gir_complaint_guid,
mapFrom((src) => src.girId),
),
);
};

export const mapAttractantXrefDtoToAttractantHwcrXref = (mapper: Mapper) => {
createMap<AttractantXrefDto, AttractantHwcrXref>(
mapper,
Expand Down
Loading

0 comments on commit dbafc12

Please sign in to comment.