Skip to content

Commit

Permalink
stab at feature-gating
Browse files Browse the repository at this point in the history
  • Loading branch information
masimons committed Sep 17, 2024
1 parent 32a4bc3 commit 15e2749
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/client/public/deploy-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ window.APP_CONFIG.featureFlags = {
newGrantsDetailPageEnabled: true,
shareTerminologyEnabled: true,
followNotesEnabled: true,
showForecastedGrants: true,
};

// Setting a GOOGLE_TAG_ID enables Google Analytics.
Expand Down
4 changes: 4 additions & 0 deletions packages/client/src/helpers/featureFlags/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ export function shareTerminologyEnabled() {
export function followNotesEnabled() {
return getFeatureFlags().followNotesEnabled === true;
}

export function showForecastedGrants() {
return getFeatureFlags().showForecastedGrants === true;
}
17 changes: 14 additions & 3 deletions packages/server/src/db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check failure on line 27 in packages/server/src/db/index.js

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Use object destructuring

Check failure on line 27 in packages/server/src/db/index.js

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Unable to resolve path to module './helpers/featureFlags'

Check failure on line 27 in packages/server/src/db/index.js

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Missing file extension for "./helpers/featureFlags"

async function getUsers(tenantId) {
const users = await knex('users')
Expand Down Expand Up @@ -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') })

Check failure on line 354 in packages/server/src/db/index.js

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Missing semicolon
} else {
qb.where({ open_date: moment().subtract(1, 'day').format('YYYY-MM-DD') })
.whereNot({ opportunity_status: 'forecasted' });

Check failure on line 357 in packages/server/src/db/index.js

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Expected indentation of 20 spaces but found 16
}
})
.limit(3);

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions terraform/prod.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions terraform/staging.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 15e2749

Please sign in to comment.