Compare commits
2 Commits
ba4e6f4d17
...
a9e2ca5cf6
| Author | SHA1 | Date | |
|---|---|---|---|
| a9e2ca5cf6 | |||
| 9fd15de094 |
@@ -1,6 +1,6 @@
|
|||||||
defmodule Mihainator.Extractor do
|
defmodule Mihainator.Extractor do
|
||||||
@moduledoc """
|
@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
|
def extract(file) do
|
||||||
|
|||||||
@@ -20,7 +20,13 @@ defmodule MihainatorWeb.DayComponent do
|
|||||||
classes = get_button_classes(info)
|
classes = get_button_classes(info)
|
||||||
style = get_button_style(day)
|
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}
|
{:ok, socket}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,9 +5,12 @@ defmodule MihainatorWeb.ResultComponent do
|
|||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def update(assigns, socket) do
|
def update(assigns, socket) do
|
||||||
months = get_one_day_for_each_month(assigns.calendar_dates)
|
socket =
|
||||||
|
assign(
|
||||||
socket = assign(socket, assigns: assigns, months: months)
|
socket,
|
||||||
|
assigns: assigns,
|
||||||
|
months: get_first_day_of_each_month(assigns.calendar_dates)
|
||||||
|
)
|
||||||
|
|
||||||
{:ok, socket}
|
{:ok, socket}
|
||||||
end
|
end
|
||||||
@@ -15,9 +18,12 @@ defmodule MihainatorWeb.ResultComponent do
|
|||||||
def month(%{day: day_info} = assigns) do
|
def month(%{day: day_info} = assigns) do
|
||||||
parsed_day = get_date(day_info)
|
parsed_day = get_date(day_info)
|
||||||
|
|
||||||
formatted_month = parsed_day |> Calendar.strftime("%B")
|
assigns =
|
||||||
|
assign(
|
||||||
assigns = assign(assigns, formatted_month: formatted_month, year: parsed_day.year)
|
assigns,
|
||||||
|
formatted_month: Calendar.strftime(parsed_day, "%B"),
|
||||||
|
year: parsed_day.year
|
||||||
|
)
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<div class="text-center border-b pb-2 text-slate-700 dark:text-slate-300">
|
<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)
|
||||||
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)
|
Map.keys(calendar_dates)
|
||||||
|> Enum.sort()
|
|> Enum.sort()
|
||||||
|> Enum.filter(fn x -> String.ends_with?(x, "-01") end)
|
|> Enum.filter(fn x -> String.ends_with?(x, "-01") end)
|
||||||
|
|||||||
Reference in New Issue
Block a user