mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-09 12:46:10 -05:00
Download checked in participants sorted by registration time
This commit is contained in:
@@ -15,6 +15,7 @@ const stm = sql.prepare(/*sql*/ `
|
||||
"TournamentTeam"."id",
|
||||
"TournamentTeam"."name",
|
||||
"TournamentTeam"."seed",
|
||||
"TournamentTeam"."createdAt",
|
||||
"TournamentTeamCheckIn"."checkedInAt",
|
||||
"TournamentTeam"."prefersNotToHost",
|
||||
json_group_array(
|
||||
@@ -53,6 +54,7 @@ export interface FindTeamsByTournamentIdItem {
|
||||
id: TournamentTeam["id"];
|
||||
name: TournamentTeam["name"];
|
||||
seed: TournamentTeam["seed"];
|
||||
createdAt: TournamentTeam["createdAt"];
|
||||
checkedInAt: TournamentTeamCheckIn["checkedInAt"] | null;
|
||||
prefersNotToHost: TournamentTeam["prefersNotToHost"];
|
||||
members: Array<
|
||||
|
||||
@@ -47,6 +47,7 @@ import { Avatar } from "~/components/Avatar";
|
||||
import { TrashIcon } from "~/components/icons/Trash";
|
||||
import { FormMessage } from "~/components/FormMessage";
|
||||
import { Label } from "~/components/Label";
|
||||
import { databaseTimestampToDate } from "~/utils/dates";
|
||||
|
||||
export const action: ActionFunction = async ({ request, params }) => {
|
||||
const user = await requireUserId(request);
|
||||
@@ -630,6 +631,28 @@ function DownloadParticipants() {
|
||||
.join("\n");
|
||||
}
|
||||
|
||||
function checkedInParticipantsContent() {
|
||||
const header = "Teams ordered by registration time\n---\n";
|
||||
|
||||
return (
|
||||
header +
|
||||
data.teams
|
||||
.slice()
|
||||
.sort((a, b) => a.createdAt - b.createdAt)
|
||||
.filter((team) => team.checkedInAt)
|
||||
.map((team, i) => {
|
||||
return `${i + 1}) ${team.name} - ${databaseTimestampToDate(
|
||||
team.createdAt,
|
||||
).toISOString()} - ${team.members
|
||||
.map(
|
||||
(member) => `${discordFullName(member)} - <@${member.discordId}>`,
|
||||
)
|
||||
.join(" / ")}`;
|
||||
})
|
||||
.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
function notCheckedInParticipantsContent() {
|
||||
return data.teams
|
||||
.slice()
|
||||
@@ -668,6 +691,17 @@ function DownloadParticipants() {
|
||||
>
|
||||
All participants
|
||||
</Button>
|
||||
<Button
|
||||
size="tiny"
|
||||
onClick={() =>
|
||||
handleDownload({
|
||||
filename: "checked-in-participants.txt",
|
||||
content: checkedInParticipantsContent(),
|
||||
})
|
||||
}
|
||||
>
|
||||
Checked in participants
|
||||
</Button>
|
||||
<Button
|
||||
size="tiny"
|
||||
onClick={() =>
|
||||
|
||||
Reference in New Issue
Block a user