diff --git a/music_library.livemd b/music_library.livemd index 8e853270..b4e4940e 100644 --- a/music_library.livemd +++ b/music_library.livemd @@ -129,3 +129,35 @@ genres = ```elixir Enum.join(genres.rows, ",") ``` + +## Total artists per country + + + +```elixir +total_artists_per_country = + Exqlite.query!( + conn, + ~S""" + SELECT + count(*) AS total_artists, + json_extract(musicbrainz_data, '$.country') AS country + FROM artist_infos + GROUP BY country + ORDER BY total_artists DESC; + """, + [] + ) +``` + + + +```elixir +VegaLite.new(width: 600, title: "Total artists per country") +|> VegaLite.data_from_values(total_artists_per_country, + only: ["total_artists", "country"] +) +|> VegaLite.mark(:bar) +|> VegaLite.encode_field(:x, "total_artists", type: :quantitative) +|> VegaLite.encode_field(:y, "country", type: :nominal) +```