Show the division a result came from on the team results page for multi-division tournaments

This commit is contained in:
Kalle
2026-11-09 16:22:09 +02:00
parent 8900020de1
commit 01ec7554d7
4 changed files with 28 additions and 2 deletions

View File

@@ -12,7 +12,7 @@ import * as TeamRepository from "./TeamRepository.server";
import { TEAM } from "./team-constants";
describe("findResultsById", () => {
test("participant who was on the roster at the result's time but left later is not a sub", async () => {
const seedTeamResult = async ({ div }: { div: string | null }) => {
const [owner, formerMember] = await UserFactory.createMany(2);
const team = await TeamFactory.create({
memberUserIds: [owner.id, formerMember.id],
@@ -42,12 +42,20 @@ describe("findResultsById", () => {
placement: 1,
participantCount: 8,
tournamentTeamId: tournamentTeam.id,
div: null,
div,
})),
setResults: new Map(),
},
});
return { team, tournament, formerMember };
};
test("participant who was on the roster at the result's time but left later is not a sub", async () => {
const { team, tournament, formerMember } = await seedTeamResult({
div: null,
});
const { startsAt } = await db
.selectFrom("CalendarEventDate")
.select("startsAt")
@@ -67,6 +75,14 @@ describe("findResultsById", () => {
expect(results).toHaveLength(1);
expect(results[0].subs).toHaveLength(0);
});
test("returns the division the team placed in", async () => {
const { team } = await seedTeamResult({ div: "D2" });
const results = await TeamRepository.findResultsById(team.id);
expect(results[0].div).toBe("D2");
});
});
describe("insertOwnMembership", () => {

View File

@@ -234,6 +234,7 @@ export async function findResultsById(teamId: number) {
"TournamentResult.tournamentId",
"TournamentResult.placement",
"TournamentResult.participantCount",
"TournamentResult.div",
"TournamentTeam.startingBracketIdx",
])
.where("teamId", "=", teamId)
@@ -267,6 +268,7 @@ export async function findResultsById(teamId: number) {
"results.tournamentId",
"results.participantCount",
"results.tournamentTeamId",
"results.div",
"CalendarEvent.name as tournamentName",
"CalendarEventDate.startsAt",
sql<

View File

@@ -71,6 +71,9 @@ export function TeamResultsTable({ results }: TeamResultsTableProps) {
>
{result.tournamentName}
</Link>
{result.div ? (
<span className="text-lighter">({result.div})</span>
) : null}
{result.tier ? <TierPill tier={result.tier} /> : null}
</div>
</td>

View File

@@ -0,0 +1,5 @@
---
navItem: t
type: feature
---
Team results now show the division the team played in for tournaments with several divisions, like user results do