From f1369dd0e00e80c9fdca3c4d9154067513016967 Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Mon, 8 Jan 2024 09:28:40 -0700 Subject: [PATCH 1/2] Fixing NARS Dis filenames --- src/api/controllers/admin/reporting-controller.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/controllers/admin/reporting-controller.ts b/src/api/controllers/admin/reporting-controller.ts index d28ffe44..315122a0 100644 --- a/src/api/controllers/admin/reporting-controller.ts +++ b/src/api/controllers/admin/reporting-controller.ts @@ -154,13 +154,13 @@ export default class ReportingController extends BaseController { if (this.format == "html") { this.response.send(reportData); } else if (this.format == "csv") { - this.response.setHeader("Content-disposition", `attachment; filename="PPYT.CSLS.PT_NARS_2223.001.csv"`); + this.response.setHeader("Content-disposition", `attachment; filename="PPYT.CSLS.PDEXPAND_2223.${moment().format("YYYY-MM-DD")}.csv"`); this.response.setHeader("Content-type", "text/csv"); this.response.send(reportData); } else if (this.format == "json") { this.response.json(reportData); } else { - this.response.setHeader("Content-disposition", `attachment; filename="PPYT.CSLS.PT_NARS_2223.001.txt"`); + this.response.setHeader("Content-disposition", `attachment; filename="PPYT.CSLS.PDEXPAND_2223.${moment().format("YYYY-MM-DD")}.txt"`); this.response.setHeader("Content-type", "text/plain"); this.response.send(reportData); } @@ -175,13 +175,13 @@ export default class ReportingController extends BaseController { if (this.format == "html") { this.response.send(reportData); } else if (this.format == "csv") { - this.response.setHeader("Content-disposition", `attachment; filename="PPYT.CSLS.PT_NARS_2223.001.csv"`); + this.response.setHeader("Content-disposition", `attachment; filename="PPYT.CSLS.PDReducedCourseLoad_2223.${moment().format("YYYY-MM-DD")}.csv"`); this.response.setHeader("Content-type", "text/csv"); this.response.send(reportData); } else if (this.format == "json") { this.response.json(reportData); } else { - this.response.setHeader("Content-disposition", `attachment; filename="PPYT.CSLS.PT_NARS_2223.001.txt"`); + this.response.setHeader("Content-disposition", `attachment; filename="PPYT.CSLS.PDReducedCourseLoad_2223.${moment().format("YYYY-MM-DD")}.txt"`); this.response.setHeader("Content-type", "text/plain"); this.response.send(reportData); } From fb5b39806aa0a5a1d02f47d8f5955a080067662f Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Mon, 8 Jan 2024 10:18:01 -0700 Subject: [PATCH 2/2] Using latest assessment to remove dups --- src/api/services/admin/nars-dis-reporting-service.ts | 1 + src/api/services/admin/nars-disft-reporting-service.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/services/admin/nars-dis-reporting-service.ts b/src/api/services/admin/nars-dis-reporting-service.ts index 53434f90..627b3e00 100644 --- a/src/api/services/admin/nars-dis-reporting-service.ts +++ b/src/api/services/admin/nars-dis-reporting-service.ts @@ -50,6 +50,7 @@ export class NarsDisabilityReportingService { INNER JOIN sfa.institution ON (institution.id = institution_campus.institution_id) INNER JOIN (SELECT SUM(COALESCE(disbursed_amount, 0)) disbursed, max(issue_date) issue_date, funding_request_id, assessment_id FROM sfa.disbursement GROUP BY assessment_id, funding_request_id) d ON (funding_request.id = d.funding_request_id and assessment.id = d.assessment_id) + INNER JOIN (SELECT funding_request_id, MAX(id) last_id FROM sfa.assessment GROUP BY funding_request_id) maxid ON assessment.id = maxid.last_id where funding_request.request_type_id IN (4,5) AND application.academic_year_id = ${this.year} AND (application.is_perm_disabled = 1 OR application.permanent_disability = 1 OR application.pers_or_prolong_disability = 1 OR application.is_persist_disabled = 1)`); diff --git a/src/api/services/admin/nars-disft-reporting-service.ts b/src/api/services/admin/nars-disft-reporting-service.ts index e289e499..6cc22625 100644 --- a/src/api/services/admin/nars-disft-reporting-service.ts +++ b/src/api/services/admin/nars-disft-reporting-service.ts @@ -55,7 +55,8 @@ export class NarsDisabilityRCLReportingService { INNER JOIN sfa.field_program ON (application.program_id = field_program.program_id AND study_field.id = field_program.study_field_id) INNER JOIN (SELECT SUM(COALESCE(disbursed_amount, 0)) disbursed, max(issue_date) issue_date, funding_request_id, assessment_id FROM sfa.disbursement GROUP BY assessment_id, funding_request_id) d ON (funding_request.id = d.funding_request_id and assessment.id = d.assessment_id) - where + INNER JOIN (SELECT funding_request_id, MAX(id) last_id FROM sfa.assessment GROUP BY funding_request_id) maxid ON assessment.id = maxid.last_id + WHERE funding_request.request_type_id IN (4,5) AND application.academic_year_id = ${this.year} AND (application.is_perm_disabled = 1 OR application.permanent_disability = 1 OR application.pers_or_prolong_disability = 1 OR application.is_persist_disabled = 1) ORDER BY sin`);