mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-10 21:26:08 -05:00
Fix wrong players showing in result tables
This commit is contained in:
2
TODO.md
2
TODO.md
@@ -23,7 +23,7 @@ Calendar
|
||||
|
||||
## Other
|
||||
|
||||
- [ ] can submit results with one invalid linked user
|
||||
- [x] can submit results with one invalid linked user
|
||||
- [x] Redirect to event page after submitting results
|
||||
- [x] date input take in account time zone difference between server and client
|
||||
- [x] User selector allow passing users from top level
|
||||
|
||||
@@ -218,11 +218,11 @@ const findWinnersByEventIdStm = sql.prepare(`
|
||||
"User"."discordId" as "playerDiscordId",
|
||||
"User"."discordAvatar" as "playerDiscordAvatar"
|
||||
from "CalendarEventResultTeam"
|
||||
join
|
||||
left join
|
||||
"CalendarEventResultPlayer"
|
||||
on
|
||||
"CalendarEventResultPlayer"."teamId" = "CalendarEventResultTeam"."id"
|
||||
join
|
||||
left join
|
||||
"User"
|
||||
on
|
||||
"User"."id" = "CalendarEventResultPlayer"."userId"
|
||||
@@ -289,6 +289,7 @@ const findResultsByUserIdStm = sql.prepare(`
|
||||
select
|
||||
"CalendarEvent"."id" as "eventId",
|
||||
"CalendarEvent"."name" as "eventName",
|
||||
"CalendarEventResultTeam"."id" as "teamId",
|
||||
"CalendarEventResultTeam"."name" as "teamName",
|
||||
"CalendarEventResultTeam"."placement",
|
||||
"CalendarEvent"."participantCount",
|
||||
@@ -314,16 +315,21 @@ const findMatesByResultTeamIdStm = sql.prepare(`
|
||||
"User"."discordId" as "discordId",
|
||||
"User"."discordAvatar" as "discordAvatar"
|
||||
from "CalendarEventResultPlayer"
|
||||
join "User"
|
||||
left join "User"
|
||||
on "User"."id" = "CalendarEventResultPlayer"."userId"
|
||||
where "teamId" = $teamId
|
||||
and "userId" != $userId
|
||||
and (
|
||||
"CalendarEventResultPlayer"."userId" is null
|
||||
or
|
||||
"CalendarEventResultPlayer"."userId" != $userId
|
||||
)
|
||||
`);
|
||||
|
||||
export function findResultsByUserId(userId: User["id"]) {
|
||||
return (
|
||||
findResultsByUserIdStm.all({ userId }) as Array<{
|
||||
eventId: CalendarEvent["id"];
|
||||
teamId: CalendarEventResultTeam["id"];
|
||||
eventName: CalendarEvent["name"];
|
||||
teamName: CalendarEventResultTeam["name"];
|
||||
placement: CalendarEventResultTeam["placement"];
|
||||
@@ -334,7 +340,7 @@ export function findResultsByUserId(userId: User["id"]) {
|
||||
...row,
|
||||
mates: (
|
||||
findMatesByResultTeamIdStm.all({
|
||||
teamId: row.eventId,
|
||||
teamId: row.teamId,
|
||||
userId,
|
||||
}) as Array<{
|
||||
name: CalendarEventResultPlayer["name"];
|
||||
|
||||
@@ -189,7 +189,10 @@ function Results() {
|
||||
<td>
|
||||
<ul className="event__results-players">
|
||||
{result.players.map((player) => (
|
||||
<li key={typeof player === "string" ? player : player.id}>
|
||||
<li
|
||||
key={typeof player === "string" ? player : player.id}
|
||||
className="flex items-center"
|
||||
>
|
||||
{typeof player === "string" ? (
|
||||
player
|
||||
) : (
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Avatar } from "~/components/Avatar";
|
||||
import { Section } from "~/components/Section";
|
||||
import { databaseTimestampToDate } from "~/utils/dates";
|
||||
import { discordFullName, placementString } from "~/utils/strings";
|
||||
import { userPage } from "~/utils/urls";
|
||||
import { calendarEventPage, userPage } from "~/utils/urls";
|
||||
import type { UserPageLoaderData } from "../u.$identifier";
|
||||
|
||||
export default function UserResultsPage() {
|
||||
@@ -23,7 +23,7 @@ export default function UserResultsPage() {
|
||||
<th>Team</th>
|
||||
<th>Tournament</th>
|
||||
<th>Date</th>
|
||||
<th>Members</th>
|
||||
<th>Mates</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -33,7 +33,11 @@ export default function UserResultsPage() {
|
||||
{placementString(result.placement)}
|
||||
</td>
|
||||
<td>{result.teamName}</td>
|
||||
<td>{result.eventName}</td>
|
||||
<td>
|
||||
<Link to={calendarEventPage(result.eventId)}>
|
||||
{result.eventName}
|
||||
</Link>
|
||||
</td>
|
||||
<td>
|
||||
{databaseTimestampToDate(result.startTime).toLocaleDateString(
|
||||
i18n.language,
|
||||
|
||||
Reference in New Issue
Block a user