can't resist
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

20 lines
535 B

defmodule TomieWeb.ListenLive.Charts do
use TomieWeb, :live
def render(assigns), do: TomieWeb.ListenView.render("charts.html", assigns)
def mount(_args, _session, socket) do
{:ok, socket |> assign(fetch())}
end
def fetch(),
do: [
last_two_weeks:
Listens.Artists.Artist
|> Listens.Report.top(6, weeks: -2)
|> Enum.map(fn %{model: artist, listens: _l} ->
%{name: artist.name, data: Listens.Report.by_day(artist.id, days: 14)}
end)
|> Jason.encode!()
]
end