Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit a89aa5b

Browse files
author
Martin Wahnschaffe
committed
SORMAS-Foundation#2957 Campaign chart calculation based on fieldValue not working correct
1 parent 924bf3e commit a89aa5b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

sormas-backend/src/main/java/de/symeda/sormas/backend/campaign/data/CampaignFormDataFacadeEjb.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,15 @@ public List<CampaignDiagramDataDto> getDiagramData(
309309
region != null ? ", " + District.TABLE_NAME + "." + District.UUID + ", " + District.TABLE_NAME + "." + District.NAME : "")
310310
+ ", " + Region.TABLE_NAME + "." + Region.UUID + ", " + Region.TABLE_NAME + "." + Region.NAME;
311311

312+
312313
Query seriesDataQuery = em.createNativeQuery(
313314
"SELECT " + CampaignFormMeta.TABLE_NAME + "." + CampaignFormMeta.UUID + " as formUuid,"
314315
+ CampaignFormMeta.TABLE_NAME + "." + CampaignFormMeta.FORM_ID + " as formId"
315316
+ ", jsonData->>'" + CampaignFormDataEntry.ID + "' as fieldId"
316317
+ ", jsonMeta->>'" + CampaignFormElement.CAPTION + "' as fieldCaption"
317318
+ ", CASE"
318319
+ " WHEN (jsonMeta ->> '" + CampaignFormElement.TYPE + "') = '" + CampaignFormElementType.NUMBER.toString() + "' THEN sum(cast_to_int(jsonData->>'" + CampaignFormDataEntry.VALUE + "', 0))"
319-
+ " ELSE count((jsonData->>'" + CampaignFormDataEntry.VALUE + "') = '" + diagramSeries.getFieldValue() + "')"
320+
+ " ELSE sum(CASE WHEN(jsonData->>'" + CampaignFormDataEntry.VALUE + "') = '" + diagramSeries.getFieldValue() + "' THEN 1 ELSE 0 END)"
320321
+ " END as sumValue"
321322
+ ", " + Region.TABLE_NAME + "." + Region.UUID
322323
+ ", " + Region.TABLE_NAME + "." + Region.NAME

0 commit comments

Comments
 (0)