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

fix: remove dependencies on use-request.js except from /routes #1607 #2191

Closed
wants to merge 2 commits into from

Conversation

dysmento
Copy link
Contributor

@dysmento dysmento commented Nov 7, 2023

Ticket #1607

Description

This issue was recommended by @as1729 as a good "first issue" for ARPA.

This is a refactor to stop using use-request.js outside of /routes, because we don't always want to assume there's a request context. This allows us to use functions without a request context by passing in the arguments they need, e.g. tenantId

Testing

The existing tests were updated to pass in necessary data where they weren't already doing that.

Automated and Unit Tests

  • Added Unit tests

Manual tests for Reviewer

  • Added steps to test feature/functionality manually

Checklist

  • Provided ticket and description
  • Provided screenshots/demo
  • Provided testing information
  • Provided adequate test coverage for all new code
  • Added PR reviewers

@dysmento dysmento self-assigned this Nov 7, 2023
@@ -181,7 +181,7 @@ function recipientBelongsToUpload(existingRecipient, upload) {
* @param {object} upload - the upload record
* @returns
*/
async function updateOrCreateRecipient(existingRecipient, newRecipient, trns, upload) {
async function updateOrCreateRecipient(existingRecipient, newRecipient, trns, upload, tenantId) {
Copy link

Choose a reason for hiding this comment

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

Function updateOrCreateRecipient has 5 arguments (exceeds 4 allowed). Consider refactoring.

@@ -1,12 +1,12 @@
const { validateUpload } = require('./validate-upload');
const { uploadsInPeriod } = require('../db/uploads');

async function revalidateUploads(period, user, trns) {
const uploads = await uploadsInPeriod(period.id, trns);
async function revalidateUploads(period, user, req, trns, tenantId) {
Copy link

Choose a reason for hiding this comment

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

Function revalidateUploads has 5 arguments (exceeds 4 allowed). Consider refactoring.

@@ -139,7 +138,7 @@ async function createObligationSheet(periodId, domain, tenantId, logger = log) {
return rows;
}

async function createProjectSummaries(periodId, domain, tenantId, logger = log) {
async function createProjectSummaries(periodId, domain, req, tenantId, logger = log) {
Copy link

Choose a reason for hiding this comment

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

Function createProjectSummaries has 5 arguments (exceeds 4 allowed). Consider refactoring.

Copy link

codeclimate bot commented Nov 7, 2023

Code Climate has analyzed commit 91eca3f and detected 3 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 3

The test coverage on the diff in this pull request is 38.8% (50% is the threshold).

This pull request will bring the total coverage in the repository to 55.9% (0.0% change).

View more on Code Climate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant