Search in sources :

Example 1 with Artist

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);
    }
}
Also used : Artist(net.robinfriedli.aiode.entities.Artist) HashMap(java.util.HashMap) BigInteger(java.math.BigInteger) Session(org.hibernate.Session)

Aggregations

BigInteger (java.math.BigInteger)1 HashMap (java.util.HashMap)1 Artist (net.robinfriedli.aiode.entities.Artist)1 Session (org.hibernate.Session)1