Skip to content

Commit

Permalink
Merge pull request #245 from adhocteam/active-grants-only
Browse files Browse the repository at this point in the history
Return active grants only
  • Loading branch information
rahearn authored Mar 16, 2021
2 parents 14abd07 + 479d9d4 commit 2e351ea
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 49 deletions.
19 changes: 19 additions & 0 deletions src/migrations/20210315234158-seed-non-grantee-recipients.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
up: (queryInterface) => queryInterface.bulkInsert('NonGrantees', [
{ name: 'CCDF / Child Care Administrator' },
{ name: 'Head Start Collaboration Office' },
{ name: 'QRIS System' },
{ name: 'Regional Head Start Association' },
{ name: 'Regional TTA/Other Specialists' },
{ name: 'State CCR&R' },
{ name: 'State Early Learning Standards' },
{ name: 'State Education System' },
{ name: 'State Health System' },
{ name: 'State Head Start Association' },
{ name: 'State Professional Development / Continuing Education' },
],
{
ignoreDuplicates: true,
}),
down: (queryInterface) => queryInterface.bulkDelete('Regions', null, {}),
};
45 changes: 0 additions & 45 deletions src/seeders/20210107170250-nonGrantees.js

This file was deleted.

6 changes: 5 additions & 1 deletion src/services/activityReports.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,14 @@ export async function setStatus(report, status) {
* @returns {*} Grants and Non grantees
*/
export async function possibleRecipients(regionId) {
const where = regionId ? { regionId } : undefined;
let where = { status: 'Active' };
if (regionId) {
where = { ...where, regionId };
}

const grants = await Grantee.findAll({
attributes: ['id', 'name'],
order: ['name'],
include: [{
where,
model: Grant,
Expand Down
5 changes: 2 additions & 3 deletions src/services/activityReports.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('Activity Reports DB service', () => {
grantee = await Grantee.create({ id: RECIPIENT_ID, name: 'grantee', regionId: 17 });
await Region.create({ name: 'office 17', id: 17 });
await Grant.create({
id: RECIPIENT_ID, number: 1, granteeId: grantee.id, regionId: 17,
id: RECIPIENT_ID, number: 1, granteeId: grantee.id, regionId: 17, status: 'Active',
});
await NonGrantee.create({ id: RECIPIENT_ID, name: 'nonGrantee' });
});
Expand Down Expand Up @@ -454,8 +454,7 @@ describe('Activity Reports DB service', () => {

it('retrieves all recipients when not specifying region', async () => {
const recipients = await possibleRecipients();
const grantees = await Grantee.findAll();
expect(recipients.grants.length).toBe(grantees.length);
expect(recipients.grants.length).toBe(11);
});
});
});

0 comments on commit 2e351ea

Please sign in to comment.