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: enr agg endpoint + do not req stage for attr and pi (DHIS2-15691) #1335

Merged
merged 1 commit into from
Oct 22, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/dhis2-verify-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Build
run: yarn build

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: app-build
path: |
Expand All @@ -73,7 +73,7 @@ jobs:
with:
node-version: 12.x

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: app-build

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"homepage": "https://github.com/dhis2/event-reports-app#readme",
"dependencies": {
"d2-analysis": "^33.3.1",
"d2-analysis": "^33.3.3",
"d2-utilizr": "0.2.13"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion src/api/Dimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ Dimension.prototype.isIgnoreDimension = function() {

// dep 1

const getFullId = dim => (dim.programStage ? dim.programStage.id + '.' : '') + dim.dimension;
const getFullId = dim => (dim.programStage && dim.programStage.id ?
dim.programStage.id + '.' : '') + dim.dimension;

Dimension.prototype.url = function(isSorted, response, isFilter) {
if (this.isIgnoreDimension()) {
Expand Down
35 changes: 30 additions & 5 deletions src/api/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import isNumeric from 'd2-utilizr/lib/isNumeric';
import isObject from 'd2-utilizr/lib/isObject';
import isString from 'd2-utilizr/lib/isString';

import { Record, Layout as d2aLayout } from 'd2-analysis';
import { Record, Layout as d2aLayout, dimensionsInit } from 'd2-analysis';

export var Layout = function(refs, c, applyConfig, forceApplyConfig) {
var t = this;
Expand All @@ -20,6 +20,22 @@ export var Layout = function(refs, c, applyConfig, forceApplyConfig) {
// inherit
Object.assign(t, new d2aLayout(refs, c, applyConfig));

// data element dimensions
if (c.dataElementDimensions) {
t.dataElementDimensions = c.dataElementDimensions;
}

// add isDataElement to distinguish from attributes and program indicators
if (t.dataElementDimensions) {
([].concat(t.columns, t.rows, t.filters))
.filter(dimension => dimension)
.forEach(dimension => {
if (c.dataElementDimensions.find(de => de.dataElement.id === dimension.dimension)) {
dimension.isDataElement = true
}
})
}

// program
t.program = isObject(c.program) ? c.program : null;
t.programStage = isObject(c.programStage) ? c.programStage : null;
Expand Down Expand Up @@ -185,11 +201,20 @@ Layout.prototype.getDataTypeUrl = function() {
var DATA_TYPE_EVENT = dimensionConfig.dataType['individual_cases'];
var OUTPUT_TYPE_EVENT = optionConfig.getOutputType('event').id;
var OUTPUT_TYPE_ENROLLMENT = optionConfig.getOutputType('enrollment').id;

var urlMap = {
[OUTPUT_TYPE_EVENT]: {
[DATA_TYPE_AGG]: '/events/aggregate',
[DATA_TYPE_EVENT]: '/events/query',
},
[OUTPUT_TYPE_ENROLLMENT]: {
[DATA_TYPE_AGG]: '/enrollments/aggregate',
[DATA_TYPE_EVENT]: '/enrollments/query',
}
}

var url = this.dataType === DATA_TYPE_AGG ? '/events/aggregate' :
this.outputType === OUTPUT_TYPE_EVENT ? '/events/query' :
'/enrollments/query';

var url = urlMap[this.outputType][this.dataType]

return url || dimensionConfig.dataTypeUrl[dimensionConfig.getDefaultDataType()] || '';
};

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1734,10 +1734,10 @@ currently-unhandled@^0.4.1:
dependencies:
array-find-index "^1.0.1"

d2-analysis@^33.3.1:
version "33.3.1"
resolved "https://registry.yarnpkg.com/d2-analysis/-/d2-analysis-33.3.1.tgz#6299beb6b79bc252d21c535db86ccab301700c95"
integrity sha512-VhGB5BWiyZrGFpwRDOMJt0SpK0mboFe50VGE7GRUP8JzqGNUG0FXxuzC5wepKcPuPOEimU+PjrqGtmPZFBo0XQ==
d2-analysis@^33.3.3:
version "33.3.3"
resolved "https://registry.yarnpkg.com/d2-analysis/-/d2-analysis-33.3.3.tgz#cf60f052711111aa46512a1fe0e44462bd20654a"
integrity sha512-TAk3Dqho6vrD/wul/DHR/mW8P89kgOqyR9eiUwBFS7n1BRlvifgFTdzT0mI53DN9I8nuBi+6TWtFHQvjN8lBIQ==
dependencies:
"@dhis2/d2-ui-rich-text" "^5.1.0"
d2-utilizr "^0.2.16"
Expand Down
Loading