Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Services / EventService.cpp
diff options
context:
space:
mode:
1 files changed, 3 insertions, 3 deletions
-rw-r--r--src/Services/EventService.cpp6
diff --git a/src/Services/EventService.cpp b/src/Services/EventService.cpp
index 2766d38..88a9e08 100644
--- a/src/Services/EventService.cpp
+++ b/src/Services/EventService.cpp
@@ -164,16 +164,16 @@ unsigned indexToInsertWhenTicketSort(const List<Event>& elem, unsigned topN, uns
if (elem[i].get_tickets().get_count() <= ticketCount)
return i;
}
- return (topN >= elem.get_count()) ? topN : elem.get_count();
+ return (topN < elem.get_count()) ? topN : elem.get_count();
}
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 || events.get_count() < topN)
+ if (ind < topN)
result.insertAt(events[i], ind);
- if (result.get_count() == topN)
+ if (result.get_count() > topN)
result.removeAt(topN);
}
return result;