Skip to content

Commit

Permalink
fix: reset views on app restart
Browse files Browse the repository at this point in the history
  • Loading branch information
abehidek committed Dec 10, 2023
1 parent d11e080 commit 5b4dc4f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/hidek_xyz/content/live_views.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,17 @@ defmodule HidekXyz.Content.LiveViews do
nil ->
%View{} =
db_content_view =
Repo.insert!(%View{count: 1, slug: slug}, on_conflict: [inc: [count: 1]])
case Repo.get_by(View, slug: slug) do
nil -> Repo.insert!(%View{count: 1, slug: slug})
%View{} = view -> view
end

# %View{} =
# db_content_view =
# Repo.insert!(%View{count: 1, slug: slug}, on_conflict: [inc: [count: 1]])

new_content_view = %ContentViews{
count: db_content_view.count
count: db_content_view.count + 1
}

new_state =
Expand Down

0 comments on commit 5b4dc4f

Please sign in to comment.