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

Revert "fix: #1676 - Cache prior reporting periods" #2243

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 0 additions & 184 deletions packages/server/__tests__/arpa_reporter/server/fixtures/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,196 +103,12 @@ const uploads = {
},
};

const audit_report_data = {
obligations: [{
'Reporting Period': 'Quarterly 1',
'Period End Date': new Date(2021, 11, 31),
Upload: {
f: '=HYPERLINK(\'http://localhost:8080/arpa_reporter/uploads/601a2011-91d5-4acb-b83e-f47ee8ae462f\',\'UPLOAD_CLEAN_ID6.xlsm\')',
},
'Adopted Budget (EC tabs)': 300000,
'Total Cumulative Obligations (EC tabs)': 300000,
'Total Cumulative Expenditures (EC tabs)': 150000,
'Current Period Obligations (EC tabs)': 150000,
'Current Period Expenditures (EC tabs)': 150000,
'Subaward Obligations (Subaward >50k)': 300000,
'Total Expenditure Amount (Expenditures >50k)': 150000,
'Current Period Obligations (Aggregate Awards <50k)': 0,
'Current Period Expenditures (Aggregate Awards <50k)': 0,
}, {
'Reporting Period': 'Quarterly 2',
'Period End Date': new Date(2022, 2, 31),
Upload: {
f: '=HYPERLINK(\'http://localhost:8080/arpa_reporter/uploads/3bb6dbb3-741c-43d1-957a-2d35dd1dd2a9\',\'UPLOAD_CLEAN_ID7.xlsm\')',
},
'Adopted Budget (EC tabs)': 300000,
'Total Cumulative Obligations (EC tabs)': 300000,
'Total Cumulative Expenditures (EC tabs)': 150000,
'Current Period Obligations (EC tabs)': 150000,
'Current Period Expenditures (EC tabs)': 150000,
'Subaward Obligations (Subaward >50k)': 300000,
'Total Expenditure Amount (Expenditures >50k)': 150000,
'Current Period Obligations (Aggregate Awards <50k)': 0,
'Current Period Expenditures (Aggregate Awards <50k)': 0,
}, {
'Reporting Period': 'Quarterly 3',
'Period End Date': new Date(2022, 5, 30),
Upload: {
f: '=HYPERLINK(\'http://localhost:8080/arpa_reporter/uploads/db5de7d3-4209-46d0-9479-8696491aadfc\',\'UPLOAD_CLEAN_ID8.xlsm\')',
},
'Adopted Budget (EC tabs)': 300000,
'Total Cumulative Obligations (EC tabs)': 300000,
'Total Cumulative Expenditures (EC tabs)': 150000,
'Current Period Obligations (EC tabs)': 150000,
'Current Period Expenditures (EC tabs)': 150000,
'Subaward Obligations (Subaward >50k)': 300000,
'Total Expenditure Amount (Expenditures >50k)': 150000,
'Current Period Obligations (Aggregate Awards <50k)': 0,
'Current Period Expenditures (Aggregate Awards <50k)': 0,
}],
projectSummaries: [{
'Project ID': 6,
Upload: {
f: '=HYPERLINK(\'http://localhost:8080/arpa_reporter/uploads/601a2011-91d5-4acb-b83e-f47ee8ae462f\',\'UPLOAD_CLEAN_ID6.xlsm\')',
},
'Last Reported': 'Quarterly 1',
'Adopted Budget': 300000,
'Total Cumulative Obligations': 300000,
'Total Cumulative Expenditures': 150000,
'Current Period Obligations': 150000,
'Current Period Expenditures': 150000,
'Completion Status': 'Completed less than 50%',
}, {
'Project ID': 7,
Upload: {
f: '=HYPERLINK(\'http://localhost:8080/arpa_reporter/uploads/3bb6dbb3-741c-43d1-957a-2d35dd1dd2a9\',\'UPLOAD_CLEAN_ID7.xlsm\')',
},
'Last Reported': 'Quarterly 2',
'Adopted Budget': 300000,
'Total Cumulative Obligations': 300000,
'Total Cumulative Expenditures': 150000,
'Current Period Obligations': 150000,
'Current Period Expenditures': 150000,
'Completion Status': 'Completed less than 50%',
},
{
'Project ID': 8,
Upload: {
f: '=HYPERLINK(\'http://localhost:8080/arpa_reporter/uploads/db5de7d3-4209-46d0-9479-8696491aadfc\',\'UPLOAD_CLEAN_ID8.xlsm\')',
},
'Last Reported': 'Quarterly 3',
'Adopted Budget': 300000,
'Total Cumulative Obligations': 300000,
'Total Cumulative Expenditures': 150000,
'Current Period Obligations': 150000,
'Current Period Expenditures': 150000,
'Completion Status': 'Completed less than 50%',
}],
projectSummaryGroupedByProject: [{
'Project ID': '6',
'Project Description': 'This project will fund the start-up costs of new Family Child Care providers to open high-quality FCC options and increase the overall supply of child care in the state. \'New Family Child Care Providers\' can be defined, for the purposes of this program, as providers who do not currently hold a license with the Department of Human Services, which may include providers who previously held licenses in good standing with the Department or providers new to the field entirely. This project will fund the start-up costs of new Family Child Care providers to open high-quality FCC options and increase the overall supply of child care in the state.',
'Project Expenditure Category Group': '2-Negative Economic Impacts',
'Project Expenditure Category': '2.32-Business Incubators and Start-Up or Expansion Assistance',
'2021-12-31 Total Aggregate Expenditures': 150000,
'2021-12-31 Total Expenditures for Awards Greater or Equal to $50k': 0,
'2021-12-31 Total Aggregate Obligations': 300000,
'2021-12-31 Total Obligations for Awards Greater or Equal to $50k': 0,
'Capital Expenditure Amount': 0,
}, {
'Project ID': '7',
'Project Description': 'This project will fund the start-up costs of new Family Child Care providers to open high-quality FCC options and increase the overall supply of child care in the state. \'New Family Child Care Providers\' can be defined, for the purposes of this program, as providers who do not currently hold a license with the Department of Human Services, which may include providers who previously held licenses in good standing with the Department or providers new to the field entirely. This project will fund the start-up costs of new Family Child Care providers to open high-quality FCC options and increase the overall supply of child care in the state.',
'Project Expenditure Category Group': '2-Negative Economic Impacts',
'Project Expenditure Category': '2.32-Business Incubators and Start-Up or Expansion Assistance',
'2022-03-31 Total Aggregate Expenditures': 150000,
'2022-03-31 Total Expenditures for Awards Greater or Equal to $50k': 0,
'2022-03-31 Total Aggregate Obligations': 300000,
'2022-03-31 Total Obligations for Awards Greater or Equal to $50k': 0,
'Capital Expenditure Amount': 0,
}, {
'Project ID': '8',
'Project Description': 'This project will fund the start-up costs of new Family Child Care providers to open high-quality FCC options and increase the overall supply of child care in the state. \'New Family Child Care Providers\' can be defined, for the purposes of this program, as providers who do not currently hold a license with the Department of Human Services, which may include providers who previously held licenses in good standing with the Department or providers new to the field entirely. This project will fund the start-up costs of new Family Child Care providers to open high-quality FCC options and increase the overall supply of child care in the state.',
'Project Expenditure Category Group': '2-Negative Economic Impacts',
'Project Expenditure Category': '2.32-Business Incubators and Start-Up or Expansion Assistance',
'2022-06-30 Total Aggregate Expenditures': 150000,
'2022-06-30 Total Expenditures for Awards Greater or Equal to $50k': 0,
'2022-06-30 Total Aggregate Obligations': 300000,
'2022-06-30 Total Obligations for Awards Greater or Equal to $50k': 0,
'Capital Expenditure Amount': 0,
}],
KPIDataGroupedByProject: [{
'Project ID': '6',
'Number of Subawards': 0,
'Number of Expenditures': 1,
'Evidence Based Total Spend': 0,
'Evidence based total spend': null,
}, {
'Project ID': '7',
'Number of Subawards': 0,
'Number of Expenditures': 1,
'Evidence Based Total Spend': 0,
'Evidence based total spend': null,
}, {
'Project ID': '8',
'Number of Subawards': 0,
'Number of Expenditures': 1,
'Evidence Based Total Spend': 0,
'Evidence based total spend': null,
}],
};

const session = {
user: {
id: 1,
email: '[email protected]',
name: 'Alex Allain',
role_id: 1,
role_name: 'admin',
role_rules: {},
agency_id: 0,
agency_name: 'USDR',
agency_abbreviation: 'USDR',
agency_parent_id_id: null,
agency_warning_threshold: 30,
agency_danger_threshold: 15,
tenant_id: 1,
tenant_display_name: 'USDR Tenant',
tenant_main_agency_id: 400,
tenant_uses_spoc_process: false,
tags: null,
role: { id: 1, name: 'admin', rules: {} },
agency: {
id: 0,
name: 'USDR',
abbreviation: 'USDR',
agency_parent_id: undefined,
warning_threshold: 30,
danger_threshold: 15,
main_agency_id: undefined,
subagencies: [],
},
tenant: {
id: 1,
display_name: 'USDR Tenant',
main_agency_id: 400,
uses_spoc_process: false,
},
emailPreferences: {
GRANT_ASSIGNMENT: 'SUBSCRIBED',
GRANT_INTEREST: 'SUBSCRIBED',
GRANT_DIGEST: 'SUBSCRIBED',
},
},
selectedAgency: 0,
};

module.exports = {
TABLES,
reportingPeriods,
uploads,
TENANT_ID,
users,
audit_report_data,
session,
};

module.exports.clean = async (knex) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const email = require('../../../../src/lib/email');
const audit_report = require('../../../../src/arpa_reporter/lib/audit-report');
const aws = require('../../../../src/lib/gost-aws');
const { withTenantId } = require('../helpers/with-tenant-id');
const { audit_report_data } = require('../fixtures/fixtures');

function handleUploadFake(type) {
if (type === 'success') {
Expand All @@ -30,7 +29,6 @@ describe('audit report generation', () => {
afterEach(() => {
sandbox.restore();
});

it('sendEmailWithLink creates a presigned url and sends email to recipient', async () => {
const sendFake = sandbox.fake.returns('foo');
sandbox.replace(email, 'sendAsyncReportEmail', sendFake);
Expand Down Expand Up @@ -81,7 +79,6 @@ describe('audit report generation', () => {
expect(sendEmailFake.firstCall.firstArg).to.equal('0/99/example.xlsx');
expect(sendEmailFake.firstCall.args[1]).to.equal('[email protected]');
});

it('generateAndSendEmail does not send an email if upload fails', async () => {
const sendFake = sandbox.fake.returns('foo');
sandbox.replace(email, 'sendAsyncReportEmail', sendFake);
Expand Down Expand Up @@ -122,43 +119,6 @@ describe('audit report generation', () => {
expect(sendEmailFake.notCalled).to.equal(true);
});

it('generate audit report components', async () => {
const allData = audit_report_data;
const cachedData = Object.keys(audit_report_data).reduce((x, y) => { x[y] = audit_report_data[y].slice(0, -1); return x; }, {});
const dataWithCache = Object.keys(audit_report_data).reduce((x, y) => { x[y] = [audit_report_data[y][audit_report_data[y].length - 1]]; return x; }, {});
const periodId = 1;
const tenantId = 0;
const domain = 'test';

const obligationStub = sandbox.stub(audit_report, 'getObligationData');
obligationStub.returns(allData.obligations);
const obligationsNoCache = await audit_report.createObligationSheet(periodId, domain, tenantId, null);
obligationStub.returns(dataWithCache.obligations);
const obligationsWithCache = await audit_report.createObligationSheet(periodId, domain, tenantId, cachedData.obligations);
expect(JSON.stringify(obligationsNoCache)).to.equal(JSON.stringify(obligationsWithCache));

const projectSummariesStub = sandbox.stub(audit_report, 'getProjectSummariesData');
projectSummariesStub.returns(allData.projectSummaries);
const projectSummariesNoCache = await audit_report.createProjectSummariesSheet(periodId, domain, tenantId, null);
projectSummariesStub.returns(dataWithCache.projectSummaries);
const projectSummariesWithCache = await audit_report.createProjectSummariesSheet(periodId, domain, tenantId, cachedData.projectSummaries);
expect(JSON.stringify(projectSummariesNoCache)).to.equal(JSON.stringify(projectSummariesWithCache));

const projectSummaryGroupedByProjectStub = sandbox.stub(audit_report, 'getReportsGroupedByProjectData');
projectSummaryGroupedByProjectStub.returns(allData.projectSummaryGroupedByProject);
const projectSummaryGroupedByProjectNoCache = await audit_report.createReportsGroupedByProjectSheet(periodId, tenantId, null);
projectSummaryGroupedByProjectStub.returns(dataWithCache.projectSummaryGroupedByProject);
const projectSummaryGroupedByProjectWithCache = await audit_report.createReportsGroupedByProjectSheet(periodId, tenantId, cachedData.projectSummaryGroupedByProject);
expect(JSON.stringify(projectSummaryGroupedByProjectNoCache)).to.equal(JSON.stringify(projectSummaryGroupedByProjectWithCache));

const kpiDataStub = sandbox.stub(audit_report, 'getKpiDataGroupedByProjectData');
kpiDataStub.returns(allData.KPIDataGroupedByProject);
const kpiDataNoCache = await audit_report.createKpiDataGroupedByProjectSheet(periodId, tenantId, null);
kpiDataStub.returns(dataWithCache.KPIDataGroupedByProject);
const kpiDataWithCache = await audit_report.createKpiDataGroupedByProjectSheet(periodId, tenantId, cachedData.KPIDataGroupedByProject);
expect(JSON.stringify(kpiDataNoCache)).to.equal(JSON.stringify(kpiDataWithCache));
});

it('headers should be in the proper order', () => {
const projects = [{
'09-30-2021 Total Aggregate Expenditures': 150000,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const assert = require('assert');

const { generateReport } = require('../../../../src/arpa_reporter/services/generate-arpa-report');
const { generate } = require('../../../../src/arpa_reporter/lib/audit-report');
const { withTenantId } = require('../helpers/with-tenant-id');

describe('arpa report generation', () => {
Expand All @@ -12,12 +11,4 @@ describe('arpa report generation', () => {
});
});

describe('audit report generation', () => {
it('generates a report', async () => {
const tenantId = 0;
const report = await withTenantId(tenantId, () => generate('http://localhost'));
assert.ok(report);
});
});

// NOTE: This file was copied from tests/server/services/generate-arpa-report.spec.js (git @ ada8bfdc98) in the arpa-reporter repo on 2022-09-23T20:05:47.735Z
Loading
Loading