From 278e151eef34ade127bc24c35412efcaf2098321 Mon Sep 17 00:00:00 2001 From: Pascal Schmid Date: Wed, 23 Oct 2024 22:36:20 +0200 Subject: [PATCH] Simplify data structure --- lib/mihainator/extractor.ex | 27 +++++++------------ .../components/result_component.html.heex | 2 +- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/lib/mihainator/extractor.ex b/lib/mihainator/extractor.ex index c3444e4..1dab693 100644 --- a/lib/mihainator/extractor.ex +++ b/lib/mihainator/extractor.ex @@ -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 diff --git a/lib/mihainator_web/live/components/result_component.html.heex b/lib/mihainator_web/live/components/result_component.html.heex index 5f285a8..690c90a 100644 --- a/lib/mihainator_web/live/components/result_component.html.heex +++ b/lib/mihainator_web/live/components/result_component.html.heex @@ -2,7 +2,7 @@

This is the result of your history:

- <%= for {_, days_of_month} <- @calendar_dates.interaction_data do %> + <%= for {_, days_of_month} <- @calendar_dates do %>
<.month days_of_month={days_of_month}>