mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 15:48:23 -05:00
Remove redundant isOwner column (#2944)
This commit is contained in:
@@ -355,13 +355,12 @@ function finalizedBracket() {
|
||||
for (let j = 0; j < 4; j++) {
|
||||
sql
|
||||
.prepare(
|
||||
`insert into "TournamentTeamMember" ("tournamentTeamId", "userId", "isOwner", "createdAt", "role")
|
||||
values ($tournamentTeamId, $userId, $isOwner, $createdAt, $role)`,
|
||||
`insert into "TournamentTeamMember" ("tournamentTeamId", "userId", "createdAt", "role")
|
||||
values ($tournamentTeamId, $userId, $createdAt, $role)`,
|
||||
)
|
||||
.run({
|
||||
tournamentTeamId: teamId,
|
||||
userId: userIds.shift()!,
|
||||
isOwner: j === 0 ? 1 : 0,
|
||||
createdAt: dateToDatabaseTimestamp(new Date()),
|
||||
role: j === 0 ? "OWNER" : "REGULAR",
|
||||
});
|
||||
@@ -1738,13 +1737,11 @@ function calendarEventWithToToolsTeams(
|
||||
insert into "TournamentTeamMember" (
|
||||
"tournamentTeamId",
|
||||
"userId",
|
||||
"isOwner",
|
||||
"createdAt",
|
||||
"role"
|
||||
) values (
|
||||
$tournamentTeamId,
|
||||
$userId,
|
||||
$isOwner,
|
||||
$createdAt,
|
||||
$role
|
||||
)
|
||||
@@ -1753,7 +1750,6 @@ function calendarEventWithToToolsTeams(
|
||||
.run({
|
||||
tournamentTeamId: id + teamIdAddition,
|
||||
userId,
|
||||
isOwner: i === 0 ? 1 : 0,
|
||||
createdAt: dateToDatabaseTimestamp(yesterday),
|
||||
role: i === 0 ? "OWNER" : "REGULAR",
|
||||
});
|
||||
|
||||
@@ -826,7 +826,6 @@ export interface TournamentTeamCheckIn {
|
||||
|
||||
export interface TournamentTeamMember {
|
||||
createdAt: Generated<number>;
|
||||
isOwner: Generated<number>;
|
||||
inGameName: string | null;
|
||||
tournamentTeamId: number;
|
||||
userId: number;
|
||||
|
||||
@@ -84,7 +84,7 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
|
||||
"User.country",
|
||||
"User.pronouns",
|
||||
"TournamentTeamMember.inGameName",
|
||||
"TournamentTeamMember.isOwner",
|
||||
"TournamentTeamMember.role",
|
||||
"TournamentTeamMember.createdAt",
|
||||
"RankedSeedingSkill.ordinal as rankedOrdinal",
|
||||
"UnrankedSeedingSkill.ordinal as unrankedOrdinal",
|
||||
@@ -140,7 +140,7 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
|
||||
? `https://cdn.discordapp.com/avatars/${member.discordId}/${member.discordAvatar}.png`
|
||||
: null,
|
||||
country: member.country,
|
||||
captain: Boolean(member.isOwner),
|
||||
captain: member.role === "OWNER",
|
||||
inGameName: member.inGameName,
|
||||
pronouns: member.pronouns,
|
||||
friendCode: friendCodes[member.userId],
|
||||
|
||||
@@ -13,7 +13,6 @@ const createMember = (userId: number) =>
|
||||
twitch: null,
|
||||
plusTier: null,
|
||||
createdAt: 0,
|
||||
isOwner: 0,
|
||||
inGameName: null,
|
||||
streamTwitch: null,
|
||||
streamViewerCount: null,
|
||||
|
||||
@@ -1057,7 +1057,7 @@ export class Tournament {
|
||||
|
||||
return this.ctx.teams.find((team) =>
|
||||
team.members.some(
|
||||
(member) => member.userId === user.id && member.isOwner,
|
||||
(member) => member.userId === user.id && member.role === "OWNER",
|
||||
),
|
||||
) as (typeof this.ctx.teams)[number] & { inviteCode: string };
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ describe("tournamentSummary()", () => {
|
||||
username: "test",
|
||||
inGameName: "test",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
plusTier: null,
|
||||
createdAt: 0,
|
||||
userId,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -399,14 +399,13 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "plussy",
|
||||
country: "AU",
|
||||
twitch: "plus218",
|
||||
isOwner: 1,
|
||||
createdAt: 1734656039,
|
||||
inGameName: "Plussy#1291",
|
||||
plusTier: null,
|
||||
streamTwitch: null,
|
||||
streamViewerCount: null,
|
||||
streamThumbnailUrl: null,
|
||||
role: "REGULAR",
|
||||
role: "OWNER",
|
||||
},
|
||||
{
|
||||
userId: 2899,
|
||||
@@ -416,7 +415,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "chimera_",
|
||||
country: "AU",
|
||||
twitch: "mikamikax_",
|
||||
isOwner: 0,
|
||||
createdAt: 1734656044,
|
||||
inGameName: "CHIMERA#1263",
|
||||
plusTier: null,
|
||||
@@ -433,7 +431,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "zalph",
|
||||
country: "SO",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734656047,
|
||||
inGameName: "CountMeOut#1985",
|
||||
plusTier: null,
|
||||
@@ -450,7 +447,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: null,
|
||||
country: "ST",
|
||||
twitch: "tigersplat",
|
||||
isOwner: 0,
|
||||
createdAt: 1734664082,
|
||||
inGameName: "BIDOOFGMAX#8251",
|
||||
plusTier: null,
|
||||
@@ -467,7 +463,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "2021_spl",
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734674285,
|
||||
inGameName: "Bugha 33#1316",
|
||||
plusTier: null,
|
||||
@@ -513,14 +508,13 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "kojuke",
|
||||
country: "NZ",
|
||||
twitch: null,
|
||||
isOwner: 1,
|
||||
createdAt: 1734423187,
|
||||
inGameName: "☆ SD-J ☆#2947",
|
||||
plusTier: null,
|
||||
streamTwitch: null,
|
||||
streamViewerCount: null,
|
||||
streamThumbnailUrl: null,
|
||||
role: "REGULAR",
|
||||
role: "OWNER",
|
||||
},
|
||||
{
|
||||
userId: 21689,
|
||||
@@ -530,7 +524,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "voidedparadigm",
|
||||
country: "AU",
|
||||
twitch: "voidedparadigm",
|
||||
isOwner: 0,
|
||||
createdAt: 1734424893,
|
||||
inGameName: "parasyka#2169",
|
||||
plusTier: null,
|
||||
@@ -547,7 +540,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "cookie",
|
||||
country: "AU",
|
||||
twitch: "cookie_spl",
|
||||
isOwner: 0,
|
||||
createdAt: 1734426984,
|
||||
inGameName: "cookie♪#1006",
|
||||
plusTier: null,
|
||||
@@ -564,7 +556,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "qu",
|
||||
country: "BF",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734426986,
|
||||
inGameName: null,
|
||||
plusTier: null,
|
||||
@@ -605,14 +596,13 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "telethia",
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 1,
|
||||
createdAt: 1734660846,
|
||||
inGameName: "Telethia#6611",
|
||||
plusTier: null,
|
||||
streamTwitch: null,
|
||||
streamViewerCount: null,
|
||||
streamThumbnailUrl: null,
|
||||
role: "REGULAR",
|
||||
role: "OWNER",
|
||||
},
|
||||
{
|
||||
userId: 13370,
|
||||
@@ -622,7 +612,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "puma",
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734660856,
|
||||
inGameName: "Puma#2209",
|
||||
plusTier: null,
|
||||
@@ -639,7 +628,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "shockwavee",
|
||||
country: "AU",
|
||||
twitch: "shockwavee03",
|
||||
isOwner: 0,
|
||||
createdAt: 1734660882,
|
||||
inGameName: "ShockWavee#3003",
|
||||
plusTier: null,
|
||||
@@ -656,7 +644,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: null,
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734663143,
|
||||
inGameName: null,
|
||||
plusTier: null,
|
||||
@@ -697,14 +684,13 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "mitsi",
|
||||
country: "PS",
|
||||
twitch: null,
|
||||
isOwner: 1,
|
||||
createdAt: 1734683349,
|
||||
inGameName: "mitsi#2589",
|
||||
plusTier: null,
|
||||
streamTwitch: null,
|
||||
streamViewerCount: null,
|
||||
streamThumbnailUrl: null,
|
||||
role: "REGULAR",
|
||||
role: "OWNER",
|
||||
},
|
||||
{
|
||||
userId: 13590,
|
||||
@@ -714,7 +700,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "canary",
|
||||
country: "AU",
|
||||
twitch: "sanityzed",
|
||||
isOwner: 0,
|
||||
createdAt: 1734683352,
|
||||
inGameName: "☆ SD-N ☆#2936",
|
||||
plusTier: null,
|
||||
@@ -731,7 +716,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "wilds",
|
||||
country: "AU",
|
||||
twitch: "whilds",
|
||||
isOwner: 0,
|
||||
createdAt: 1734683356,
|
||||
inGameName: "Wilds ♪#6274",
|
||||
plusTier: null,
|
||||
@@ -748,7 +732,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: null,
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734683966,
|
||||
inGameName: "2F Law#1355",
|
||||
plusTier: null,
|
||||
@@ -765,7 +748,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "silly_b3",
|
||||
country: "AU",
|
||||
twitch: "silly_b3",
|
||||
isOwner: 0,
|
||||
createdAt: 1734685180,
|
||||
inGameName: "His Silly#2385",
|
||||
plusTier: null,
|
||||
@@ -811,14 +793,13 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: null,
|
||||
country: "AU",
|
||||
twitch: "veemo_ai",
|
||||
isOwner: 1,
|
||||
createdAt: 1734608907,
|
||||
inGameName: "H! Veems#3106",
|
||||
plusTier: null,
|
||||
streamTwitch: null,
|
||||
streamViewerCount: null,
|
||||
streamThumbnailUrl: null,
|
||||
role: "REGULAR",
|
||||
role: "OWNER",
|
||||
},
|
||||
{
|
||||
userId: 29665,
|
||||
@@ -828,7 +809,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: null,
|
||||
country: "AU",
|
||||
twitch: "sounkade",
|
||||
isOwner: 0,
|
||||
createdAt: 1734608923,
|
||||
inGameName: "H!PwPwPew#2889",
|
||||
plusTier: null,
|
||||
@@ -845,7 +825,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: null,
|
||||
country: "AU",
|
||||
twitch: "ozzysqid",
|
||||
isOwner: 0,
|
||||
createdAt: 1734608925,
|
||||
inGameName: "H!Ozzysqid#2558",
|
||||
plusTier: null,
|
||||
@@ -862,7 +841,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "koifu",
|
||||
country: "AU",
|
||||
twitch: "koifu_spl",
|
||||
isOwner: 0,
|
||||
createdAt: 1734608931,
|
||||
inGameName: "DrkXWolf17#3326",
|
||||
plusTier: null,
|
||||
@@ -879,7 +857,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: null,
|
||||
country: "PH",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734659216,
|
||||
inGameName: "Slanted#1646",
|
||||
plusTier: null,
|
||||
@@ -896,7 +873,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: null,
|
||||
country: null,
|
||||
twitch: "shade_is_special",
|
||||
isOwner: 0,
|
||||
createdAt: 1734684084,
|
||||
inGameName: null,
|
||||
plusTier: null,
|
||||
@@ -937,14 +913,13 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "albonchap",
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 1,
|
||||
createdAt: 1734397954,
|
||||
inGameName: "Albonchap#9998",
|
||||
plusTier: null,
|
||||
streamTwitch: null,
|
||||
streamViewerCount: null,
|
||||
streamThumbnailUrl: null,
|
||||
role: "REGULAR",
|
||||
role: "OWNER",
|
||||
},
|
||||
{
|
||||
userId: 43662,
|
||||
@@ -954,7 +929,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: null,
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734397970,
|
||||
inGameName: "FoolLime#1864",
|
||||
plusTier: null,
|
||||
@@ -971,7 +945,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: null,
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734397973,
|
||||
inGameName: "snowy#2709",
|
||||
plusTier: null,
|
||||
@@ -988,7 +961,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "verygoodnegg",
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734398287,
|
||||
inGameName: "Veryneggy#1494",
|
||||
plusTier: null,
|
||||
@@ -1005,7 +977,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: null,
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734398628,
|
||||
inGameName: "Mikil#2961",
|
||||
plusTier: null,
|
||||
@@ -1051,14 +1022,13 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "dit-toad",
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 1,
|
||||
createdAt: 1734598652,
|
||||
inGameName: "ЯR Dit-toe#3315",
|
||||
plusTier: null,
|
||||
streamTwitch: null,
|
||||
streamViewerCount: null,
|
||||
streamThumbnailUrl: null,
|
||||
role: "REGULAR",
|
||||
role: "OWNER",
|
||||
},
|
||||
{
|
||||
userId: 33611,
|
||||
@@ -1068,7 +1038,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: null,
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734598655,
|
||||
inGameName: "ЯR Samkat #3138",
|
||||
plusTier: null,
|
||||
@@ -1085,7 +1054,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: "cakeatstake",
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734598656,
|
||||
inGameName: "ЯR smart!!#1424",
|
||||
plusTier: null,
|
||||
@@ -1102,7 +1070,6 @@ export const ZONES_WEEKLY_38 = (): TournamentData => ({
|
||||
customUrl: null,
|
||||
country: "AU",
|
||||
twitch: null,
|
||||
isOwner: 0,
|
||||
createdAt: 1734612388,
|
||||
inGameName: "Mat#1561",
|
||||
plusTier: null,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -379,7 +379,6 @@ describe("updateMemberRole", () => {
|
||||
.values({
|
||||
tournamentTeamId: team.id,
|
||||
userId: 2,
|
||||
isOwner: 0,
|
||||
role: "REGULAR",
|
||||
})
|
||||
.execute();
|
||||
@@ -490,7 +489,6 @@ describe("leaveLfg", () => {
|
||||
.values({
|
||||
tournamentTeamId: team.id,
|
||||
userId: 1,
|
||||
isOwner: 1,
|
||||
role: "OWNER",
|
||||
})
|
||||
.execute();
|
||||
|
||||
@@ -42,7 +42,6 @@ export function createPlaceholderTeam(args: CreatePlaceholderTeamArgs) {
|
||||
.values({
|
||||
tournamentTeamId: createdTeam.id,
|
||||
userId: args.userId,
|
||||
isOwner: 1,
|
||||
role: "OWNER",
|
||||
isStayAsSub: args.isStayAsSub ? 1 : 0,
|
||||
})
|
||||
|
||||
@@ -61,7 +61,8 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
|
||||
|
||||
if (team) {
|
||||
const member = team.members.find((m) => m.userId === user.id);
|
||||
const canManageTeam = member?.isOwner || member?.role === "MANAGER";
|
||||
const canManageTeam =
|
||||
member?.role === "OWNER" || member?.role === "MANAGER";
|
||||
errorToastIfFalsy(
|
||||
canManageTeam,
|
||||
"Only team owners and managers can join the queue",
|
||||
|
||||
@@ -160,7 +160,7 @@ async function resolveOwnTeam({
|
||||
languages: [],
|
||||
vc: null,
|
||||
pronouns: null,
|
||||
role: m.isOwner ? "OWNER" : m.role === "MANAGER" ? "MANAGER" : "REGULAR",
|
||||
role: m.role,
|
||||
isStayAsSub: false,
|
||||
weapons: null,
|
||||
plusTier: m.plusTier,
|
||||
|
||||
@@ -178,7 +178,6 @@ export async function findById(id: number) {
|
||||
"User.twitch",
|
||||
"SeedingSkill.ordinal",
|
||||
"PlusTier.tier as plusTier",
|
||||
"TournamentTeamMember.isOwner",
|
||||
"TournamentTeamMember.role",
|
||||
"TournamentTeamMember.createdAt",
|
||||
sql<string | null> /*sql*/`coalesce(
|
||||
|
||||
@@ -148,7 +148,6 @@ export function create({
|
||||
.values({
|
||||
tournamentTeamId: tournamentTeam.id,
|
||||
userId,
|
||||
isOwner: 1,
|
||||
role: "OWNER",
|
||||
inGameName: ownerInGameName,
|
||||
})
|
||||
@@ -197,7 +196,7 @@ export function copyFromAnotherTournament({
|
||||
.select([
|
||||
"TournamentTeamMember.createdAt",
|
||||
"TournamentTeamMember.inGameName",
|
||||
"TournamentTeamMember.isOwner",
|
||||
"TournamentTeamMember.role",
|
||||
"TournamentTeamMember.userId",
|
||||
|
||||
// -- exclude these
|
||||
|
||||
@@ -102,7 +102,7 @@ export const action: ActionFunction = async ({ request, params }) => {
|
||||
validateIsTournamentOrganizer();
|
||||
const team = tournament.teamById(data.teamId);
|
||||
errorToastIfFalsy(team, "Invalid team id");
|
||||
const oldCaptain = team.members.find((m) => m.isOwner);
|
||||
const oldCaptain = team.members.find((m) => m.role === "OWNER");
|
||||
invariant(oldCaptain, "Team has no captain");
|
||||
const newCaptain = team.members.find((m) => m.userId === data.memberId);
|
||||
errorToastIfFalsy(newCaptain, "Invalid member id");
|
||||
@@ -191,7 +191,7 @@ export const action: ActionFunction = async ({ request, params }) => {
|
||||
"Can't remove last member from checked in team",
|
||||
);
|
||||
errorToastIfFalsy(
|
||||
!team.members.find((m) => m.userId === data.memberId)?.isOwner,
|
||||
team.members.find((m) => m.userId === data.memberId)?.role !== "OWNER",
|
||||
"Cannot remove team owner",
|
||||
);
|
||||
errorToastIfFalsy(
|
||||
|
||||
@@ -77,7 +77,7 @@ export const action: ActionFunction = async ({ request, params }) => {
|
||||
const whatToDoWithPreviousTeam = !previousTeam
|
||||
? undefined
|
||||
: previousTeam.members.some(
|
||||
(member) => member.userId === user.id && member.isOwner,
|
||||
(member) => member.userId === user.id && member.role === "OWNER",
|
||||
)
|
||||
? "DELETE"
|
||||
: "LEAVE";
|
||||
|
||||
@@ -73,10 +73,10 @@ export function TeamWithRoster({
|
||||
|
||||
return (
|
||||
<li key={member.userId} className={styles.teamMemberRow}>
|
||||
{member.isOwner ? (
|
||||
{member.role === "OWNER" ? (
|
||||
<span className={`${styles.teamMemberNameRole}`}>C</span>
|
||||
) : null}
|
||||
{isSub && !member.isOwner ? (
|
||||
{isSub && member.role !== "OWNER" ? (
|
||||
<span
|
||||
className={`${styles.teamMemberNameRole} ${styles.teamMemberNameRoleSub}`}
|
||||
>
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { Tables } from "~/db/tables";
|
||||
|
||||
const stm = sql.prepare(/* sql */ `
|
||||
update TournamentTeamMember
|
||||
set "isOwner" = @isOwner
|
||||
set "role" = @role
|
||||
where
|
||||
"tournamentTeamId" = @tournamentTeamId and
|
||||
"userId" = @userId
|
||||
@@ -18,13 +18,13 @@ export const changeTeamOwner = sql.transaction(
|
||||
stm.run({
|
||||
tournamentTeamId: args.tournamentTeamId,
|
||||
userId: args.oldCaptainId,
|
||||
isOwner: 0,
|
||||
role: "REGULAR",
|
||||
});
|
||||
|
||||
stm.run({
|
||||
tournamentTeamId: args.tournamentTeamId,
|
||||
userId: args.newCaptainId,
|
||||
isOwner: 1,
|
||||
role: "OWNER",
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
@@ -11,9 +11,9 @@ const stm = sql.prepare(/*sql*/ `
|
||||
"TournamentTeam"
|
||||
left join "TournamentTeamCheckIn" on
|
||||
"TournamentTeamCheckIn"."tournamentTeamId" = "TournamentTeam"."id"
|
||||
left join "TournamentTeamMember" on
|
||||
"TournamentTeamMember"."tournamentTeamId" = "TournamentTeam"."id"
|
||||
and "TournamentTeamMember"."isOwner" = 1
|
||||
left join "TournamentTeamMember" on
|
||||
"TournamentTeamMember"."tournamentTeamId" = "TournamentTeam"."id"
|
||||
and "TournamentTeamMember"."role" = 'OWNER'
|
||||
where
|
||||
"TournamentTeam"."tournamentId" = @tournamentId
|
||||
and "TournamentTeam"."isPlaceholder" = 0
|
||||
|
||||
@@ -534,10 +534,10 @@ function DownloadParticipants() {
|
||||
.slice()
|
||||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
.map((team) => {
|
||||
const owner = team.members.find((user) => user.isOwner);
|
||||
const owner = team.members.find((user) => user.role === "OWNER");
|
||||
invariant(owner);
|
||||
|
||||
const nonOwners = team.members.filter((user) => !user.isOwner);
|
||||
const nonOwners = team.members.filter((user) => user.role !== "OWNER");
|
||||
|
||||
let result = `-- ${team.name} --\n(C) ${owner.username} (IGN: ${owner.inGameName ?? ""}) - <@${owner.discordId}>`;
|
||||
|
||||
|
||||
@@ -1162,7 +1162,7 @@ function DeleteMember({ members }: { members: TournamentDataTeam["members"] }) {
|
||||
<div className="stack md horizontal">
|
||||
<select name="userId" id={id}>
|
||||
{members
|
||||
.filter((member) => !member.isOwner)
|
||||
.filter((member) => member.role !== "OWNER")
|
||||
.map((member) => (
|
||||
<option key={member.userId} value={member.userId}>
|
||||
{member.username}
|
||||
|
||||
@@ -103,7 +103,6 @@ describe("syncLiveStreams tournament streamers", () => {
|
||||
country: null,
|
||||
twitch: "player_one",
|
||||
plusTier: null,
|
||||
isOwner: 1,
|
||||
role: "OWNER",
|
||||
createdAt: 0,
|
||||
streamTwitch: null,
|
||||
@@ -144,7 +143,6 @@ describe("syncLiveStreams tournament streamers", () => {
|
||||
country: null,
|
||||
twitch: "dropped_player",
|
||||
plusTier: null,
|
||||
isOwner: 1,
|
||||
role: "OWNER",
|
||||
createdAt: 0,
|
||||
streamTwitch: null,
|
||||
@@ -198,7 +196,6 @@ describe("syncLiveStreams tournament streamers", () => {
|
||||
country: null,
|
||||
twitch: "different_account",
|
||||
plusTier: null,
|
||||
isOwner: 1,
|
||||
role: "OWNER",
|
||||
createdAt: 0,
|
||||
streamTwitch: null,
|
||||
@@ -235,7 +232,6 @@ describe("syncLiveStreams tournament streamers", () => {
|
||||
country: null,
|
||||
twitch: "streamer_a",
|
||||
plusTier: null,
|
||||
isOwner: 1,
|
||||
role: "OWNER",
|
||||
createdAt: 0,
|
||||
streamTwitch: null,
|
||||
@@ -275,7 +271,6 @@ describe("syncLiveStreams tournament streamers", () => {
|
||||
country: null,
|
||||
twitch: "streamer_b",
|
||||
plusTier: null,
|
||||
isOwner: 1,
|
||||
role: "OWNER",
|
||||
createdAt: 0,
|
||||
streamTwitch: null,
|
||||
|
||||
BIN
db-test.sqlite3
BIN
db-test.sqlite3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14
migrations/131-tournament-team-member-drop-is-owner.js
Normal file
14
migrations/131-tournament-team-member-drop-is-owner.js
Normal file
@@ -0,0 +1,14 @@
|
||||
export function up(db) {
|
||||
db.transaction(() => {
|
||||
db.prepare(
|
||||
/* sql */ `update "TournamentTeamMember" set "role" = 'OWNER' where "isOwner" = 1 and "role" != 'OWNER'`,
|
||||
).run();
|
||||
db.prepare(
|
||||
/* sql */ `update "TournamentTeamMember" set "role" = 'REGULAR' where "isOwner" = 0 and "role" = 'OWNER'`,
|
||||
).run();
|
||||
|
||||
db.prepare(
|
||||
/* sql */ `alter table "TournamentTeamMember" drop column "isOwner"`,
|
||||
).run();
|
||||
})();
|
||||
}
|
||||
Reference in New Issue
Block a user