From 69f3d4509d72b188549be24ea3f38c79def9fa15 Mon Sep 17 00:00:00 2001 From: Stefanos Hadjipetrou Date: Thu, 11 Jul 2024 16:20:07 +0300 Subject: [PATCH] feat: eligibility years array in table result --- src/controllers/eligibility.controller.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controllers/eligibility.controller.ts b/src/controllers/eligibility.controller.ts index b27a200..34337e5 100644 --- a/src/controllers/eligibility.controller.ts +++ b/src/controllers/eligibility.controller.ts @@ -80,6 +80,8 @@ export class EligibilityController { EligibilityTableMapping.geography, ); + const years: string[] = []; + const data: { [key: string]: | string @@ -150,6 +152,7 @@ export class EligibilityController { ); _.forEach(componentGroupedByYear, (value, key) => { + years.push(key); let isEligible = _.get( value, `[0]["${EligibilityTableMapping.isEligible}"]`, @@ -184,7 +187,7 @@ export class EligibilityController { return item; }); - return {data}; + return {data, years: _.orderBy(_.uniq(years), [], ['desc'])}; }) .catch(handleDataApiError); }