use of gg.projecteden.nexus.models.hours.HoursService.HoursTopArguments in project Nexus by ProjectEdenGG.
the class HoursCommand method top2.
// TODO Update paginate to support database-level pagination
@Async
@Description("View the play time leaderboard for any year, month, or day")
@Path("top [args...]")
void top2(@Arg("1") HoursTopArguments args, @Switch boolean onlyStaff) {
int page = args.getPage();
List<PageResult> results = service.getPage(args);
String onlyStaffSwitch = "";
if (onlyStaff) {
onlyStaffSwitch = " --onlyStaff";
results.removeIf(result -> !Rank.of(result.getUuid()).isStaff());
}
if (results.size() == 0)
error("&cNo results on page " + page);
int totalHours = 0;
for (PageResult result : results) totalHours += result.getTotal();
send("");
send(PREFIX + "Total: " + Timespan.ofSeconds(totalHours).format() + (page > 1 ? "&e | &3Page " + page : ""));
BiFunction<PageResult, String, JsonBuilder> formatter = (result, index) -> json(index + " &e" + Nerd.of(result.getUuid()).getColoredName() + " &7- " + Timespan.ofSeconds(result.getTotal()).format());
paginate(results, formatter, "/hours top " + args.getInput() + onlyStaffSwitch, page);
}
Aggregations