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

fix: pagination and audit report #1831

Merged
merged 5 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 10 additions & 3 deletions packages/client/src/components/GrantsTableNext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,17 @@
</b-row>
<b-row align-v="center">
<b-col cols="12" class="d-flex">
<b-pagination class="m-0" v-model="currentPage" :total-rows="totalRows" :per-page="perPage" first-number
last-number first-text="First" prev-text="Prev" next-text="Next" last-text="Last"
<b-pagination
class="m-0"
v-model="currentPage"
:total-rows="totalRows"
:per-page="perPage"
first-text="First"
prev-text="Prev"
next-text="Next"
last-text="Last"
aria-controls="grants-table" />
<div class="ml-2 border border-light rounded text-justify p-2 page-item">{{ grants.length }} of {{ totalRows }}</div>
<div class="ml-2 border border-light rounded text-justify p-2 page-item">{{ totalRows }} total grants</div>
</b-col>
</b-row>
<GrantDetails :selected-grant.sync="selectedGrant" />
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/arpa_reporter/lib/audit-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down
12 changes: 7 additions & 5 deletions packages/server/src/db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ async function buildKeywordQuery(queryBuilder, includeKeywords, excludeKeywords)
}
}

async function buildFiltersQuery(queryBuilder, filters) {
async function buildFiltersQuery(queryBuilder, filters, agencyId) {
const statusMap = {
Applied: 'Result',
'Not Applying': 'Rejected',
Expand All @@ -479,6 +479,7 @@ 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);
Expand Down Expand Up @@ -524,11 +525,12 @@ 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) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function getGrantsNew has 5 arguments (exceeds 4 allowed). Consider refactoring.

console.log(filters, paginationParams, orderingParams, tenantId, agencyId);
const { data, pagination } = await knex(TABLES.grants)
.select(`${TABLES.grants}.*`)
.distinct()
Expand All @@ -544,7 +546,7 @@ async function getGrantsNew(filters, paginationParams, orderingParams, tenantId)

await buildKeywordQuery(queryBuilder, filters.includeKeywords, filters.excludeKeywords);
console.log('here 1');
await buildFiltersQuery(queryBuilder, filters);
await buildFiltersQuery(queryBuilder, filters, agencyId);
console.log('here 2');
}
if (orderingParams.orderBy && orderingParams.orderBy !== 'undefined') {
Expand Down
1 change: 1 addition & 0 deletions packages/server/src/routes/grants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down