feat: filter characters by daily mode in fruit loading functions
Build Docker Image / build (push) Successful in 1m33s
Build Docker Image / build (push) Successful in 1m33s
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { db } from '$lib/server/db';
|
import { db } from '$lib/server/db';
|
||||||
import { character, devilFruit, devilFruitHistory, type DevilFruit, type Character } from '$lib/server/db/schema';
|
import { character, devilFruit, devilFruitHistory, type DevilFruit, type Character } from '$lib/server/db/schema';
|
||||||
import { desc, eq, and } from 'drizzle-orm';
|
import { eq, and } from 'drizzle-orm';
|
||||||
|
|
||||||
// Generate or get random seed for daily fruit selection
|
// Generate or get random seed for daily fruit selection
|
||||||
const RANDOM_SEED = Math.random();
|
const RANDOM_SEED = Math.random();
|
||||||
@@ -42,6 +42,7 @@ export async function getCharactersWithDevilFruit(): Promise<CharacterWithFruit[
|
|||||||
.select(characterWithFruitSelect)
|
.select(characterWithFruitSelect)
|
||||||
.from(character)
|
.from(character)
|
||||||
.leftJoin(devilFruit, eq(character.devilFruitId, devilFruit.id))
|
.leftJoin(devilFruit, eq(character.devilFruitId, devilFruit.id))
|
||||||
|
.where(eq(character.isInDailyMode, true))
|
||||||
.all()) as any[];
|
.all()) as any[];
|
||||||
|
|
||||||
return rows.filter((r) => r.devilFruitId) as CharacterWithFruit[];
|
return rows.filter((r) => r.devilFruitId) as CharacterWithFruit[];
|
||||||
@@ -52,6 +53,7 @@ export async function getAllDevilFruitsFromCharacters(): Promise<DevilFruit[]> {
|
|||||||
.select(characterWithFruitSelect)
|
.select(characterWithFruitSelect)
|
||||||
.from(character)
|
.from(character)
|
||||||
.leftJoin(devilFruit, eq(character.devilFruitId, devilFruit.id))
|
.leftJoin(devilFruit, eq(character.devilFruitId, devilFruit.id))
|
||||||
|
.where(eq(character.isInDailyMode, true))
|
||||||
.all()) as any[];
|
.all()) as any[];
|
||||||
|
|
||||||
const map = new Map<string, DevilFruit>();
|
const map = new Map<string, DevilFruit>();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
import { getAllDevilFruitsFromCharacters, getOrCreateTodayFruit, getYesterdayFruit, getTodayFruitWinsCount } from '$lib/server/daily-fruit';
|
import { getAllDevilFruitsFromCharacters, getOrCreateTodayFruit, getYesterdayFruit, getTodayFruitWinsCount } from '$lib/server/daily-fruit';
|
||||||
import { getAllCharacters } from '$lib/server/daily-character';
|
import { getDailyModeCharacters } from '$lib/server/daily-character';
|
||||||
|
|
||||||
export async function load(event) {
|
export async function load(event) {
|
||||||
const fruits = await getAllDevilFruitsFromCharacters();
|
const fruits = await getAllDevilFruitsFromCharacters();
|
||||||
@@ -12,8 +12,8 @@ export async function load(event) {
|
|||||||
|
|
||||||
const yesterdayFruit = await getYesterdayFruit(new Date());
|
const yesterdayFruit = await getYesterdayFruit(new Date());
|
||||||
|
|
||||||
// Load all characters for searching and filter only those with a devil fruit
|
// Load daily-mode characters for searching and filter only those with a devil fruit
|
||||||
const allCharacters = await getAllCharacters();
|
const allCharacters = await getDailyModeCharacters();
|
||||||
const characters = allCharacters.filter((c) => c.devilFruitId);
|
const characters = allCharacters.filter((c) => c.devilFruitId);
|
||||||
|
|
||||||
// Find the character tied to the chosen fruit among characters that have a devil fruit
|
// Find the character tied to the chosen fruit among characters that have a devil fruit
|
||||||
|
|||||||
Reference in New Issue
Block a user