Skip to content

Commit

Permalink
feat(user-find): initial db query for user find, updated to query by …
Browse files Browse the repository at this point in the history
…user id instead of username
  • Loading branch information
akinsey committed Oct 22, 2024
1 parent 1a8bfe7 commit fa6bfe5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/epochtalk_server_web/helpers/proxy_conversion.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ defmodule EpochtalkServerWeb.Helpers.ProxyConversion do
"poll.by_thread" ->
build_poll(id)

"user.find" ->
build_user(id)

_ ->
build_model(nil, nil, nil, nil)
end
Expand All @@ -66,6 +69,31 @@ defmodule EpochtalkServerWeb.Helpers.ProxyConversion do
end
end

def build_user(user_id) do
from(u in "smf_members", where: u.id_member == ^user_id)
|> select([u], %{
activity: u.activity,
avatar: u.avatar,
created_at: u.dateRegistered * 1000,
dob: u.birthdate,
gender: u.gender,
id: u.id_member,
language: nil,
last_active: nil,
location: u.location,
merit: u.merit,
id_group: u.id_group,
id_post_group: u.id_post_group,
signature: u.signature,
posts: u.posts,
name: u.realName,
username: u.realName,
title: u.usertitle,
website: u.websiteUrl
})
|> SmfRepo.one()
end

def build_poll(thread_id) do
from(t in "smf_topics",
where: t.id_topic == ^thread_id
Expand Down

0 comments on commit fa6bfe5

Please sign in to comment.