From 1b92dfd0b57e697de3bb62cf62de6db283c1dffd Mon Sep 17 00:00:00 2001 From: Sylvain Jermini Date: Sat, 7 Jan 2017 19:40:07 +0100 Subject: [PATCH] #233 partition expired events: set cutoff date for two week, show sold tickets statistic --- .../java/alfio/controller/api/admin/EventApiController.java | 4 ++-- src/main/java/alfio/model/Event.java | 6 +++++- .../feature/expired-events-list/expired-events-list.html | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/alfio/controller/api/admin/EventApiController.java b/src/main/java/alfio/controller/api/admin/EventApiController.java index 6b2798f3df..c73b63660e 100644 --- a/src/main/java/alfio/controller/api/admin/EventApiController.java +++ b/src/main/java/alfio/controller/api/admin/EventApiController.java @@ -160,12 +160,12 @@ public List getAllEvents(Principal principal) { @RequestMapping(value = "/active-events", method = GET) public List getAllActiveEvents(Principal principal) { - return eventStatisticsManager.getAllEventsWithStatisticsFilteredBy(principal.getName(), event -> !event.expired()); + return eventStatisticsManager.getAllEventsWithStatisticsFilteredBy(principal.getName(), event -> !event.expiredSince(14)); } @RequestMapping(value = "/expired-events", method = GET) public List getAllExpiredEvents(Principal principal) { - return eventStatisticsManager.getAllEventsWithStatisticsFilteredBy(principal.getName(), Event::expired); + return eventStatisticsManager.getAllEventsWithStatisticsFilteredBy(principal.getName(), event -> event.expiredSince(14)); } @RequestMapping(value = "/events/{name}", method = GET) diff --git a/src/main/java/alfio/model/Event.java b/src/main/java/alfio/model/Event.java index 0bf4fbdc32..7259160748 100644 --- a/src/main/java/alfio/model/Event.java +++ b/src/main/java/alfio/model/Event.java @@ -294,6 +294,10 @@ private static boolean mustUseFirstAndLastName(Event event) { } public boolean expired() { - return ZonedDateTime.now(getZoneId()).truncatedTo(ChronoUnit.DAYS).isAfter(getEnd().truncatedTo(ChronoUnit.DAYS)); + return expiredSince(0); + } + + public boolean expiredSince(int days) { + return ZonedDateTime.now(getZoneId()).truncatedTo(ChronoUnit.DAYS).minusDays(days).isAfter(getEnd().truncatedTo(ChronoUnit.DAYS)); } } diff --git a/src/main/webapp/resources/js/admin/feature/expired-events-list/expired-events-list.html b/src/main/webapp/resources/js/admin/feature/expired-events-list/expired-events-list.html index 281d4b7a8c..4bfeb334c1 100644 --- a/src/main/webapp/resources/js/admin/feature/expired-events-list/expired-events-list.html +++ b/src/main/webapp/resources/js/admin/feature/expired-events-list/expired-events-list.html @@ -31,6 +31,9 @@

Past events

{{event.formattedBegin | formatDate}} / {{event.formattedEnd | formatDate}} +