Last active
December 4, 2017 12:04
-
-
Save natanbc/de8f7b457b0fed8df8aec353b5416e7b to your computer and use it in GitHub Desktop.
DBL lib indexing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) throws Throwable { | |
DiscordBotsAPI api = new DiscordBotsAPI(); | |
Map<String, Integer> map = api.index().stream().map(BotInfo::getLib).collect(Collectors.groupingBy( | |
Function.identity(), | |
Collectors.collectingAndThen(Collectors.counting(), Long::intValue) | |
)); | |
int total = map.values().stream().mapToInt(Integer::intValue).sum(); | |
System.out.println("Total: " + total); | |
System.out.println(); | |
map.entrySet().stream().sorted(Comparator.<Map.Entry<String, Integer>>comparingInt(Map.Entry::getValue).reversed()).forEach(entry->{ | |
System.out.println(entry.getKey() + ": " + entry.getValue() + " bots, " + (entry.getValue().doubleValue()/total * 100) + "%"); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment