Skip to content

Commit

Permalink
Merge pull request #397 from pandutibil/dev
Browse files Browse the repository at this point in the history
Updated configurations for diksha and fixed issues in dashboard metri…
  • Loading branch information
pandutibil authored Nov 21, 2023
2 parents 66141c5 + 80c606e commit 8d13f4f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/app/views/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,33 +187,33 @@ 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)
// console.log(metricData.value)
}
}
} 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]
});
}
}
Expand Down
12 changes: 4 additions & 8 deletions src/app/views/diksha/config/diksha_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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": ['', '', '%', '', ''],
Expand Down

0 comments on commit 8d13f4f

Please sign in to comment.