Skip to content

Commit

Permalink
fix: remove duplicate counts [DHIS2-15948] (#1013) (#1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzemp authored Dec 11, 2023
1 parent 7232ff0 commit 97d4a3b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
8 changes: 4 additions & 4 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -549,14 +549,14 @@ msgstr "Data elements"
msgid "Organisation unit groups"
msgstr "Organisation unit groups"

msgid "Tracked entity instances"
msgstr "Tracked entity instances"
msgid "Tracked entities"
msgstr "Tracked entities"

msgid "Pivot tables"
msgstr "Pivot tables"

msgid "Program instances"
msgstr "Program instances"
msgid "Enrollments"
msgstr "Enrollments"

msgid "Indicator types"
msgstr "Indicator types"
Expand Down
22 changes: 15 additions & 7 deletions src/pages/data-statistics/parse-tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ const objectLabels = {
indicator: i18n.t('Indicators'),
period: i18n.t('Periods'),
visualization: i18n.t('Visualization'),
programStageInstance: i18n.t('Events'),
event: i18n.t('Events'),
organisationUnit: i18n.t('Organisation units'),
validationRule: i18n.t('Validation rules'),
dataValue: i18n.t('Data values'),
program: i18n.t('Programs'),
dataElement: i18n.t('Data elements'),
organisationUnitGroup: i18n.t('Organisation unit groups'),
trackedEntityInstance: i18n.t('Tracked entity instances'),
trackedEntity: i18n.t('Tracked entities'),
reportTable: i18n.t('Pivot tables'),
programInstance: i18n.t('Program instances'),
enrollment: i18n.t('Enrollments'),
indicatorType: i18n.t('Indicator types'),
dataSet: i18n.t('Data sets'),
userGroup: i18n.t('User groups'),
Expand All @@ -48,17 +48,25 @@ const translatedTimeLabelFromIntProperty = (key) => {
}
}

// old (<=v40) keys
const excludedObjectCountKeys = [
'programInstance',
'programStageInstance',
'trackedEntityInstance',
]

const objectCountsTableFromResponse = (objectCountsResponse) => {
if (!objectCountsResponse) {
return null
}

const elements = Object.entries(objectCountsResponse).map(
([key, count]) => ({
// api returns old (<=v40) and new (>=v41) keys; filter out old ones
const elements = Object.entries(objectCountsResponse)
.filter(([key]) => !excludedObjectCountKeys.includes(key))
.map(([key, count]) => ({
label: objectLabels[key] || key,
count,
})
)
}))
elements.sort((a, b) => a.label.localeCompare(b.label))

return {
Expand Down

0 comments on commit 97d4a3b

Please sign in to comment.