mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-22 05:13:09 +01:00
correctly set last_replied_to_at in topics
This commit is contained in:
parent
5d6c1d97c1
commit
d6592efa0e
2 changed files with 3 additions and 2 deletions
|
@ -40,6 +40,7 @@ defmodule Philomena.Topics do
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def create_topic(forum, attribution, attrs \\ %{}) do
|
def create_topic(forum, attribution, attrs \\ %{}) do
|
||||||
|
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||||
topic =
|
topic =
|
||||||
%Topic{}
|
%Topic{}
|
||||||
|> Topic.creation_changeset(attrs, forum, attribution)
|
|> Topic.creation_changeset(attrs, forum, attribution)
|
||||||
|
@ -50,7 +51,7 @@ defmodule Philomena.Topics do
|
||||||
{count, nil} =
|
{count, nil} =
|
||||||
Topic
|
Topic
|
||||||
|> where(id: ^topic.id)
|
|> 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}
|
{:ok, count}
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -24,7 +24,7 @@ defmodule Philomena.Topics.Topic do
|
||||||
field :post_count, :integer, default: 1
|
field :post_count, :integer, default: 1
|
||||||
field :view_count, :integer, default: 0
|
field :view_count, :integer, default: 0
|
||||||
field :sticky, :boolean, default: false
|
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 :locked_at, :utc_datetime
|
||||||
field :deletion_reason, :string
|
field :deletion_reason, :string
|
||||||
field :lock_reason, :string
|
field :lock_reason, :string
|
||||||
|
|
Loading…
Reference in a new issue