From 23a6739eb19aa42c5733b48960478c763b1329aa Mon Sep 17 00:00:00 2001 From: Colin McDonald Date: Tue, 2 Aug 2016 19:16:21 -0400 Subject: [PATCH] Update /staff for Ariel (new schhema) --- .../frozenorb/apiv3/route/users/GETStaff.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/main/java/net/frozenorb/apiv3/route/users/GETStaff.java b/src/main/java/net/frozenorb/apiv3/route/users/GETStaff.java index 68e907e..d64a87d 100644 --- a/src/main/java/net/frozenorb/apiv3/route/users/GETStaff.java +++ b/src/main/java/net/frozenorb/apiv3/route/users/GETStaff.java @@ -12,38 +12,38 @@ import java.util.*; public final class GETStaff implements Handler { - public void handle(RoutingContext ctx) { - Map staffRanks = new HashMap<>(); + public void handle(RoutingContext ctx) { + Map staffRanks = new HashMap<>(); - Rank.findAll().forEach(rank -> { - if (rank.isStaffRank()) { - staffRanks.put(rank.getId(), rank); - } - }); + Rank.findAll().forEach(rank -> { + if (rank.isStaffRank()) { + staffRanks.put(rank.getId(), rank); + } + }); - Map> result = new TreeMap<>((first, second) -> { - Rank firstRank = staffRanks.get(first); - Rank secondRank = staffRanks.get(second); + Map> result = new TreeMap<>((a, b) -> { + Rank aRank = staffRanks.get(a); + Rank bRank = staffRanks.get(b); - return Integer.compare(firstRank.getGeneralWeight(), secondRank.getGeneralWeight()); - }); + return Integer.compare(bRank.getGeneralWeight(), aRank.getGeneralWeight()); + }); - List staffGrants = SyncUtils.runBlocking(v -> Grant.findByRank(staffRanks.values(), v)); + List staffGrants = SyncUtils.runBlocking(v -> Grant.findByRank(staffRanks.values(), v)); - for (Grant staffGrant : staffGrants) { - if (staffGrant.isActive()) { - User user = SyncUtils.runBlocking(v -> User.findById(staffGrant.getId(), v)); - Rank rank = staffRanks.get(staffGrant.getRank()); + for (Grant staffGrant : staffGrants) { + if (staffGrant.isActive()) { + User user = SyncUtils.runBlocking(v -> User.findById(staffGrant.getUser(), v)); + Rank rank = staffRanks.get(staffGrant.getRank()); - if (!result.containsKey(rank.getId())) { - result.put(rank.getId(), new HashSet<>()); - } + if (!result.containsKey(rank.getId())) { + result.put(rank.getId(), new HashSet<>()); + } - result.get(rank.getId()).add(user); - } - } + result.get(rank.getId()).add(user); + } + } - APIv3.respondJson(ctx, 200, result); - } + APIv3.respondJson(ctx, 200, result); + } } \ No newline at end of file