Simplify data structure
This commit is contained in:
@@ -19,24 +19,17 @@ defmodule Mihainator.Extractor do
|
||||
|
||||
date_range = Date.range(first_date, last_date)
|
||||
|
||||
interaction_data =
|
||||
raw_data
|
||||
|> Enum.filter(fn {date, _} -> Date.after?(date, first_date) end)
|
||||
|> Map.new()
|
||||
|> get_normalized_interaction_data(date_range)
|
||||
|> Enum.group_by(fn {date, _} ->
|
||||
month =
|
||||
Integer.to_string(date.month)
|
||||
|> String.pad_leading(2, "0")
|
||||
raw_data
|
||||
|> Enum.filter(fn {date, _} -> Date.after?(date, first_date) end)
|
||||
|> Map.new()
|
||||
|> get_normalized_interaction_data(date_range)
|
||||
|> Enum.group_by(fn {date, _} ->
|
||||
month =
|
||||
Integer.to_string(date.month)
|
||||
|> String.pad_leading(2, "0")
|
||||
|
||||
"#{date.year}-#{month}"
|
||||
end)
|
||||
|
||||
%{
|
||||
first_date: first_date,
|
||||
last_date: last_date,
|
||||
interaction_data: interaction_data
|
||||
}
|
||||
"#{date.year}-#{month}"
|
||||
end)
|
||||
end
|
||||
|
||||
defp get_raw_data(file) do
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<p class="text-lg">This is the result of your history:</p>
|
||||
|
||||
<div class="calendar-wrapper">
|
||||
<%= for {_, days_of_month} <- @calendar_dates.interaction_data do %>
|
||||
<%= for {_, days_of_month} <- @calendar_dates do %>
|
||||
<div class="calendar">
|
||||
<.month days_of_month={days_of_month}></.month>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user