Skip to content

Commit

Permalink
Merge pull request #74 from ItKlubBozoLagan/dev
Browse files Browse the repository at this point in the history
Fix UI
  • Loading branch information
Antony1060 authored Nov 11, 2024
2 parents 661a64d + 6a1c54d commit c119471
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
36 changes: 28 additions & 8 deletions apps/backend/src/routes/contest/ContestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,16 @@ ContestHandler.get("/:contest_id/leaderboard", async (req, res) => {
)
).flat();

const eduUsers = (
await Promise.all(
R.chunk(contestMembers, 100).map((chunk) => {
return Database.selectFrom("edu_users", "*", {
id: eqIn(...chunk.map((it) => it.user_id)),
});
})
)
).flat();

const organisationMembers = await Database.selectFrom(
"organisation_members",
"*",
Expand All @@ -460,14 +470,24 @@ ContestHandler.get("/:contest_id/leaderboard", async (req, res) => {
res,
StatusCodes.OK,
contestMembers
.map((it, _, __, user = users.find((user) => user.id === it.user_id)!) => ({
...it,
...R.pick(user, ["full_name"]),
...R.pick(organisationMembers.find((member) => member.user_id === it.user_id)!, [
"elo",
]),
email_domain: user.email.split("@").at(-1),
}))
.map(
(
it,
_,
__,
user = users.find((user) => user.id === it.user_id)!,
eduUser = eduUsers.find((user) => user.id === it.user_id)
) => ({
...it,
...R.pick(user, ["full_name"]),
...R.pick(
organisationMembers.find((member) => member.user_id === it.user_id)!,
["elo"]
),
email_domain: user.email.split("@").at(-1),
edu_mail_domain: eduUser?.email.split("@").at(-1),
})
)
.map((it) => ({ ...it, score: it.score ?? {} }))
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,14 @@ OrganisationMemberHandler.get("/", async (req, res) => {
id: eqIn(...organisationMembers.map((organisationMember) => organisationMember.user_id)),
});

const eduUsers = await Database.selectFrom("edu_users", "*", {
id: eqIn(...organisationMembers.map((organisationMember) => organisationMember.user_id)),
});

return respond(
res,
StatusCodes.OK,
organisationMembers.map(
(
it,
_,
__,
user = users.find((user) => user.id === it.user_id)!,
eduUser = eduUsers.find((user) => user.id === it.user_id)
) => ({
(it, _, __, user = users.find((user) => user.id === it.user_id)!) => ({
...it,
...R.pick(user, ["full_name"]),
email_domain: user.email.split("@").at(-1),
edu_mail_domain: eduUser?.email.split("@").at(-1),
})
)
);
Expand Down

0 comments on commit c119471

Please sign in to comment.