diff --git a/src/migrations/20210315234158-seed-non-grantee-recipients.js b/src/migrations/20210315234158-seed-non-grantee-recipients.js new file mode 100644 index 0000000000..01bd79cd5f --- /dev/null +++ b/src/migrations/20210315234158-seed-non-grantee-recipients.js @@ -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, {}), +}; diff --git a/src/seeders/20210107170250-nonGrantees.js b/src/seeders/20210107170250-nonGrantees.js deleted file mode 100644 index 7bee280c9d..0000000000 --- a/src/seeders/20210107170250-nonGrantees.js +++ /dev/null @@ -1,45 +0,0 @@ -const 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', - }, -]; - -module.exports = { - up: async (queryInterface) => { - await queryInterface.bulkInsert('NonGrantees', nonGrantees, {}); - }, - - down: async (queryInterface) => { - await queryInterface.bulkDelete('NonGrantees', null, {}); - }, -}; diff --git a/src/services/activityReports.js b/src/services/activityReports.js index c1b6774e0f..4455b1af52 100644 --- a/src/services/activityReports.js +++ b/src/services/activityReports.js @@ -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, diff --git a/src/services/activityReports.test.js b/src/services/activityReports.test.js index df789c8a60..6bb27e2742 100644 --- a/src/services/activityReports.test.js +++ b/src/services/activityReports.test.js @@ -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' }); }); @@ -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); }); }); });