Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Services / EventService.cpp
diff options
context:
space:
mode:
1 files changed, 1 insertions, 1 deletions
-rw-r--r--src/Services/EventService.cpp2
diff --git a/src/Services/EventService.cpp b/src/Services/EventService.cpp
index 5b79faa..f220089 100644
--- a/src/Services/EventService.cpp
+++ b/src/Services/EventService.cpp
@@ -171,7 +171,7 @@ List<Event> EventService::queryMostWatched(unsigned topN) {
List<Event> result;
for (unsigned i = 0; i < events.get_count(); i++) {
unsigned ind = indexToInsertWhenTicketSort(result, topN, events[i].get_tickets().get_count());
- if (ind < topN)
+ if (ind < topN || events.get_count() < topN)
result.insertAt(events[i], ind);
if (result.get_count() == topN)
result.removeAt(topN);