Skip to content

Commit 07b9741

Browse files
committed
refactor: use select_merge for additional fields
1 parent 9396519 commit 07b9741

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

lib/algora/accounts/accounts.ex

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -152,31 +152,10 @@ defmodule Algora.Accounts do
152152
|> apply_criteria(criteria)
153153
|> order_by([earnings: e], desc_nulls_last: e.total_earned)
154154
|> order_by([u], desc: u.id)
155-
|> select([u, earnings: e, transactions: t, projects: p], %{
156-
type: u.type,
157-
id: u.id,
158-
handle: u.handle,
159-
name: u.name,
160-
provider_login: u.provider_login,
161-
provider_meta: u.provider_meta,
162-
linkedin_url: u.linkedin_url,
163-
linkedin_meta: u.linkedin_meta,
164-
employment_info: u.employment_info,
165-
location_iso_lvl4: u.location_iso_lvl4,
166-
avatar_url: u.avatar_url,
167-
bio: u.bio,
168-
system_bio: u.system_bio,
169-
system_tags: u.system_tags,
170-
min_compensation: u.min_compensation,
171-
location: u.location,
172-
country: u.country,
173-
tech_stack: u.tech_stack,
155+
|> select_merge([u, earnings: e, transactions: t, projects: p], %{
174156
total_earned: Algora.SQL.money_or_zero(e.total_earned),
175157
transactions_count: coalesce(t.transactions_count, 0),
176-
contributed_projects_count: coalesce(p.projects_count, 0),
177-
hourly_rate_min: u.hourly_rate_min,
178-
hourly_rate_max: u.hourly_rate_max,
179-
hours_per_week: u.hours_per_week
158+
contributed_projects_count: coalesce(p.projects_count, 0)
180159
})
181160
|> Repo.all()
182161
|> Enum.map(&User.after_load/1)

0 commit comments

Comments
 (0)