diff --git a/services/121-service/src/metrics/metrics.service.ts b/services/121-service/src/metrics/metrics.service.ts index b10f89e84e..9a3ef3cc44 100644 --- a/services/121-service/src/metrics/metrics.service.ts +++ b/services/121-service/src/metrics/metrics.service.ts @@ -240,6 +240,7 @@ export class MetricsService { preferredLanguage: null, financialserviceprovider: null, paymentAmountMultiplier: null, + paymentCount: null, }; return { ...objectOrder, @@ -395,6 +396,7 @@ export class MetricsService { GenericAttributes.paymentAmountMultiplier, GenericAttributes.registrationCreatedDate, GenericAttributes.fspDisplayName, + GenericAttributes.paymentCount, ] as string[]; const program = await this.programRepository.findOneByOrFail({ @@ -529,7 +531,7 @@ export class MetricsService { return columnDetails.map((row) => { const filteredRow = {}; for (const key in row) { - if (row[key]) { + if (row[key] != null) { filteredRow[key] = row[key]; } } diff --git a/services/121-service/src/program-attributes/program-attributes.service.ts b/services/121-service/src/program-attributes/program-attributes.service.ts index 33e1bc2ee7..0bebb59836 100644 --- a/services/121-service/src/program-attributes/program-attributes.service.ts +++ b/services/121-service/src/program-attributes/program-attributes.service.ts @@ -42,16 +42,23 @@ export class ProgramAttributesService { (paAttribute: Attribute) => paAttribute.name, ); - let filterableAttributeNames = [ - { - group: 'payments', - filters: [ - 'failedPayment', - 'waitingPayment', - 'successPayment', - 'notYetSentPayment', - ], - }, + const paymentGroup = { + group: 'payments', + filters: [ + 'failedPayment', + 'waitingPayment', + 'successPayment', + 'notYetSentPayment', + 'paymentCount', + ], + }; + if (program.enableMaxPayments) { + paymentGroup.filters.push('maxPayments'); + paymentGroup.filters.push('paymentCountRemaining'); + } + + const filterableAttributeNames = [ + paymentGroup, { group: 'messages', filters: ['lastMessageStatus'], @@ -63,17 +70,6 @@ export class ProgramAttributesService { ], }, ]; - if (program.enableMaxPayments) { - filterableAttributeNames = [ - ...filterableAttributeNames, - ...[ - { - group: 'maxPayments', - filters: ['maxPayments', 'paymentCount', 'paymentCountRemaining'], - }, - ], - ]; - } const filterableAttributes: { group: string; diff --git a/services/121-service/src/registration/enum/custom-data-attributes.ts b/services/121-service/src/registration/enum/custom-data-attributes.ts index 7989e0ec8c..ec0ef2f866 100644 --- a/services/121-service/src/registration/enum/custom-data-attributes.ts +++ b/services/121-service/src/registration/enum/custom-data-attributes.ts @@ -36,6 +36,7 @@ export enum GenericAttributes { paymentAmountMultiplier = 'paymentAmountMultiplier', fspName = 'fspName', maxPayments = 'maxPayments', + paymentCount = 'paymentCount', scope = 'scope', status = 'status', registrationProgramId = 'registrationProgramId', diff --git a/services/121-service/test/metrics/export-list.test.ts b/services/121-service/test/metrics/export-list.test.ts index 780cdbe9a6..a1f053c97f 100644 --- a/services/121-service/test/metrics/export-list.test.ts +++ b/services/121-service/test/metrics/export-list.test.ts @@ -36,6 +36,7 @@ function createExportObject( Object.keys(exportObject).forEach( (key) => !exportObject[key] && delete exportObject[key], ); + exportObject.paymentCount = 0; return exportObject; }