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-1242] Add support for creating & updating permits from multiple permit codes #1248

Merged
merged 3 commits into from
Jun 27, 2024

Conversation

sggerard
Copy link
Contributor

Pull Request Standards

Description

Previously only the most recent valid permit was selected for a mine and records processed for the permit. However requirements changed and now both M and MX records need to be publicly available. A hotfix hotfix was deployed but did not address the underlying problem leading to syncing issues. This PR attempts to properly implement a solution.

This PR includes the following proposed change(s):
Replaces getMinePermit() with getMinePermits() and separates the logic out into multiple methods so that createMinePermit() and updateMinePermit() can process multiple mine permits instead of only the currently selected valid Mine Permit. This allows both MX and M permits and collections for a single mine to be processed during the cron run.

@sggerard sggerard linked an issue Jun 27, 2024 that may be closed by this pull request
@sggerard sggerard requested a review from a team June 27, 2024 22:19
Copy link
Contributor

@LocalNewsTV LocalNewsTV left a comment

Choose a reason for hiding this comment

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

No red flags stand out :) Just some minor formatting inconsistency and one small suggestion

Comment on lines 280 to 283
if (nrptiRecord.name === 'Lumby Mine' && permit.permit_no === 'G-4-352') {
return false;
}
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the if determines the return, couldn't the return just be the !inverse of the if.
If the intent isn't clear it could be assigned to a variable before the return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It sure can! The sonarcloud robots agree with you too ;)

Comment on lines 270 to 276
return permits.filter(p => this.isValidPermit(p,nrptiRecord));
}

isValidPermit(permit,nrptiRecord){
//Mine must not be historical which is indicated by an authorized year of '9999' on the latest amendment.
if((permit.permit_amendments.length && !permit.permit_amendments[0].authorization_end_date)
|| permit.permit_status_code === 'O'){
Copy link
Contributor

Choose a reason for hiding this comment

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

Just minor formatting inconsistencies to the rest of the file with regards to whitespace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good spotting! I did see this when I reviewed the PR too, surprised the linter didn't catch it

Copy link

sonarcloud bot commented Jun 27, 2024

@sggerard sggerard merged commit b97bc99 into master Jun 27, 2024
4 checks passed
@sggerard sggerard deleted the 1242-add-support-for-mx-permits branch June 27, 2024 23:24
@sggerard sggerard restored the 1242-add-support-for-mx-permits branch June 28, 2024 17:29
sggerard added a commit that referenced this pull request Jul 17, 2024
…ltiple permit codes (#1248)

* Add support for creating permits from multiple permit codes

* Fix test method calls

* Fix whitespace and replace if-then-else with single return statement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for MX permits
3 participants