diff options
Autocommit at 08.05.2022 @ 08:43
2 files changed, 10 insertions, 2 deletions
| -rw-r--r-- | src/Services/EventService.cpp | 2 | ||||
| -rw-r--r-- | src/UserInterface/VenueConsoleUI.cpp | 10 |
diff --git a/src/Services/EventService.cpp b/src/Services/EventService.cpp index f220089..2766d38 100644 --- a/src/Services/EventService.cpp +++ b/src/Services/EventService.cpp @@ -164,7 +164,7 @@ unsigned indexToInsertWhenTicketSort(const List<Event>& elem, unsigned topN, uns if (elem[i].get_tickets().get_count() <= ticketCount) return i; } - return topN; + return (topN >= elem.get_count()) ? topN : elem.get_count(); } List<Event> EventService::queryMostWatched(unsigned topN) { diff --git a/src/UserInterface/VenueConsoleUI.cpp b/src/UserInterface/VenueConsoleUI.cpp index 4c3f8cf..d2c4d24 100644 --- a/src/UserInterface/VenueConsoleUI.cpp +++ b/src/UserInterface/VenueConsoleUI.cpp @@ -145,7 +145,15 @@ void command_cancelEvent() { } void command_mostWatched() { - List<Event> top = es->queryMostWatched(10); + unsigned topN; + inputSubBox("How many to take?: ", &topN); + + List<Event> top = es->queryMostWatched(topN); + + printLine(""); + print("The top "); + print(topN); + printLine(" most watched events are:"); resetOrderedList(1); for (unsigned i = 0; i < top.get_count(); i++) { |
