use of net.robinfriedli.aiode.entities.Artist in project aiode by robinfriedli.
the class ChartsCommand method addArtists.
private void addArtists(List<Object[]> records, EmbedBuilder embedBuilder, String period) {
Session session = getContext().getSession();
Map<Artist, BigInteger> artistsWithPlayedAmount = new HashMap<>();
List<Artist> artists = Lists.newArrayList();
for (Object[] record : records) {
BigInteger artistPk = (BigInteger) record[0];
BigInteger playedCount = (BigInteger) record[1];
Artist artist = session.load(Artist.class, artistPk.longValue());
artists.add(artist);
artistsWithPlayedAmount.put(artist, playedCount);
}
String title = period + " - Artist Charts";
if (!artists.isEmpty()) {
Util.appendEmbedList(embedBuilder, artists, artist -> artistsWithPlayedAmount.get(artist) + " - " + artist.getName(), title, true);
} else {
embedBuilder.addField(title, "No data", true);
}
}
Aggregations