From acc3f83b6cc468e64365aef2131611cad749cc4a Mon Sep 17 00:00:00 2001 From: Michael Chadwick Date: Mon, 30 Sep 2024 09:14:18 -0700 Subject: [PATCH 1/5] added model condition for 'program-year' --- packages/frontend/app/services/reporting.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/frontend/app/services/reporting.js b/packages/frontend/app/services/reporting.js index 64c0482110..5dff7c17eb 100644 --- a/packages/frontend/app/services/reporting.js +++ b/packages/frontend/app/services/reporting.js @@ -102,10 +102,15 @@ export default class ReportingService extends Service { const objectKey = objectTranslations[prepositionalObject]; const objectTranslation = this.intl.t(objectKey); let object; + if (model === 'user') { object = record.fullName; } else if (model === 'mesh-descriptor') { object = record.name; + } else if (model === 'program-year') { + const program = await record.program; + const title = program.title; + object = `${record.classOfYear} ${title}`; } else { object = record.title; } From 19c2c7a7b7a0dd343f8a2f16e7bf12768f189dc4 Mon Sep 17 00:00:00 2001 From: Michael Chadwick Date: Thu, 10 Oct 2024 13:01:01 -0700 Subject: [PATCH 2/5] fixed classYear disappearing bug on refresh --- packages/frontend/app/services/reporting.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/frontend/app/services/reporting.js b/packages/frontend/app/services/reporting.js index 5dff7c17eb..c1360ae2f4 100644 --- a/packages/frontend/app/services/reporting.js +++ b/packages/frontend/app/services/reporting.js @@ -110,7 +110,8 @@ export default class ReportingService extends Service { } else if (model === 'program-year') { const program = await record.program; const title = program.title; - object = `${record.classOfYear} ${title}`; + const classOfYear = await record.getClassOfYear(); + object = `${classOfYear} ${title}`; } else { object = record.title; } From 2fda4858a6f73f6ad4492a3ab335157c1557fef7 Mon Sep 17 00:00:00 2001 From: Michael Chadwick Date: Mon, 14 Oct 2024 16:17:27 -0700 Subject: [PATCH 3/5] added (year) to Program Year report to match other prepositionalObject types --- packages/frontend/app/services/reporting.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/frontend/app/services/reporting.js b/packages/frontend/app/services/reporting.js index c1360ae2f4..acd40498ee 100644 --- a/packages/frontend/app/services/reporting.js +++ b/packages/frontend/app/services/reporting.js @@ -122,6 +122,9 @@ export default class ReportingService extends Service { 'academicYearCrossesCalendarYearBoundaries', ); year = crosses ? `(${record.year} - ${record.year + 1})` : `(${record.year})`; + } else if (model === 'program-year') { + const classOfYear = await record.getClassOfYear(); + year = `(${classOfYear})`; } return { From 56f10423d27a6c6d9ca690bfc641d0c95b2cfdc1 Mon Sep 17 00:00:00 2001 From: Michael Chadwick Date: Mon, 14 Oct 2024 16:18:32 -0700 Subject: [PATCH 4/5] added test for Terms in ProgramYear report --- .../tests/unit/services/reporting-test.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/packages/frontend/tests/unit/services/reporting-test.js b/packages/frontend/tests/unit/services/reporting-test.js index 7493b38492..c22dc8291e 100644 --- a/packages/frontend/tests/unit/services/reporting-test.js +++ b/packages/frontend/tests/unit/services/reporting-test.js @@ -2,6 +2,7 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; import { setupIntl } from 'ember-intl/test-support'; import { setupMirage } from 'frontend/tests/test-support/mirage'; +import { DateTime } from 'luxon'; module('Unit | Service | reporting', function (hooks) { setupTest(hooks); @@ -226,6 +227,45 @@ module('Unit | Service | reporting', function (hooks) { ); }); + test('buildReportDescription() - all terms for program year X in school Y', async function (assert) { + const school = this.server.create('school', { title: 'School of Schools' }); + const program = this.server.create('program', { school: school }); + const programYear = this.server.create('program-year', { + program, + startYear: DateTime.now().year, + }); + const vocabulary = this.server.create('vocabulary', { school }); + this.server.create('term', { + title: 'foo bar', + programYears: [programYear], + vocabulary, + }); + const report = this.server.create('report', { + subject: 'term', + prepositionalObject: 'program year', + prepositionalObjectTableRowId: programYear.id, + school, + }); + + const store = this.owner.lookup('service:store'); + const reportModel = await store.findRecord('report', report.id); + const programYearModel = await store.findRecord('program year', programYear.id); + const schoolModel = await store.findRecord('school', school.id); + const title = await this.service.buildReportDescription( + reportModel.subject, + reportModel.prepositionalObject, + reportModel.prepositionalObjectTableRowId, + school, + ); + const classOfYear = await programYearModel.getClassOfYear(); + const programYearTitle = `${classOfYear} ${program.title}`; + + assert.strictEqual( + title, + `This report shows all Terms associated with Program Year "${programYearTitle}" (${classOfYear}) in ${schoolModel.title}.`, + ); + }); + test('buildReportDescription() - broken report', async function (assert) { const school = this.server.create('school', { title: 'School of Schools' }); const report = this.server.create('report', { From 710c8ab65947b27a6a3ef1ed22387017434323a7 Mon Sep 17 00:00:00 2001 From: Michael Chadwick Date: Wed, 16 Oct 2024 13:53:03 -0700 Subject: [PATCH 5/5] removed duplicate (classOfYear) in report title and fixed test so it passes --- packages/frontend/app/services/reporting.js | 3 --- packages/frontend/tests/unit/services/reporting-test.js | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/frontend/app/services/reporting.js b/packages/frontend/app/services/reporting.js index acd40498ee..c1360ae2f4 100644 --- a/packages/frontend/app/services/reporting.js +++ b/packages/frontend/app/services/reporting.js @@ -122,9 +122,6 @@ export default class ReportingService extends Service { 'academicYearCrossesCalendarYearBoundaries', ); year = crosses ? `(${record.year} - ${record.year + 1})` : `(${record.year})`; - } else if (model === 'program-year') { - const classOfYear = await record.getClassOfYear(); - year = `(${classOfYear})`; } return { diff --git a/packages/frontend/tests/unit/services/reporting-test.js b/packages/frontend/tests/unit/services/reporting-test.js index c22dc8291e..60c74cc92d 100644 --- a/packages/frontend/tests/unit/services/reporting-test.js +++ b/packages/frontend/tests/unit/services/reporting-test.js @@ -262,7 +262,7 @@ module('Unit | Service | reporting', function (hooks) { assert.strictEqual( title, - `This report shows all Terms associated with Program Year "${programYearTitle}" (${classOfYear}) in ${schoolModel.title}.`, + `This report shows all Terms associated with Program Year "${programYearTitle}" in ${schoolModel.title}.`, ); });