Compare commits

..

2 Commits

Author SHA1 Message Date
a9e2ca5cf6 Adjust moduledoc 2024-11-02 16:16:20 +01:00
9fd15de094 Refactor code 2024-11-02 16:15:21 +01:00
3 changed files with 21 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
defmodule Mihainator.Extractor do
@moduledoc """
This module will take Threema's CSV history file and parse dates / first interaction of day
This module will take Threema's CSV history file and parse dates / interaction patterns per day
"""
def extract(file) do

View File

@@ -20,7 +20,13 @@ defmodule MihainatorWeb.DayComponent do
classes = get_button_classes(info)
style = get_button_style(day)
socket = assign(socket, classes: classes, day: parsed_day.day, style: style)
socket =
assign(
socket,
classes: classes,
day: parsed_day.day,
style: style
)
{:ok, socket}
end

View File

@@ -5,9 +5,12 @@ defmodule MihainatorWeb.ResultComponent do
@impl true
def update(assigns, socket) do
months = get_one_day_for_each_month(assigns.calendar_dates)
socket = assign(socket, assigns: assigns, months: months)
socket =
assign(
socket,
assigns: assigns,
months: get_first_day_of_each_month(assigns.calendar_dates)
)
{:ok, socket}
end
@@ -15,9 +18,12 @@ defmodule MihainatorWeb.ResultComponent do
def month(%{day: day_info} = assigns) do
parsed_day = get_date(day_info)
formatted_month = parsed_day |> Calendar.strftime("%B")
assigns = assign(assigns, formatted_month: formatted_month, year: parsed_day.year)
assigns =
assign(
assigns,
formatted_month: Calendar.strftime(parsed_day, "%B"),
year: parsed_day.year
)
~H"""
<div class="text-center border-b pb-2 text-slate-700 dark:text-slate-300">
@@ -41,7 +47,7 @@ defmodule MihainatorWeb.ResultComponent do
end)
end
defp get_one_day_for_each_month(calendar_dates) do
defp get_first_day_of_each_month(calendar_dates) do
Map.keys(calendar_dates)
|> Enum.sort()
|> Enum.filter(fn x -> String.ends_with?(x, "-01") end)