diff --git a/lib/mindwendel/brainstormings.ex b/lib/mindwendel/brainstormings.ex index 53163cc3..3a1bb74b 100644 --- a/lib/mindwendel/brainstormings.ex +++ b/lib/mindwendel/brainstormings.ex @@ -94,8 +94,6 @@ defmodule Mindwendel.Brainstormings do labels: from(idea_label in IdeaLabel, order_by: idea_label.position_order) ]) - # |> update_last_accessed_at() - {:ok, preloaded_brainstorming} end end @@ -249,6 +247,15 @@ defmodule Mindwendel.Brainstormings do Brainstorming.changeset(brainstorming, attrs) end + @doc """ + Updates the last_accessed_at field of a brainstorming. + + ## Examples + + iex> update_last_accessed_at(brainstorming) + %Brainstorming{last_accessed_at: ...} + + """ def update_last_accessed_at(brainstorming) do Repo.update(Brainstorming.changeset_with_upated_last_accessed_at(brainstorming)) brainstorming diff --git a/lib/mindwendel_web/live/brainstorming_live/show.ex b/lib/mindwendel_web/live/brainstorming_live/show.ex index 5e8c4c12..e73d9e82 100644 --- a/lib/mindwendel_web/live/brainstorming_live/show.ex +++ b/lib/mindwendel_web/live/brainstorming_live/show.ex @@ -19,6 +19,7 @@ defmodule MindwendelWeb.BrainstormingLive.Show do case Brainstormings.get_brainstorming(id) do {:ok, brainstorming} -> + Brainstormings.update_last_accessed_at(brainstorming) admin_secret = get_connect_params(socket)["adminSecret"] if Brainstormings.validate_admin_secret(brainstorming, admin_secret) do diff --git a/priv/gettext/de/LC_MESSAGES/default.po b/priv/gettext/de/LC_MESSAGES/default.po index 21e65e48..566b3ffc 100644 --- a/priv/gettext/de/LC_MESSAGES/default.po +++ b/priv/gettext/de/LC_MESSAGES/default.po @@ -26,12 +26,12 @@ msgstr "Wie können wir ..." msgid "Ready?" msgstr "Fertig?" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:199 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:200 #, elixir-autogen, elixir-format msgid "%{name} - Edit" msgstr "%{name} - Editieren" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:176 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:177 #, elixir-autogen, elixir-format msgid "%{name} - New Idea" msgstr "%{name} - Neue Idee" @@ -385,7 +385,7 @@ msgstr "Löschen" msgid "Type the label name" msgstr "Gebe dem Label einen Namen" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:186 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:187 #, elixir-autogen, elixir-format, fuzzy msgid "%{name} - New Lane" msgstr "%{name} - Neue Idee" @@ -563,7 +563,7 @@ msgstr "Detailansicht" msgid "Give moderating permissions" msgstr "Änderungen erlauben" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:50 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:51 #, elixir-autogen, elixir-format, fuzzy msgid "Brainstorming not found" msgstr "Brainstorming konnte nicht gefunden werden" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 4bb7f3d2..89c16423 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -25,12 +25,12 @@ msgstr "" msgid "Ready?" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:199 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:200 #, elixir-autogen, elixir-format msgid "%{name} - Edit" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:176 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:177 #, elixir-autogen, elixir-format msgid "%{name} - New Idea" msgstr "" @@ -384,7 +384,7 @@ msgstr "" msgid "Type the label name" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:186 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:187 #, elixir-autogen, elixir-format msgid "%{name} - New Lane" msgstr "" @@ -562,7 +562,7 @@ msgstr "" msgid "Give moderating permissions" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:50 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:51 #, elixir-autogen, elixir-format msgid "Brainstorming not found" msgstr "" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index 0b95e7b6..bb844c35 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -26,12 +26,12 @@ msgstr "" msgid "Ready?" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:199 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:200 #, elixir-autogen, elixir-format msgid "%{name} - Edit" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:176 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:177 #, elixir-autogen, elixir-format msgid "%{name} - New Idea" msgstr "" @@ -385,7 +385,7 @@ msgstr "" msgid "Type the label name" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:186 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:187 #, elixir-autogen, elixir-format, fuzzy msgid "%{name} - New Lane" msgstr "" @@ -563,7 +563,7 @@ msgstr "" msgid "Give moderating permissions" msgstr "" -#: lib/mindwendel_web/live/brainstorming_live/show.ex:50 +#: lib/mindwendel_web/live/brainstorming_live/show.ex:51 #, elixir-autogen, elixir-format, fuzzy msgid "Brainstorming not found" msgstr "" diff --git a/test/mindwendel/brainstormings_test.exs b/test/mindwendel/brainstormings_test.exs index 8516a25a..16772359 100644 --- a/test/mindwendel/brainstormings_test.exs +++ b/test/mindwendel/brainstormings_test.exs @@ -27,6 +27,14 @@ defmodule Mindwendel.BrainstormingsTest do } end + describe "update_last_accessed_at" do + test "updates the last accessed at field", %{brainstorming: brainstorming} do + Brainstormings.update_last_accessed_at(brainstorming) + {:ok, refreshed_brainstorming} = Brainstormings.get_brainstorming(brainstorming.id) + refute refreshed_brainstorming.last_accessed_at == nil + end + end + describe "update_brainstorming" do test "updates the brainstorming with filter_labels_ids", %{brainstorming: brainstorming} do filter_label = Enum.at(brainstorming.labels, 0)