mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-09 04:02:40 -05:00
Remove unused code
This commit is contained in:
parent
b35f5d9921
commit
84e1868aa0
|
|
@ -17,7 +17,6 @@ import createBuildAbilitySql from "./createBuildAbility.sql";
|
|||
import countByUserIdSql from "./countByUserId.sql";
|
||||
import buildsByUserIdSql from "./buildsByUserId.sql";
|
||||
import buildsByWeaponIdSql from "./buildsByWeaponId.sql";
|
||||
import recentBuildsSql from "./recentBuilds.sql";
|
||||
import deleteByIdSql from "./deleteById.sql";
|
||||
|
||||
const createBuildStm = sql.prepare(createBuildSql);
|
||||
|
|
@ -26,7 +25,6 @@ const createBuildAbilityStm = sql.prepare(createBuildAbilitySql);
|
|||
const countByUserIdStm = sql.prepare(countByUserIdSql);
|
||||
const buildsByUserIdStm = sql.prepare(buildsByUserIdSql);
|
||||
const buildsByWeaponIdStm = sql.prepare(buildsByWeaponIdSql);
|
||||
const recentBuildsStm = sql.prepare(recentBuildsSql);
|
||||
const deleteByIdStm = sql.prepare(deleteByIdSql);
|
||||
|
||||
interface CreateArgs {
|
||||
|
|
@ -131,12 +129,6 @@ export function buildsByWeaponId({
|
|||
return rows.map(augmentBuild);
|
||||
}
|
||||
|
||||
export function recentBuilds() {
|
||||
const rows = recentBuildsStm.all() as Array<BuildsByWeaponIdRow>;
|
||||
|
||||
return rows.map(augmentBuild);
|
||||
}
|
||||
|
||||
function augmentBuild<T>(
|
||||
row: T & { modes: Build["modes"]; weapons: string; abilities: string }
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
with "RecentBuild" as (
|
||||
select
|
||||
*
|
||||
from
|
||||
"Build"
|
||||
order by
|
||||
"updatedAt" desc
|
||||
limit
|
||||
3
|
||||
), "BuildFiltered" as (
|
||||
select
|
||||
"id",
|
||||
"title",
|
||||
"description",
|
||||
"modes",
|
||||
"headGearSplId",
|
||||
"clothesGearSplId",
|
||||
"shoesGearSplId",
|
||||
"updatedAt",
|
||||
"ownerId"
|
||||
from
|
||||
"RecentBuild"
|
||||
left join "BuildWeapon" on "BuildWeapon"."buildId" = "RecentBuild"."id"
|
||||
group by
|
||||
"RecentBuild"."id"
|
||||
),
|
||||
"BuildWithWeapon" as (
|
||||
select
|
||||
"BuildFiltered".*,
|
||||
json_group_array("BuildWeapon"."weaponSplId") as "weapons"
|
||||
from
|
||||
"BuildFiltered"
|
||||
left join "BuildWeapon" on "BuildWeapon"."buildId" = "BuildFiltered"."id"
|
||||
group by
|
||||
"BuildFiltered"."id"
|
||||
)
|
||||
select
|
||||
"BuildWithWeapon".*,
|
||||
"User"."discordId",
|
||||
"User"."discordName",
|
||||
"User"."discordDiscriminator",
|
||||
json_group_array(
|
||||
json_object(
|
||||
'ability',
|
||||
"BuildAbility"."ability",
|
||||
'gearType',
|
||||
"BuildAbility"."gearType",
|
||||
'slotIndex',
|
||||
"BuildAbility"."slotIndex"
|
||||
)
|
||||
) as "abilities"
|
||||
from
|
||||
"BuildWithWeapon"
|
||||
left join "BuildAbility" on "BuildAbility"."buildId" = "BuildWithWeapon"."id"
|
||||
left join "PlusTier" on "PlusTier"."userId" = "BuildWithWeapon"."ownerId"
|
||||
left join "User" on "User"."id" = "BuildWithWeapon"."ownerId"
|
||||
group by
|
||||
"BuildWithWeapon"."id"
|
||||
|
|
@ -31,8 +31,6 @@ import findByIdSql from "./findById.sql";
|
|||
import startTimesOfRangeSql from "./startTimesOfRange.sql";
|
||||
import findBadgesByEventIdSql from "./findBadgesByEventId.sql";
|
||||
import eventsToReportSql from "./eventsToReport.sql";
|
||||
import recentWinnersSql from "./recentWinners.sql";
|
||||
import upcomingEventsSql from "./upcomingEvents.sql";
|
||||
import createMapPoolMapSql from "./createMapPoolMap.sql";
|
||||
import deleteMapPoolMapsSql from "./deleteMapPoolMaps.sql";
|
||||
import createTieBreakerMapPoolMapSql from "./createTieBreakerMapPoolMap.sql";
|
||||
|
|
@ -305,67 +303,6 @@ export function findResultsByUserId(userId: User["id"]) {
|
|||
}));
|
||||
}
|
||||
|
||||
const recentWinnersStm = sql.prepare(recentWinnersSql);
|
||||
export function recentWinners() {
|
||||
const rows = recentWinnersStm.all() as Array<{
|
||||
eventId: CalendarEventResultTeam["eventId"];
|
||||
eventName: CalendarEvent["name"];
|
||||
startTime: CalendarEventDate["startTime"];
|
||||
teamName: CalendarEventResultTeam["name"];
|
||||
playerId: CalendarEventResultPlayer["userId"];
|
||||
playerName: CalendarEventResultPlayer["name"];
|
||||
playerDiscordName: User["discordName"] | null;
|
||||
playerDiscordDiscriminator: User["discordDiscriminator"] | null;
|
||||
playerDiscordId: User["discordId"] | null;
|
||||
playerDiscordAvatar: User["discordAvatar"];
|
||||
}>;
|
||||
|
||||
const result: Array<{
|
||||
eventId: CalendarEventResultTeam["eventId"];
|
||||
eventName: CalendarEvent["name"];
|
||||
teamName: CalendarEventResultTeam["name"];
|
||||
startTime: CalendarEventDate["startTime"];
|
||||
players: Array<
|
||||
| string
|
||||
| Pick<
|
||||
User,
|
||||
| "id"
|
||||
| "discordId"
|
||||
| "discordName"
|
||||
| "discordDiscriminator"
|
||||
| "discordAvatar"
|
||||
>
|
||||
>;
|
||||
}> = [];
|
||||
|
||||
for (const row of rows) {
|
||||
const player = row.playerName ?? {
|
||||
// player name and user id are mutually exclusive
|
||||
// also if user id exists we know a joined user also has to exist
|
||||
id: row.playerId!,
|
||||
discordId: row.playerDiscordId!,
|
||||
discordName: row.playerDiscordName!,
|
||||
discordDiscriminator: row.playerDiscordDiscriminator!,
|
||||
discordAvatar: row.playerDiscordAvatar,
|
||||
};
|
||||
|
||||
const team = result.find((team) => team.eventId === row.eventId);
|
||||
if (team) {
|
||||
team.players.push(player);
|
||||
} else {
|
||||
result.push({
|
||||
eventId: row.eventId,
|
||||
eventName: row.eventName,
|
||||
teamName: row.teamName,
|
||||
startTime: row.startTime,
|
||||
players: [player],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const findAllBetweenTwoTimestampsStm = sql.prepare(
|
||||
findAllBetweenTwoTimestampsSql
|
||||
);
|
||||
|
|
@ -434,21 +371,6 @@ export function findById(id: CalendarEvent["id"]) {
|
|||
});
|
||||
}
|
||||
|
||||
const upcomingEventsStm = sql.prepare(upcomingEventsSql);
|
||||
export function upcomingEvents() {
|
||||
const rows = upcomingEventsStm.all({
|
||||
now: dateToDatabaseTimestamp(new Date()),
|
||||
}) as Array<{
|
||||
eventId: CalendarEvent["id"];
|
||||
eventName: CalendarEvent["name"];
|
||||
tags: CalendarEvent["tags"];
|
||||
startTime: CalendarEventDate["startTime"];
|
||||
hasBadge: number;
|
||||
}>;
|
||||
|
||||
return rows.map(addTagArray).map(addBadges);
|
||||
}
|
||||
|
||||
function addBadges<
|
||||
T extends { eventId: CalendarEvent["id"]; tags?: CalendarEvent["tags"] }
|
||||
>(arg: T) {
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
with "RecentEvents" as (
|
||||
select
|
||||
"CalendarEventResultTeam"."eventId",
|
||||
"CalendarEvent"."name" as "eventName",
|
||||
"CalendarEventResultTeam"."id" as "teamId",
|
||||
"CalendarEventDate"."startTime",
|
||||
"CalendarEventResultTeam"."name" as "teamName"
|
||||
from
|
||||
"CalendarEventDate"
|
||||
inner join "CalendarEventResultTeam" on "CalendarEventResultTeam"."eventId" = "CalendarEventDate"."eventId"
|
||||
and "CalendarEventResultTeam"."placement" = 1
|
||||
inner join "CalendarEvent" on "CalendarEvent"."id" = "CalendarEventResultTeam"."eventId"
|
||||
group by
|
||||
"CalendarEventDate"."eventId"
|
||||
order by
|
||||
"CalendarEventDate"."startTime" desc
|
||||
limit
|
||||
3
|
||||
)
|
||||
select
|
||||
"RecentEvents"."eventId",
|
||||
"RecentEvents"."eventName",
|
||||
"RecentEvents"."startTime",
|
||||
"RecentEvents"."teamName",
|
||||
"CalendarEventResultPlayer"."userId" as "playerId",
|
||||
"CalendarEventResultPlayer"."name" as "playerName",
|
||||
"User"."discordName" as "playerDiscordName",
|
||||
"User"."discordDiscriminator" as "playerDiscordDiscriminator",
|
||||
"User"."discordId" as "playerDiscordId",
|
||||
"User"."discordAvatar" as "playerDiscordAvatar"
|
||||
from
|
||||
"RecentEvents"
|
||||
left join "CalendarEventResultPlayer" on "CalendarEventResultPlayer"."teamId" = "RecentEvents"."teamId"
|
||||
left join "User" on "User"."id" = "CalendarEventResultPlayer"."userId";
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
select
|
||||
"CalendarEvent"."id" as "eventId",
|
||||
"CalendarEvent"."name" as "eventName",
|
||||
"CalendarEvent"."tags",
|
||||
"CalendarEventDate"."startTime",
|
||||
exists (
|
||||
select
|
||||
1
|
||||
from
|
||||
"CalendarEventBadge"
|
||||
where
|
||||
"CalendarEventBadge"."eventId" = "CalendarEvent"."id"
|
||||
) as "hasBadge"
|
||||
from
|
||||
"CalendarEventDate"
|
||||
inner join "CalendarEvent" on "CalendarEvent"."id" = "CalendarEventDate"."eventId"
|
||||
where
|
||||
"CalendarEventDate"."startTime" > @now
|
||||
group by
|
||||
"CalendarEventDate"."eventId"
|
||||
order by
|
||||
"CalendarEventDate"."startTime" asc
|
||||
limit
|
||||
3
|
||||
Loading…
Reference in New Issue
Block a user