Fix API response too large :)
This commit is contained in:
@@ -27,8 +27,8 @@ function updateState(newState : string, newLane : number) {
|
|||||||
<!-- <div style="display: flex; width: fit-content; margin: auto; margin-left: 330px;"> -->
|
<!-- <div style="display: flex; width: fit-content; margin: auto; margin-left: 330px;"> -->
|
||||||
<div style="margin-top: 64px; margin-left: 339px;">
|
<div style="margin-top: 64px; margin-left: 339px;">
|
||||||
<ChampionTitle v-if="championData.gameCount > 0" :champion-id="championId" :winrate="lane.winrate" :pickrate="lane.pickrate" :game-count="lane.count" />
|
<ChampionTitle v-if="championData.gameCount > 0" :champion-id="championId" :winrate="lane.winrate" :pickrate="lane.pickrate" :game-count="lane.count" />
|
||||||
<RuneSelector v-if="state == 'runes' && championData.gameCount > 0" style="margin: auto; margin-top: 40px;" :runes="lane.runes" />
|
<RuneSelector v-if="state == 'runes' && championData.gameCount > 0" style="margin: auto; margin-top: 40px;" :runes="lane.runes!!" />
|
||||||
<ItemViewer v-if="state == 'items' && championData.gameCount > 0" style="margin:auto; margin-top: 40px;" :builds="lane.builds" />
|
<ItemViewer v-if="state == 'items' && championData.gameCount > 0" style="margin:auto; margin-top: 40px;" :builds="lane.builds!!" />
|
||||||
<h2 v-if="championData.gameCount == 0" style="margin: auto; margin-top: 20px; width: fit-content;">Sorry, there is no data for this champion :(</h2>
|
<h2 v-if="championData.gameCount == 0" style="margin: auto; margin-top: 20px; width: fit-content;">Sorry, there is no data for this champion :(</h2>
|
||||||
</div>
|
</div>
|
||||||
<!-- <ItemViewer v-if="championData.gameCount > 0" style="margin-top: 64px; margin-left: 64px;" :builds="championData.builds" /> -->
|
<!-- <ItemViewer v-if="championData.gameCount > 0" style="margin-top: 64px; margin-left: 64px;" :builds="championData.builds" /> -->
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
|
import { MongoClient } from 'mongodb';
|
||||||
import {connectToDatabase, fetchLatestPatch} from '../utils/mongo'
|
import {connectToDatabase, fetchLatestPatch} from '../utils/mongo'
|
||||||
|
|
||||||
async function champions(client, patch) {
|
async function champions(client: MongoClient, patch: string) {
|
||||||
const database = client.db("champions");
|
const database = client.db("champions");
|
||||||
const collection = database.collection(patch);
|
const collection = database.collection(patch);
|
||||||
const data = await collection.find().toArray()
|
const data : Array<ChampionData> = (await collection.find().toArray()) as unknown as Array<ChampionData>
|
||||||
data.map((x) => {
|
data.map((x) => {
|
||||||
delete x.runes
|
for(let lane of x.lanes) {
|
||||||
delete x.builds
|
delete lane.builds
|
||||||
|
delete lane.runes
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (_) => {
|
||||||
const client = await connectToDatabase();
|
const client = await connectToDatabase();
|
||||||
const latestPatch = await fetchLatestPatch(client);
|
const latestPatch = await fetchLatestPatch(client);
|
||||||
|
|
||||||
@@ -25,8 +25,8 @@ declare global {
|
|||||||
losingMatches: number
|
losingMatches: number
|
||||||
winrate: number
|
winrate: number
|
||||||
pickrate: number
|
pickrate: number
|
||||||
runes: Array<Rune>
|
runes?: Array<Rune>
|
||||||
builds: Builds
|
builds?: Builds
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChampionData = {
|
type ChampionData = {
|
||||||
|
|||||||
Reference in New Issue
Block a user