correctly set last_replied_to_at in topics

This commit is contained in:
byte[] 2019-12-22 09:33:07 -05:00
parent 5d6c1d97c1
commit d6592efa0e
2 changed files with 3 additions and 2 deletions

View file

@ -40,6 +40,7 @@ defmodule Philomena.Topics do
"""
def create_topic(forum, attribution, attrs \\ %{}) do
now = DateTime.utc_now() |> DateTime.truncate(:second)
topic =
%Topic{}
|> Topic.creation_changeset(attrs, forum, attribution)
@ -50,7 +51,7 @@ defmodule Philomena.Topics do
{count, nil} =
Topic
|> where(id: ^topic.id)
|> repo.update_all(set: [last_post_id: hd(topic.posts).id])
|> repo.update_all(set: [last_post_id: hd(topic.posts).id, last_replied_to_at: now])
{:ok, count}
end)

View file

@ -24,7 +24,7 @@ defmodule Philomena.Topics.Topic do
field :post_count, :integer, default: 1
field :view_count, :integer, default: 0
field :sticky, :boolean, default: false
field :last_replied_to_at, :naive_datetime
field :last_replied_to_at, :utc_datetime
field :locked_at, :utc_datetime
field :deletion_reason, :string
field :lock_reason, :string