Skip to content

Commit

Permalink
fix: reenable program status and ou to fetch metadata from app
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkrulltott committed Jan 26, 2024
1 parent 1802453 commit 7d2b1b4
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/components/Visualization/useAnalyticsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,17 @@ const extractHeaders = (analyticsResponse, outputType) => {
const dimensionIds = analyticsResponse.headers.map((header) => {
const { dimensionId, programStageId, programId } =
extractDimensionIdParts(header.name, outputType)
const idMatch =
[DIMENSION_ID_ORGUNIT, DIMENSION_ID_PROGRAM_STATUS].includes(
dimensionId
) &&
Object.keys(headersMap).find(
(key) => headersMap[key] === dimensionId
)
const idMatch = Object.keys(headersMap).find(
(key) => headersMap[key] === dimensionId
)

const formattedDimensionId = formatDimensionId({
dimensionId: idMatch || dimensionId,
dimensionId: [
DIMENSION_ID_ORGUNIT,
DIMENSION_ID_PROGRAM_STATUS,
].includes(idMatch)
? idMatch
: dimensionId,
programStageId,
programId,
outputType,
Expand Down Expand Up @@ -329,28 +330,29 @@ const extractHeaders = (analyticsResponse, outputType) => {

const labels = dimensionsWithSuffix.map(({ name, suffix, id }) => ({
id,
label: suffix ? `${name}, ${suffix}` : name,
label: suffix ? `${name}, ${suffix} !!!` : name, // TODO: remove the !!!, just for testing
}))

const headers = analyticsResponse.headers.map((header, index) => {
const result = { ...header, index }
const { dimensionId, programId, programStageId } =
extractDimensionIdParts(header.name, outputType)

const idMatch =
[DIMENSION_ID_ORGUNIT, DIMENSION_ID_PROGRAM_STATUS].includes(
dimensionId
) &&
Object.keys(headersMap).find(
(key) => headersMap[key] === dimensionId
)
const idMatch = Object.keys(headersMap).find(
(key) => headersMap[key] === dimensionId
)

result.column =
labels.find(
(label) =>
label.id ===
formatDimensionId({
dimensionId: idMatch || dimensionId,
dimensionId: [
DIMENSION_ID_ORGUNIT,
DIMENSION_ID_PROGRAM_STATUS,
].includes(idMatch)
? idMatch
: dimensionId,
programId,
programStageId,
outputType,
Expand Down

0 comments on commit 7d2b1b4

Please sign in to comment.