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

[BUG][NRPTI-1233] Amalgamated permits not showing in BCMI #1243

Merged

Conversation

sggerard
Copy link
Contributor

Description

This PR includes the following proposed change(s):

  • Support for new permit code 'ALG' in both CORE cron job and front end
  • Migration to update existing BCMI collections with type of 'ALG'
  • Additional minor unrelated spelling and linting fixes

@sggerard sggerard requested a review from a team June 20, 2024 16:35
@sggerard sggerard self-assigned this Jun 20, 2024
@sggerard sggerard linked an issue Jun 20, 2024 that may be closed by this pull request
Copy link

sonarcloud bot commented Jun 20, 2024

@acatchpole acatchpole self-assigned this Jun 20, 2024
@@ -2,7 +2,7 @@
name: Bug
about: An undesirable behaviour that needs correction
title: ''
labels: Spike
labels: Bug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated minor fix to a github issue template

@@ -72,7 +72,7 @@ exports.protectedPut = async function (args, res, next) {

const sanitizedObj = PutUtils.validateObjectAgainstModel(MineBCMI, incomingObj);

if (!sanitizedObj || sanitizedObj === {}) {
if (!sanitizedObj || Object.keys(sanitizedObj).length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated minor fix. as js compares objects by reference, "sanitizedObj === {}" is always false.

@acatchpole acatchpole marked this pull request as ready for review June 20, 2024 17:28
@acatchpole
Copy link
Contributor

sonarcloud is failing due to some var declarations in the migration template and a function we did not write having too high of a "cognitive load".

@@ -46,7 +46,9 @@
</label>
<select name="typeCode" id="typeCode" formControlName="typeCode" class="form-control">
<option *ngFor="let typeCode of permitTypes" [ngValue]="typeCode">
{{ typeCode === 'OGP' ? 'Original Permit' : 'Permit Amendment' }}
{{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to avoid nested ternary operators. I find they can be confusing to reason about and prefer the clarity of something along the following lines. Not a necessary change though. You'd have to pull it out into a function.

`
const acceptedTypeCodes = ['OGP', 'ALG']

if (acceptedTypeCodes.includes(typeCode)) return 'Permit Amendment';

if (typeCode === 'OGP') return 'Original Permit';

if (typeCode === 'ALG') return 'Amalgamated Permit';
`

@@ -68,7 +68,9 @@ <h2 class="border-0 mb-0">Edit record</h2>
<label for="typeCode">Permit Type</label>
<select name="typeCode" id="typeCode" formControlName="typeCode" class="form-control">
<option *ngFor="let typeCode of permitTypes" [ngValue]="typeCode">
{{ typeCode === 'OGP' ? 'Original Permit' : 'Permit Amendment' }}
{{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are repeating here so it could make sense to pull this out into a function referenced above.

@@ -42,6 +42,8 @@ <h2 class="border-0 mb-0">Record Information</h2>
? 'Original Permit'
: record && record.typeCode && record.typeCode === 'AMD'
? 'Permit Amendment'
: record && record.typeCode && record.typeCode === 'ALG'
? 'Amalgamated Permit'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ternary could also be addressed if you do decide to pull out a function and go the route of early returns.

getPermitType(typeCode) {
switch(typeCode){
case 'OGP':
return 'Permit';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We reference 'Permit' here and 'Original Permit' for the same case it would be best to stick to one name but there may be a reason for that.

Also is there an opportunity to refactor this switch into the function suggested above?

fergmac
fergmac previously approved these changes Jun 20, 2024
Copy link

sonarcloud bot commented Jun 20, 2024

@acatchpole acatchpole merged commit 0f6517a into master Jun 20, 2024
4 checks passed
@acatchpole acatchpole deleted the 1233-amalgamated-mines-act-permits-not-showing-in-bcmi branch June 20, 2024 22:48
sggerard added a commit that referenced this pull request Jul 17, 2024
* unrelated minor fixes

* Add getPermitType method to PermitUtils

* Add support for Amalgamated Permit code

* Revert datasource.js

* Fix typo

* created migration that updates the type field based on the typeCode of the associate records

* linting fixes

* Replace ternary operators with function calls

* Replace ternary operator with function call in add component

* moved permitName to utils and refactored to support

* removed minePermitNames from individual files as they are now in recordUtils

* added minePermitNames to recordUtils

* Fix mine permit bugs due to typos

* linting fix 3: The Revenge of Lint

---------

Co-authored-by: acatchpole <adamantiumite@gmail.com>
Co-authored-by: acatchpole <113044739+acatchpole@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Amalgamated Mines Act Permits not showing in BCMI
3 participants