Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Member realName #42

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 26 additions & 22 deletions lib/epochtalk_server/smf_query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ defmodule EpochtalkServer.SmfQuery do
where: t.id_board not in ^id_board_blacklist,
order_by: [desc: t.id_last_msg]
)
|> join(:left, [t], m in "smf_messages", on: t.id_first_msg == m.id_msg)
|> join(:left, [t], m in "smf_messages", on: t.id_last_msg == m.id_msg)
|> join(:left, [t], b in "smf_boards", on: t.id_board == b.id_board)
|> select([t, f, l, b], %{
|> join(:left, [t], f in "smf_messages", on: t.id_first_msg == f.id_msg)
|> join(:left, [t, f], l in "smf_messages", on: t.id_last_msg == l.id_msg)
|> join(:left, [t, f, l], lm in "smf_members", on: l.id_member == lm.id_member)
|> join(:left, [t, f, l, lm], b in "smf_boards", on: t.id_board == b.id_board)
|> select([t, f, l, lm, b], %{
id: t.id_topic,
slug: t.id_topic,
board_id: t.id_board,
Expand All @@ -132,7 +133,7 @@ defmodule EpochtalkServer.SmfQuery do
updated_at: l.posterTime * @ms_per_sec,
last_post_created_at: l.posterTime * @ms_per_sec,
last_post_user_id: l.id_member,
last_post_username: l.posterName,
last_post_username: lm.realName,
view_count: t.numViews,
last_post_position: nil,
last_post_deleted: false,
Expand Down Expand Up @@ -209,7 +210,7 @@ defmodule EpochtalkServer.SmfQuery do
id: b.id_board,
last_post_created_at: m.posterTime * @ms_per_sec,
last_post_position: t.numReplies,
last_post_username: m.posterName,
last_post_username: u.realName,
last_post_user_id: m.id_member,
last_post_avatar:
fragment(
Expand Down Expand Up @@ -306,12 +307,13 @@ defmodule EpochtalkServer.SmfQuery do
order_by: [desc: t.id_last_msg]
)
|> join(:left, [t], f in "smf_messages", on: t.id_first_msg == f.id_msg)
|> join(:left, [t], l in "smf_messages", on: t.id_last_msg == l.id_msg)
|> join(:left, [t, f, l], m in "smf_members", on: l.id_member == m.id_member)
|> join(:left, [t, f, l, m], a in "smf_attachments",
on: m.id_member == a.id_member and a.attachmentType == 1
|> join(:left, [t, f], fm in "smf_members", on: f.id_member == fm.id_member)
|> join(:left, [t, f, fm], l in "smf_messages", on: t.id_last_msg == l.id_msg)
|> join(:left, [t, f, fm, l], lm in "smf_members", on: l.id_member == lm.id_member)
|> join(:left, [t, f, fm, l, lm], a in "smf_attachments",
on: lm.id_member == a.id_member and a.attachmentType == 1
)
|> select([t, f, l, m, a], %{
|> select([t, f, fm, l, lm, a], %{
id: t.id_topic,
slug: t.id_topic,
board_id: t.id_board,
Expand All @@ -326,19 +328,19 @@ defmodule EpochtalkServer.SmfQuery do
post_count: t.numReplies,
title: f.subject,
user_id: f.id_member,
username: f.posterName,
username: fm.realName,
created_at: f.posterTime * @ms_per_sec,
user_deleted: false,
last_post_created_at: l.posterTime * @ms_per_sec,
last_post_deleted: false,
last_post_user_id: l.id_member,
last_post_username: l.posterName,
last_post_username: lm.realName,
last_post_user_deleted: false,
last_post_avatar:
fragment(
"if(? <>'',concat('https://bitcointalk.org/avatars/',?),ifnull(concat('https://bitcointalk.org/useravatars/',?),''))",
m.avatar,
m.avatar,
lm.avatar,
lm.avatar,
a.filename
),
last_viewed: nil,
Expand All @@ -355,9 +357,11 @@ defmodule EpochtalkServer.SmfQuery do
where: t.id_topic == ^id and t.id_board not in ^id_board_blacklist
)
# get first and last message for thread
|> join(:left, [t], m in "smf_messages", on: t.id_first_msg == m.id_msg)
|> join(:left, [t], m in "smf_messages", on: t.id_last_msg == m.id_msg)
|> select([t, f, l], %{
|> join(:left, [t], f in "smf_messages", on: t.id_first_msg == f.id_msg)
|> join(:left, [t, f], fm in "smf_members", on: f.id_member == fm.id_member)
|> join(:left, [t, f, fm], l in "smf_messages", on: t.id_last_msg == l.id_msg)
|> join(:left, [t, f, fm, l], lm in "smf_members", on: l.id_member == lm.id_member)
|> select([t, f, fm, l, lm], %{
id: t.id_topic,
slug: t.id_topic,
board_id: t.id_board,
Expand All @@ -372,13 +376,13 @@ defmodule EpochtalkServer.SmfQuery do
post_count: t.numReplies,
title: f.subject,
user_id: f.id_member,
username: f.posterName,
username: fm.realName,
created_at: f.posterTime * @ms_per_sec,
user_deleted: false,
last_post_created_at: l.posterTime * @ms_per_sec,
last_post_deleted: false,
last_post_user_id: l.id_member,
last_post_username: l.posterName,
last_post_username: lm.realName,
last_post_user_deleted: false,
last_viewed: nil
})
Expand Down Expand Up @@ -448,7 +452,7 @@ defmodule EpochtalkServer.SmfQuery do
title: m.subject,
body: m.body,
updated_at: m.modifiedTime,
username: m.posterName,
username: u.realName,
created_at: m.posterTime * @ms_per_sec,
modified_time: m.modifiedTime,
avatar:
Expand All @@ -460,7 +464,7 @@ defmodule EpochtalkServer.SmfQuery do
),
user: %{
id: m.id_member,
username: m.posterName,
username: u.realName,
signature: u.signature,
activity: u.activity,
merit: u.merit,
Expand Down
Loading