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

Commit 73ee640

Browse files
Merge pull request SORMAS-Foundation#2932 from hzi-braunschweig/2728-event-participant-count
SORMAS-Foundation#2728 do not count deleted participants
2 parents 963a86a + c118089 commit 73ee640

4 files changed

Lines changed: 21 additions & 16 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/event/EventExportDto.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class EventExportDto implements Serializable {
2929
private String uuid;
3030
private String externalId;
3131
private EventStatus eventStatus;
32-
private int participantsCount;
32+
private long participantsCount;
3333
private Disease disease;
3434
private String diseaseDetails;
3535
private Date startDate;
@@ -59,7 +59,7 @@ public EventExportDto(
5959
String uuid,
6060
String externalId,
6161
EventStatus eventStatus,
62-
int participantsCount,
62+
long participantsCount,
6363
Disease disease,
6464
String diseaseDetails,
6565
Date startDate,
@@ -310,11 +310,11 @@ public void setReportDateTime(Date reportDateTime) {
310310
}
311311

312312
@Order(25)
313-
public int getParticipantsCount() {
313+
public long getParticipantsCount() {
314314
return participantsCount;
315315
}
316316

317-
public void setParticipantsCount(int participantsCount) {
317+
public void setParticipantsCount(long participantsCount) {
318318
this.participantsCount = participantsCount;
319319
}
320320

sormas-api/src/main/java/de/symeda/sormas/api/event/EventIndexDto.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class EventIndexDto implements WithJurisdiction<EventJurisdictionDto>, Se
4747

4848
private String uuid;
4949
private EventStatus eventStatus;
50-
private int participantCount;
50+
private long participantCount;
5151
private Disease disease;
5252
private String diseaseDetails;
5353
private Date startDate;
@@ -66,7 +66,7 @@ public class EventIndexDto implements WithJurisdiction<EventJurisdictionDto>, Se
6666
public EventIndexDto(
6767
String uuid,
6868
EventStatus eventStatus,
69-
Integer participantCount,
69+
Long participantCount,
7070
Disease disease,
7171
String diseaseDetails,
7272
Date startDate,
@@ -227,11 +227,11 @@ public void setReportDateTime(Date reportDateTime) {
227227
this.reportDateTime = reportDateTime;
228228
}
229229

230-
public int getParticipantCount() {
230+
public long getParticipantCount() {
231231
return participantCount;
232232
}
233233

234-
public void setParticipantCount(int participantCount) {
234+
public void setParticipantCount(long participantCount) {
235235
this.participantCount = participantCount;
236236
}
237237

14 Bytes
Binary file not shown.

sormas-backend/src/main/java/de/symeda/sormas/backend/event/EventFacadeEjb.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import javax.persistence.criteria.Join;
4141
import javax.persistence.criteria.JoinType;
4242
import javax.persistence.criteria.Order;
43+
import javax.persistence.criteria.ParameterExpression;
4344
import javax.persistence.criteria.Predicate;
4445
import javax.persistence.criteria.Root;
4546
import javax.persistence.criteria.Subquery;
@@ -216,10 +217,12 @@ public List<EventIndexDto> getIndexList(EventCriteria eventCriteria, Integer fir
216217
Join<Location, District> district = location.join(Location.DISTRICT, JoinType.LEFT);
217218
Join<Location, Community> community = location.join(Location.COMMUNITY, JoinType.LEFT);
218219

219-
Subquery<Integer> participantCount = cq.subquery(Integer.class);
220-
Root<Event> participantCountRoot = participantCount.from(Event.class);
221-
participantCount.where(cb.equal(participantCountRoot.get(AbstractDomainObject.ID), event.get(AbstractDomainObject.ID)));
222-
participantCount.select(cb.size(participantCountRoot.get(Event.EVENT_PERSONS)));
220+
Subquery<Long> participantCount = cq.subquery(Long.class);
221+
Root<EventParticipant> eventParticipantRoot = participantCount.from(EventParticipant.class);
222+
Predicate assignedToEvent = cb.equal(eventParticipantRoot.get(EventParticipant.EVENT), event.get(AbstractDomainObject.ID));
223+
Predicate notDeleted = cb.isFalse(eventParticipantRoot.get(EventParticipant.DELETED));
224+
participantCount.select(cb.count(eventParticipantRoot));
225+
participantCount.where(assignedToEvent, notDeleted);
223226

224227
cq.multiselect(
225228
event.get(Event.UUID),
@@ -317,10 +320,12 @@ public List<EventExportDto> getExportList(EventCriteria eventCriteria, Integer f
317320
Join<Location, District> district = location.join(Location.DISTRICT, JoinType.LEFT);
318321
Join<Location, Community> community = location.join(Location.COMMUNITY, JoinType.LEFT);
319322

320-
Subquery<Integer> participantCount = cq.subquery(Integer.class);
321-
Root<Event> participantCountRoot = participantCount.from(Event.class);
322-
participantCount.where(cb.equal(participantCountRoot.get(AbstractDomainObject.ID), event.get(AbstractDomainObject.ID)));
323-
participantCount.select(cb.size(participantCountRoot.get(Event.EVENT_PERSONS)));
323+
Subquery<Long> participantCount = cq.subquery(Long.class);
324+
Root<EventParticipant> eventParticipantRoot = participantCount.from(EventParticipant.class);
325+
Predicate assignedToEvent = cb.equal(eventParticipantRoot.get(EventParticipant.EVENT), event.get(AbstractDomainObject.ID));
326+
Predicate notDeleted = cb.isFalse(eventParticipantRoot.get(EventParticipant.DELETED));
327+
participantCount.select(cb.count(eventParticipantRoot));
328+
participantCount.where(assignedToEvent, notDeleted);
324329

325330
cq.multiselect(
326331
event.get(Event.UUID),

0 commit comments

Comments
 (0)