diff --git a/packages/client/src/components/GrantsTableNext.vue b/packages/client/src/components/GrantsTableNext.vue index 352f09bd9..ab7a30336 100644 --- a/packages/client/src/components/GrantsTableNext.vue +++ b/packages/client/src/components/GrantsTableNext.vue @@ -59,10 +59,17 @@ - -
{{ grants.length }} of {{ totalRows }}
+
{{ totalRows }} total grant{{ totalRows == 1 ? '' : 's' }}
diff --git a/packages/server/src/arpa_reporter/lib/audit-report.js b/packages/server/src/arpa_reporter/lib/audit-report.js index 7a4b67f33..97e8b0617 100644 --- a/packages/server/src/arpa_reporter/lib/audit-report.js +++ b/packages/server/src/arpa_reporter/lib/audit-report.js @@ -251,7 +251,7 @@ async function generate(requestHost) { XLSX.utils.book_append_sheet(newWorkbook, sheet1, 'Obligations & Expenditures'); XLSX.utils.book_append_sheet(newWorkbook, sheet2, 'Project Summaries'); XLSX.utils.book_append_sheet(newWorkbook, sheet3, 'Project Summaries V2'); - XLSX.utils.book_append_sheet(workbook, sheet4, 'KPI'); + XLSX.utils.book_append_sheet(newWorkbook, sheet4, 'KPI'); return newWorkbook; }); diff --git a/packages/server/src/db/index.js b/packages/server/src/db/index.js index 626251d65..7ae39dcd9 100755 --- a/packages/server/src/db/index.js +++ b/packages/server/src/db/index.js @@ -439,7 +439,7 @@ function buildTsqExpression(includeKeywords, excludeKeywords) { return keywords.expressions; } -async function buildKeywordQuery(queryBuilder, includeKeywords, excludeKeywords) { +function buildKeywordQuery(queryBuilder, includeKeywords, excludeKeywords) { const tsqExpression = buildTsqExpression(includeKeywords, excludeKeywords); if (tsqExpression.phrase) { queryBuilder.joinRaw(`cross join phraseto_tsquery('english', ?) as tsqp`, tsqExpression.phrase); @@ -459,7 +459,7 @@ async function buildKeywordQuery(queryBuilder, includeKeywords, excludeKeywords) } } -async function buildFiltersQuery(queryBuilder, filters) { +function buildFiltersQuery(queryBuilder, filters, agencyId) { const statusMap = { Applied: 'Result', 'Not Applying': 'Rejected', @@ -479,9 +479,9 @@ async function buildFiltersQuery(queryBuilder, filters) { if (filters.reviewStatuses?.length) { const statuses = filters.reviewStatuses.map((status) => statusMap[status]); qb.whereIn(`${TABLES.interested_codes}.status_code`, statuses); + qb.where(`${TABLES.grants_interested}.agency_id`, '=', agencyId); } if (parseInt(filters.assignedToAgencyId, 10) >= 0) { - console.log(filters.assignedToAgencyId); qb.where(`${TABLES.assigned_grants_agency}.agency_id`, '=', filters.assignedToAgencyId); } if (filters.opportunityStatuses?.length) { @@ -524,15 +524,16 @@ async function buildFiltersQuery(queryBuilder, filters) { bill: String, }, paginationParams: { currentPage: number, perPage: number, isLengthAware: boolean }, - orderingParams: { orderBy: List[string], orderDesc: boolean} + orderingParams: { orderBy: List[string], orderDesc: boolean}, tenantId: number + agencyId: number */ -async function getGrantsNew(filters, paginationParams, orderingParams, tenantId) { - console.log(filters, paginationParams, orderingParams, tenantId); +async function getGrantsNew(filters, paginationParams, orderingParams, tenantId, agencyId) { + console.log(filters, paginationParams, orderingParams, tenantId, agencyId); const { data, pagination } = await knex(TABLES.grants) .select(`${TABLES.grants}.*`) .distinct() - .modify(async (queryBuilder) => { + .modify((queryBuilder) => { if (filters) { if (filters.reviewStatuses?.length) { queryBuilder.join(TABLES.grants_interested, `${TABLES.grants}.grant_id`, `${TABLES.grants_interested}.grant_id`) @@ -541,51 +542,8 @@ async function getGrantsNew(filters, paginationParams, orderingParams, tenantId) if (parseInt(filters.assignedToAgencyId, 10) >= 0) { queryBuilder.join(TABLES.assigned_grants_agency, `${TABLES.grants}.grant_id`, `${TABLES.assigned_grants_agency}.grant_id`); } - -<<<<<<< HEAD - /* - TODO: add grants.opportunity_number - if (filters.opportunityNumber) { - qb.where(`${TABLES.grants}.opportunity_number`, '=', filters.opportunityNumber); - } - - TODO: add grants.funding_instrument_codes - { 'CA': 'Cooperative Agreement', 'G': 'Grant', 'PC': 'Procurement Contract', 'O': 'Other' } - if (filters.fundingTypes) { - qb.where('funding_instrument_codes', '~', filters.fundingTypes.join('|')); - } - */ - if (filters.reviewStatuses?.length) { - for (const status in filters.reviewStatuses) { - qb.where(`${TABLES.interested_codes}.status_code`, '=', status); - } - } - if (filters.opportunityStatuses?.length) { - qb.whereIn(`${TABLES.grants}.opportunity_status`, filters.opportunityStatuses); - } - if (filters.opportunityCategories?.length) { - qb.whereIn(`${TABLES.grants}.opportunity_category`, filters.opportunityCategories); - } - if (filters.costSharing) { - qb.where(`${TABLES.grants}.cost_sharing`, '=', filters.costSharing); - } - if (filters.agencyCode) { - qb.where(`${TABLES.grants}.agency_code`, '=', filters.agencyCode); - } - if (filters.openDate) { - qb.where(`${TABLES.grants}.open_date`, '=', filters.openDate); - } else if (filters.postedWithinDays > 0) { - const date = moment().subtract(filters.postedWithinDays, 'days').startOf('day').format('YYYY-MM-DD'); - qb.where(`${TABLES.grants}.open_date`, '>=', date); - } - }, - ); -======= - await buildKeywordQuery(queryBuilder, filters.includeKeywords, filters.excludeKeywords); - console.log('here 1'); - await buildFiltersQuery(queryBuilder, filters); - console.log('here 2'); ->>>>>>> 1f415725 (fix: initial search adjustments 815 review (#1826)) + buildKeywordQuery(queryBuilder, filters.includeKeywords, filters.excludeKeywords); + buildFiltersQuery(queryBuilder, filters, agencyId); } if (orderingParams.orderBy && orderingParams.orderBy !== 'undefined') { if (orderingParams.orderBy.includes('interested_agencies')) { diff --git a/packages/server/src/routes/grants.js b/packages/server/src/routes/grants.js index 878423795..05fc514ef 100755 --- a/packages/server/src/routes/grants.js +++ b/packages/server/src/routes/grants.js @@ -91,6 +91,7 @@ router.get('/next', requireUser, async (req, res) => { await db.buildPaginationParams(req.query.pagination), await db.buildOrderingParams(req.query.ordering), user.tenant_id, + user.agency_id, ); res.json(grants);