Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove duplicate counts [DHIS2-15948] (v40) [REVERT] #1025

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 entities"
msgstr "Tracked entities"
msgid "Tracked entity instances"
msgstr "Tracked entity instances"

msgid "Pivot tables"
msgstr "Pivot tables"

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

msgid "Indicator types"
msgstr "Indicator types"
Expand Down
22 changes: 7 additions & 15 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'),
event: i18n.t('Events'),
programStageInstance: 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'),
trackedEntity: i18n.t('Tracked entities'),
trackedEntityInstance: i18n.t('Tracked entity instances'),
reportTable: i18n.t('Pivot tables'),
enrollment: i18n.t('Enrollments'),
programInstance: i18n.t('Program instances'),
indicatorType: i18n.t('Indicator types'),
dataSet: i18n.t('Data sets'),
userGroup: i18n.t('User groups'),
Expand All @@ -48,25 +48,17 @@ const translatedTimeLabelFromIntProperty = (key) => {
}
}

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

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

// 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]) => ({
const elements = Object.entries(objectCountsResponse).map(
([key, count]) => ({
label: objectLabels[key] || key,
count,
}))
})
)
elements.sort((a, b) => a.label.localeCompare(b.label))

return {
Expand Down
Loading