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

feat(grants): forecasted UI seed data - MERGE AFTER PR # 3456 #3631

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
37 changes: 29 additions & 8 deletions packages/server/__tests__/db/db.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ describe('db', () => {
});
it('gets grants with agency codes', async () => {
const result = await db.getGrantsNew(
{ agencyCode: 'HHS' },
{ agencyCode: 'HHS', opportunityStatuses: ['posted', 'closed'] },
{ currentPage: 1, perPage: 10, isLengthAware: true },
{ orderBy: 'open_date', orderDesc: 'true' },
fixtures.tenants.SBA.id,
Expand All @@ -460,7 +460,7 @@ describe('db', () => {
});
it('gets grants that either have or do not have cost sharing', async () => {
const result = await db.getGrantsNew(
{ costSharing: 'Yes' },
{ costSharing: 'Yes', opportunityStatuses: ['posted', 'closed'] },
{ currentPage: 1, perPage: 10, isLengthAware: true },
{ orderBy: 'open_date', orderDesc: 'true' },
fixtures.tenants.SBA.id,
Expand All @@ -471,7 +471,7 @@ describe('db', () => {
expect(result.pagination.lastPage).to.equal(0);

const result2 = await db.getGrantsNew(
{ costSharing: 'No' },
{ costSharing: 'No', opportunityStatuses: ['posted', 'closed'] },
{ currentPage: 1, perPage: 3, isLengthAware: true },
{ orderBy: 'open_date', orderDesc: 'true' },
fixtures.tenants.SBA.id,
Expand All @@ -483,7 +483,7 @@ describe('db', () => {
});
it('gets grants with a specific opportunity categories', async () => {
const result = await db.getGrantsNew(
{ opportunityCategories: ['Mandatory', 'Continuation'] },
{ opportunityCategories: ['Mandatory', 'Continuation'], opportunityStatuses: ['posted', 'closed'] },
{ currentPage: 1, perPage: 10, isLengthAware: true },
{ orderBy: 'open_date', orderDesc: 'true' },
fixtures.tenants.SBA.id,
Expand All @@ -494,7 +494,7 @@ describe('db', () => {
expect(result.pagination.lastPage).to.equal(0);

const result2 = await db.getGrantsNew(
{ opportunityCategories: ['Discretionary', 'Other'] },
{ opportunityCategories: ['Discretionary', 'Other'], opportunityStatuses: ['posted', 'closed'] },
{ currentPage: 1, perPage: 4, isLengthAware: true },
{ orderBy: 'open_date', orderDesc: 'true' },
fixtures.tenants.SBA.id,
Expand Down Expand Up @@ -533,7 +533,7 @@ describe('db', () => {
});
it('gets grants that have any of the eligibility codes', async () => {
const result = await db.getGrantsNew(
{ eligibilityCodes: ['11', '07'] },
{ eligibilityCodes: ['11', '07'], opportunityStatuses: ['posted', 'closed'] },
{ currentPage: 1, perPage: 10, isLengthAware: true },
{ orderBy: 'open_date', orderDesc: 'true' },
fixtures.tenants.SBA.id,
Expand Down Expand Up @@ -612,6 +612,7 @@ describe('db', () => {
let result = await db.getGrantsNew(
{
includeKeywords: ['community', 'health'],
opportunityStatuses: ['posted', 'closed'],
},
{ currentPage: 1, perPage: 10, isLengthAware: true },
{ orderBy: 'open_date', orderDesc: true },
Expand All @@ -626,6 +627,7 @@ describe('db', () => {
{
includeKeywords: ['community', 'health'],
excludeKeywords: ['covid'],
opportunityStatuses: ['posted', 'closed'],
},
{ currentPage: 1, perPage: 10, isLengthAware: true },
{ orderBy: 'open_date', orderDesc: true },
Expand All @@ -646,7 +648,7 @@ describe('db', () => {
});
it('check award_ceiling ordering is correct for blank and zero award ceiling desc', async () => {
const result = await db.getGrantsNew(
{ agencyCode: 'HHS' },
{ agencyCode: 'HHS', opportunityStatuses: ['posted', 'closed'] },
{ currentPage: 1, perPage: 10, isLengthAware: true },
{ orderBy: 'award_ceiling', orderDesc: 'true' },
fixtures.tenants.SBA.id,
Expand All @@ -658,7 +660,7 @@ describe('db', () => {
});
it('check award_ceiling ordering is correct for blank and zero award ceiling asc', async () => {
const result = await db.getGrantsNew(
{ agencyCode: 'HHS' },
{ agencyCode: 'HHS', opportunityStatuses: ['posted', 'closed'] },
{ currentPage: 1, perPage: 10, isLengthAware: true },
{ orderBy: 'award_ceiling', orderDesc: 'false' },
fixtures.tenants.SBA.id,
Expand Down Expand Up @@ -1119,4 +1121,23 @@ describe('db', () => {
expect(usdrUserViewedRecord.updated_at.getTime()).to.equal(new Date('2024-01-01').getTime());
});
});

context('forecasted grants', () => {
it('gets grants with opportunity forecasted', async () => {
const result = await db.getGrants({
tenantId: fixtures.users.staffUser.tenant_id,
filters: {
opportunityStatuses: ['forecasted'],
},
perPage: 50,
currentPage: 1,
});

expect(result).to.have.property('data').with.lengthOf(4);
expect(result.data[0].close_date).to.be.null;
expect(result.data[0].close_date_explanation).to.equal('Sample text for null close_date');
expect(result.data[2].close_date).to.be.null;
expect(result.data[2].open_date).to.be.null;
});
});
});
215 changes: 215 additions & 0 deletions packages/server/__tests__/db/seeds/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,220 @@ const grants = {
},
};

const forecastedGrants = {
hasCloseDateExplanation: {
status: 'inbox',
grant_id: '284822',
grant_number: 'CDC-RFA-PS16-1606',
agency_code: 'HHS-CDC-NCHHSTP',
award_ceiling: '325000',
cost_sharing: 'No',
title: 'Comprehensive High-Impact HIV Prevention Projects for Young Men of Color Who Have Sex with Men and Young Transgender Persons of Color',
cfda_list: '47.050',
open_date: '2055-08-11',
close_date: null,
close_date_explanation: 'Sample text for null close_date',
notes: 'auto-inserted by script',
search_terms: '[in title/desc]+',
reviewer_name: 'none',
opportunity_category: 'Discretionary',
description: '<p class="MsoNormal">The Centers for Disease Control and Prevention announces the availability of fiscal year 2055 funds for a cooperative agreement program for community-based organizations (CBOs) to develop and implement High-Impact Human Immunodeficiency Virus (HIV) Prevention Programs.</p>',
eligibility_codes: '12',
funding_activity_category_codes: 'HL',
opportunity_status: 'forecasted',
raw_body_json: {
opportunity: {
id: '284822',
number: 'CDC-RFA-PS16-1606',
title: 'Comprehensive High-Impact HIV Prevention Projects for Young Men of Color Who Have Sex with Men and Young Transgender Persons of Color',
description: '<p class="MsoNormal">The Centers for Disease Control and Prevention announces the availability of fiscal year 2055 funds for a cooperative agreement program for community-based organizations (CBOs) to develop and implement High-Impact Human Immunodeficiency Virus (HIV) Prevention Programs.</p>',
milestones: {
post_date: '2055-08-11',
close: {
date: null,
},
},
category: { code: 'D', name: 'Discretionary' },
},
agency: { code: 'HHS-CDC-NCHHSTP' },
award: { ceiling: '325000' },
cost_sharing_or_matching_requirement: false,
cfda_numbers: ['47.050'],
eligible_applicants: [
{ code: '12' },
],
funding_activity: {
categories: [
{
name: 'Health',
code: 'HL',
},
],
},
},
created_at: '2021-08-11 11:30:38.89828-07',
updated_at: '2021-08-11 12:30:39.531-07',
},
hasCloseAndOpenDates: {
status: 'inbox',
grant_id: '284810',
grant_number: 'HHS-2016-IHS-UIHP1-0001',
agency_code: 'HHS-IHS',
award_ceiling: '500000',
cost_sharing: 'No',
title: 'Office of Urban Indian Health Program - Title V HIV/AIDS',
cfda_list: '93.193',
open_date: '2056-08-05',
close_date: '2076-09-06',
notes: 'auto-inserted by script',
search_terms: '[in title/desc]+',
reviewer_name: 'none',
opportunity_category: 'Discretionary',
description: '<p>The Indian Health Service is accepting limited competitive grant applications for the Office of Urban Indian Health Programs Title V HIV/AIDS program. </p>',
eligibility_codes: '11 07 25',
funding_activity_category_codes: 'HL',
opportunity_status: 'forecasted',
raw_body_json: {
opportunity: {
id: '284810',
number: 'HHS-2016-IHS-UIHP1-0001',
title: 'Office of Urban Indian Health Program - Title V HIV/AIDS',
description: '<p>The Indian Health Service is accepting limited competitive grant applications for the Office of Urban Indian Health Programs Title V HIV/AIDS program. </p>',
milestones: {
post_date: '2056-08-05',
},
category: { code: 'D', name: 'Discretionary' },
},
agency: { code: 'HHS-IHS' },
award: { ceiling: '500000' },
cost_sharing_or_matching_requirement: false,
cfda_numbers: ['93.193'],
eligible_applicants: [
{ code: '11' }, { code: '07' }, { code: '25' },
],
funding_activity: {
categories: [
{
name: 'Health',
code: 'HL',
},
],
},
revision: { id: 'c3' },
},
created_at: '2021-08-06 16:03:53.57025-07',
updated_at: '2021-08-11 12:35:42.562-07',
revision_id: 'c3',
},
nullOpenAndCloseDates: {
status: 'inbox',
grant_id: '284793',
grant_number: 'TI-16-005',
agency_code: 'HHS-SAMHS',
award_ceiling: '500000',
cost_sharing: 'No',
title: 'Cooperative Agreement to Support the Establishment of a Ukraine HIV International Addiction Technology Transfer Center (UHATTC)',
cfda_list: '93.243',
open_date: null,
close_date: null,
notes: 'auto-inserted by script',
search_terms: '[in title/desc]+',
reviewer_name: 'none',
opportunity_category: 'Discretionary',
description: '<p>The purpose of this program is to establish an internationally-based ATTC in Ukraine that primarily builds the capacity and increases the skills and abilities of healthcare providers of the national Ukraine HIV/AIDS program/</p>',
eligibility_codes: '25',
funding_activity_category_codes: 'HL ISS',
opportunity_status: 'forecasted',
raw_body_json: {
opportunity: {
id: '284793',
number: 'TI-16-005',
title: 'Cooperative Agreement to Support the Establishment of a Ukraine HIV International Addiction Technology Transfer Center (UHATTC)',
description: '<p>The purpose of this program is to establish an internationally-based ATTC in Ukraine that primarily builds the capacity and increases the skills and abilities of healthcare providers of the national Ukraine HIV/AIDS program/</p>',
milestones: {
post_date: '2021-08-05',
},
category: { code: 'D', name: 'Discretionary' },
},
agency: { code: 'HHS-SAMHS' },
award: { ceiling: '250000' },
cost_sharing_or_matching_requirement: false,
cfda_numbers: ['93.243'],
eligible_applicants: [
{ code: '25' },
],
funding_activity: {
categories: [
{
name: 'Health',
code: 'HL',
},
{
name: 'Income Security and Social Services',
code: 'ISS',
},
],
},
revision: { id: 'c3' },
},
created_at: '2021-08-06 16:03:53.57025-07',
updated_at: '2021-08-11 12:35:42.562-07',
revision_id: 'c3',
},
validOpenAndCloseDates: {
status: 'inbox',
grant_id: '284769',
grant_number: 'PA-FPT-002',
agency_code: 'HHS-OPHS',
award_ceiling: '4000000',
cost_sharing: 'No',
title: 'Anticipated Availability of funds for Title X Family Planning Training Cooperative Agreements',
cfda_list: '93.260',
open_date: '2046-08-05',
close_date: '2046-09-06',
close_date_explanation: 'Sample text - close_date has valid date',
notes: 'auto-inserted by script',
search_terms: '[in title/desc]+',
reviewer_name: 'none',
opportunity_category: 'Discretionary',
description: ' <p>The overarching goal of these training and technical assistance projects is to improve reproductive health outcomes for men, women and adolescents by reducing unplanned pregnancies, improving efforts to plan and space pregnancies through counseling, lower the rates of STDs, and improving birth outcomes. <p>',
eligibility_codes: '11 07 25',
funding_activity_category_codes: 'HL',
opportunity_status: 'forecasted',
raw_body_json: {
opportunity: {
id: '284769',
number: 'PA-FPT-002',
title: 'Anticipated Availability of funds for Title X Family Planning Training Cooperative Agreements',
description: ' <p>The overarching goal of these training and technical assistance projects is to improve reproductive health outcomes for men, women and adolescents by reducing unplanned pregnancies, improving efforts to plan and space pregnancies through counseling, lower the rates of STDs, and improving birth outcomes. <p>',
milestones: {
post_date: '2021-08-05',
},
category: { code: 'D', name: 'Discretionary' },
},
agency: { code: 'HHS-OPHS' },
award: { ceiling: '4000000' },
cost_sharing_or_matching_requirement: false,
cfda_numbers: ['93.260'],
eligible_applicants: [
{ code: '00' }, { code: '01' }, { code: '02' },
],
funding_activity: {
categories: [
{
name: 'Health',
code: 'HL',
},
],
},
revision: { id: 'c3' },
},
created_at: '2021-08-06 16:03:53.57025-07',
updated_at: '2021-08-11 12:35:42.562-07',
revision_id: 'c3',
},
};

const grantsInterested = {
entry1: {
agency_id: agencies.accountancy.id,
Expand Down Expand Up @@ -581,4 +795,5 @@ module.exports.seed = async (knex) => {
await knex(TABLES.grants_interested).insert(Object.values(grantsInterested));
await knex(TABLES.grants_saved_searches).insert(Object.values(grantsSavedSearches));
await knex(TABLES.grants_viewed).insert(Object.values(grantsViewed));
await knex(TABLES.grants).insert(Object.values(forecastedGrants));
};
14 changes: 14 additions & 0 deletions packages/server/seeds/dev/03_add_forecasted_grants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// require('dotenv').config();

const {
forecastedGrants, assignedForecastedGrantsAgency,
} = require('./ref/forecastedGrants');

const seed = async (knex) => {
await knex('grants').insert(forecastedGrants);
await knex('assigned_grants_agency').insert(assignedForecastedGrantsAgency);
};

module.exports = {
seed,
};
Loading
Loading