From 80c606e276bb2aabf3341b87fc5c513fe4156b41 Mon Sep 17 00:00:00 2001 From: pandutibil Date: Tue, 21 Nov 2023 16:05:08 +0530 Subject: [PATCH] Updated configurations for diksha and fixed issues in dashboard metric construction --- src/app/views/dashboard/dashboard.component.ts | 14 +++++++------- src/app/views/diksha/config/diksha_config.ts | 12 ++++-------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/app/views/dashboard/dashboard.component.ts b/src/app/views/dashboard/dashboard.component.ts index b15499a0..a2b12fb5 100644 --- a/src/app/views/dashboard/dashboard.component.ts +++ b/src/app/views/dashboard/dashboard.component.ts @@ -187,22 +187,22 @@ export class DashboardComponent implements OnInit { if (currentLevelFilter !== undefined) { let metricQueries = currentLevelFilter?.actions?.queries; let metricQueriesKeys = Object.keys(metricQueries); - console.log("cvbn:", { metricQueriesKeys, currentLevelFilter, metricQueries }) for (let k = 0; k < metricQueriesKeys?.length; k++) { if (metrics.length >= 2) { break; } else if (metricQueriesKeys[k].indexOf('bigNumber') > -1) { let query = parseRbacFilter(metricQueries[metricQueriesKeys[k]], rbacDetails); + let bigNumberOptions = Array.isArray(programConfig[reports[i]]?.options?.bigNumber) ? programConfig[reports[i]]?.options?.bigNumber[rbacDetails.role] : programConfig[reports[i]]?.options?.bigNumber; if (query === "" || isNaN(Number(query))) { let res = await this._wrapperService.runQuery(query) if (res && res.length > 0) { let metricData = { - value: Array.isArray(programConfig[reports[i]]?.options?.bigNumber?.property) ? String(formatNumberForReport(res[0]?.[programConfig[reports[i]]?.options?.bigNumber?.property[k]])) + [programConfig[reports[i]]?.options?.bigNumber?.valueSuffix[k]] : String(formatNumberForReport(res[0]?.[programConfig[reports[i]]?.options?.bigNumber?.property])) + [programConfig[reports[i]]?.options?.bigNumber?.valueSuffix], - name: Array.isArray(programConfig[reports[i]]?.options?.bigNumber?.title) ? programConfig[reports[i]]?.options?.bigNumber?.title[k] : programConfig[reports[i]]?.options?.bigNumber?.title + value: Array.isArray(bigNumberOptions?.property) ? String(formatNumberForReport(res[0]?.[bigNumberOptions?.property[k]])) + [bigNumberOptions?.valueSuffix[k]] : String(formatNumberForReport(res[0]?.[bigNumberOptions?.property])) + [bigNumberOptions?.valueSuffix], + name: Array.isArray(bigNumberOptions?.title) ? bigNumberOptions?.title[k] : bigNumberOptions?.title } - if((Array.isArray(programConfig[reports[i]]?.options?.bigNumber?.property) ? res?.[0]?.[programConfig[reports[i]]?.options?.bigNumber?.property[k]] : res?.[0]?.[programConfig[reports[i]]?.options?.bigNumber?.property]) === null) { - metricData.value = Array.isArray(programConfig[reports[i]]?.options?.bigNumber?.valueSuffix) ? '0' + programConfig[reports[i]]?.options?.bigNumber?.valueSuffix[k] : '0' + programConfig[reports[i]]?.options?.bigNumber?.valueSuffix + if((Array.isArray(bigNumberOptions?.property) ? res?.[0]?.[bigNumberOptions?.property[k]] : res?.[0]?.[bigNumberOptions?.property]) === null) { + metricData.value = Array.isArray(bigNumberOptions?.valueSuffix) ? '0' + bigNumberOptions?.valueSuffix[k] : '0' + bigNumberOptions?.valueSuffix } if (metricData.value !== null && metricData !== undefined) { metrics.push(metricData) @@ -210,10 +210,10 @@ export class DashboardComponent implements OnInit { } } } else { - const formatter = programConfig[reports[i]]?.options?.bigNumber?.formatter[k] ? programConfig[reports[i]]?.options?.bigNumber?.formatter[k] : programConfig[reports[i]]?.options?.bigNumber?.formatter; + const formatter = bigNumberOptions?.formatter[k] ? bigNumberOptions?.formatter[k] : bigNumberOptions?.formatter; metrics.push({ value: !isNaN(metricQueries[metricQueriesKeys[k]]) ? formatNumberForReport(metricQueries[metricQueriesKeys[k]], formatter) : metricQueries[metricQueriesKeys[k]], - name: programConfig[reports[i]]?.options?.bigNumber?.title[k] + name: bigNumberOptions?.title[k] }); } } diff --git a/src/app/views/diksha/config/diksha_config.ts b/src/app/views/diksha/config/diksha_config.ts index 13b30bf9..5b910c8c 100644 --- a/src/app/views/diksha/config/diksha_config.ts +++ b/src/app/views/diksha/config/diksha_config.ts @@ -521,10 +521,7 @@ export const config = { "hierarchyLevel": "0", "actions": { "queries": { - "bigNumber1": "6766", - "bigNumber2": "107000", - "bigNumber3": "332000", - "bigNumber4": "select count(distinct state_id) as total_states from datasets.diksha_energized_textbooks_state where sum > 0" + "bigNumber1": "select count(distinct state_id) as total_states from datasets.diksha_energized_textbooks_state where sum > 0" }, "level": "district" } @@ -547,10 +544,9 @@ export const config = { ], "options": { "bigNumber": [{ - "title": ['Total ETBs', 'Total QR Codes', 'Total Content', 'Total States/UTs Participating'], - "valueSuffix": ['', '', '', ''], - "property": ['', '', '', 'total_states'], - "formatter": { locale: 'en-IN', format: "long" } + "title": ['Total States/UTs Participating'], + "valueSuffix": [''], + "property": ['total_states'] }, { "title": ['Total ETBs', 'Total QR Codes', 'Content Coverage on QR', 'Total States/UTs Participating', 'Total Content'], "valueSuffix": ['', '', '%', '', ''],