diff --git a/packages/client/public/deploy-config.js b/packages/client/public/deploy-config.js index 1dcdafedf3..557261f293 100644 --- a/packages/client/public/deploy-config.js +++ b/packages/client/public/deploy-config.js @@ -27,6 +27,7 @@ window.APP_CONFIG.featureFlags = { newGrantsDetailPageEnabled: true, shareTerminologyEnabled: true, followNotesEnabled: true, + showForecastedGrants: true, }; // Setting a GOOGLE_TAG_ID enables Google Analytics. diff --git a/packages/client/src/helpers/featureFlags/index.js b/packages/client/src/helpers/featureFlags/index.js index 7fa1d46553..e186765b8f 100644 --- a/packages/client/src/helpers/featureFlags/index.js +++ b/packages/client/src/helpers/featureFlags/index.js @@ -15,3 +15,7 @@ export function shareTerminologyEnabled() { export function followNotesEnabled() { return getFeatureFlags().followNotesEnabled === true; } + +export function showForecastedGrants() { + return getFeatureFlags().showForecastedGrants === true; +} diff --git a/packages/server/src/db/index.js b/packages/server/src/db/index.js index 3671260754..7e8f738499 100755 --- a/packages/server/src/db/index.js +++ b/packages/server/src/db/index.js @@ -24,6 +24,7 @@ const { TABLES } = require('./constants'); const emailConstants = require('../lib/email/constants'); const { fundingActivityCategoriesByCode } = require('../lib/fieldConfigs/fundingActivityCategories'); const helpers = require('./helpers'); +const showForecastedGrants = require('./helpers/featureFlags').showForecastedGrants; async function getUsers(tenantId) { const users = await knex('users') @@ -349,8 +350,12 @@ async function getNewGrantsForAgency(agency) { .select(knex.raw(`${TABLES.grants}.*, count(*) OVER() AS total_grants`)) .modify(helpers.whereAgencyCriteriaMatch, agencyCriteria) .modify((qb) => { - qb.where({ open_date: moment().subtract(1, 'day').format('YYYY-MM-DD') }) + if (showForecastedGrants) { + qb.where({ open_date: moment().subtract(1, 'day').format('YYYY-MM-DD') }) + } else { + qb.where({ open_date: moment().subtract(1, 'day').format('YYYY-MM-DD') }) .whereNot({ opportunity_status: 'forecasted' }); + } }) .limit(3); @@ -763,7 +768,6 @@ async function getGrantsNew(filters, paginationParams, orderingParams, tenantId, .select(knex.raw(` count(*) OVER() AS full_count `)) - .whereNot({ opportunity_status: 'forecasted' }) .groupBy( 'grants.grant_id', 'grants.grant_number', @@ -792,6 +796,9 @@ async function getGrantsNew(filters, paginationParams, orderingParams, tenantId, 'grants.bill', 'grants.funding_activity_category_codes', ); + if (!showForecastedGrants) { + query.whereNot({ opportunity_status: 'forecasted' }); + } if (toCsv) { query.modify(addCsvData); } @@ -847,7 +854,11 @@ async function getGrants({ currentPage, perPage, tenantId, filters, orderBy, searchTerm, orderDesc, } = {}) { const data = await knex(TABLES.grants) - .whereNot(`${TABLES.grants}.opportunity_status`, 'forecasted') + .modify((queryBuilder) => { + if (!showForecastedGrants) { + queryBuilder.whereNot(`${TABLES.grants}.opportunity_status`, 'forecasted'); + } + }) .modify((queryBuilder) => { if (searchTerm && searchTerm !== 'null') { queryBuilder.andWhere( diff --git a/terraform/prod.tfvars b/terraform/prod.tfvars index 951b2a696b..ab2c525f24 100644 --- a/terraform/prod.tfvars +++ b/terraform/prod.tfvars @@ -52,6 +52,7 @@ website_feature_flags = { newGrantsDetailPageEnabled = true, shareTerminologyEnabled = true, followNotesEnabled = false, + showForecastedGrants = false, } // Google Analytics Account ID: 233192355, Property ID: 321194851, Stream ID: 3802896350 diff --git a/terraform/staging.tfvars b/terraform/staging.tfvars index e38ad49cd4..257d222345 100644 --- a/terraform/staging.tfvars +++ b/terraform/staging.tfvars @@ -51,6 +51,7 @@ website_feature_flags = { newGrantsDetailPageEnabled = true, shareTerminologyEnabled = true, followNotesEnabled = false, + showForecastedGrants = true, } // Google Analytics Account ID: 233192355, Property ID: 429910307, Stream ID: 7590745080