Skip to content

Commit

Permalink
feat(last-active): bring back last post date for last active in user …
Browse files Browse the repository at this point in the history
…find
  • Loading branch information
akinsey committed Nov 5, 2024
1 parent 8cde747 commit f618c32
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/epochtalk_server_web/helpers/proxy_conversion.ex
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ defmodule EpochtalkServerWeb.Helpers.ProxyConversion do
end

def build_user(user_id) do
from(u in "smf_members", where: u.id_member == ^user_id)
last_active =
from m in "smf_messages",
where: m.id_member == ^user_id,
order_by: [desc: m.posterTime],
limit: 1,
select: %{last_active: m.posterTime * 1000}

user = from(u in "smf_members", where: u.id_member == ^user_id)
|> join(:left, [u], a in "smf_attachments",
on: u.id_member == a.id_member and a.attachmentType == 1
)
Expand All @@ -94,7 +101,6 @@ defmodule EpochtalkServerWeb.Helpers.ProxyConversion do
gender: u.gender,
id: u.id_member,
language: nil,
last_active: nil,
location: u.location,
merit: u.merit,
id_group: u.id_group,
Expand All @@ -114,6 +120,10 @@ defmodule EpochtalkServerWeb.Helpers.ProxyConversion do
)
})
|> SmfRepo.one()

if user.post_count > 0,
do: Map.merge(user, SmfRepo.one(last_active)),
else: Map.put(user, :last_active, user.created_at)
end

def build_poll(thread_id) do
Expand Down

0 comments on commit f618c32

Please sign in to comment.