Skip to content

Commit

Permalink
use explicit last accessed
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek committed Dec 19, 2024
1 parent 87bbef8 commit c52094e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
11 changes: 9 additions & 2 deletions lib/mindwendel/brainstormings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/mindwendel_web/live/brainstorming_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions priv/gettext/de/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
8 changes: 4 additions & 4 deletions priv/gettext/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down Expand Up @@ -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 ""
Expand Down Expand Up @@ -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 ""
8 changes: 4 additions & 4 deletions priv/gettext/en/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down Expand Up @@ -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 ""
Expand Down Expand Up @@ -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 ""
8 changes: 8 additions & 0 deletions test/mindwendel/brainstormings_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c52094e

Please sign in to comment.