From 3d66ff432a48acfa0f2ff0e15a7ede4c5a970338 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Fri, 6 Dec 2019 17:36:08 -0500 Subject: [PATCH] update topic last reply date --- lib/philomena/posts.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/philomena/posts.ex b/lib/philomena/posts.ex index cf0c79b8..2c39ca7c 100644 --- a/lib/philomena/posts.ex +++ b/lib/philomena/posts.ex @@ -43,6 +43,8 @@ defmodule Philomena.Posts do """ def create_post(topic, attributes, params \\ %{}) do + now = DateTime.utc_now() + topic_query = Topic |> where(id: ^topic.id) @@ -67,7 +69,7 @@ defmodule Philomena.Posts do end) |> Multi.run(:update_topic, fn repo, %{post: %{id: post_id}} -> {count, nil} = - repo.update_all(topic_query, inc: [post_count: 1], set: [last_post_id: post_id]) + repo.update_all(topic_query, inc: [post_count: 1], set: [last_post_id: post_id, last_replied_to_at: now]) {:ok, count} end)