Skip to content

Commit 9b9986e

Browse files
committed
Merge branch 'v3-test' into v3
2 parents a3fba85 + a785098 commit 9b9986e

19 files changed

Lines changed: 304 additions & 207 deletions

File tree

.github/workflows/ci.yml

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: pnpm/action-setup@v3
2222
- uses: actions/setup-node@v4
2323
with:
24-
node-version: 20.x
24+
node-version: 22.x
2525
cache: pnpm
2626

2727
- name: Install
@@ -37,7 +37,7 @@ jobs:
3737
- uses: pnpm/action-setup@v3
3838
- uses: actions/setup-node@v4
3939
with:
40-
node-version: 20.x
40+
node-version: 22.x
4141
cache: pnpm
4242

4343
- name: Install
@@ -46,43 +46,43 @@ jobs:
4646
- name: Typecheck
4747
run: pnpm run typecheck
4848

49-
build:
50-
runs-on: ubuntu-latest
51-
steps:
52-
- uses: actions/checkout@v4
53-
- uses: pnpm/action-setup@v3
54-
- uses: actions/setup-node@v4
55-
with:
56-
node-version: 20.x
57-
cache: pnpm
49+
# build:
50+
# runs-on: ubuntu-latest
51+
# steps:
52+
# - uses: actions/checkout@v4
53+
# - uses: pnpm/action-setup@v3
54+
# - uses: actions/setup-node@v4
55+
# with:
56+
# node-version: 20.x
57+
# cache: pnpm
5858

59-
- name: Restore cache
60-
uses: actions/cache@v4
61-
with:
62-
path: |
63-
dist
64-
.nuxt
65-
key: ${{ runner.os }}-nuxt-build-${{ hashFiles('dist') }}
66-
restore-keys: |
67-
${{ runner.os }}-nuxt-build-
68-
- name: Install dependencies
69-
run: pnpm install
70-
- name: Static HTML export with Nuxt
71-
run: pnpm run generate
72-
env:
73-
NUXT_APP_BASE_URL: /summoners-summit/
74-
NUXT_PUBLIC_NEED_REDIRECT: true
75-
- name: Upload artifact
76-
uses: actions/upload-pages-artifact@v3
77-
with:
78-
path: ./dist
59+
# - name: Restore cache
60+
# uses: actions/cache@v4
61+
# with:
62+
# path: |
63+
# dist
64+
# .nuxt
65+
# key: ${{ runner.os }}-nuxt-build-${{ hashFiles('dist') }}
66+
# restore-keys: |
67+
# ${{ runner.os }}-nuxt-build-
68+
# - name: Install dependencies
69+
# run: pnpm install
70+
# - name: Static HTML export with Nuxt
71+
# run: pnpm run generate
72+
# env:
73+
# NUXT_APP_BASE_URL: /summoners-summit/
74+
# NUXT_PUBLIC_NEED_REDIRECT: true
75+
# - name: Upload artifact
76+
# uses: actions/upload-pages-artifact@v3
77+
# with:
78+
# path: ./dist
7979

80-
deploy:
81-
needs: build
82-
permissions:
83-
pages: write
84-
id-token: write
85-
runs-on: ubuntu-latest
86-
steps:
87-
- name: Deploy GitHub Pages site
88-
uses: actions/deploy-pages@v4
80+
# deploy:
81+
# needs: build
82+
# permissions:
83+
# pages: write
84+
# id-token: write
85+
# runs-on: ubuntu-latest
86+
# steps:
87+
# - name: Deploy GitHub Pages site
88+
# uses: actions/deploy-pages@v4

app/components/admin/player/AdminPlayerListTable.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<NDataTable
33
:data="data"
44
:columns="columns"
5-
virtual-scroll
65
:loading="loading"
7-
flex-height
6+
:flex-height="true"
7+
:virtual-scroll="true"
88
/>
99
</template>
1010

app/components/admin/tournament/AdminTournamentForm.vue

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,27 @@ const actionCardsWeight = asyncComputed(async () => {
198198
});
199199
provide("actionCardsWeight", actionCardsWeight);
200200
201-
const characterCardNumUsages = ref<Record<CardId, number>>({});
202-
provide("characterCardNumUsages", characterCardNumUsages);
203-
watch(preferredGameVersion, async () => {
204-
const res = await $fetch("/api/v3/cards/getCharacterCardStats", {
205-
params: preferredGameVersion.value ? { preferredGameVersion: preferredGameVersion.value } : undefined,
206-
});
207-
if (res.success) {
208-
characterCardNumUsages.value = Object.fromEntries(
209-
res.characterCardStats.map(item => [
210-
item.cardId,
211-
item.numGames + item.numBanned,
212-
]),
213-
);
201+
const { data: characterCardsUsages } = useLazyFetch("/api/v4/character-cards-usages");
202+
const characterCardsWeight = asyncComputed(async () => {
203+
const weight: Record<CardId, number> = Object.fromEntries(
204+
(characterCardsUsages.value ?? [])
205+
.map(item => [item.cardId, item.numGames]),
206+
);
207+
if (preferredGameVersion.value) {
208+
try {
209+
const res = await $fetch("/api/v4/character-cards-usages", {
210+
query: { gameVersion: preferredGameVersion.value },
211+
});
212+
res.forEach((item) => {
213+
weight[item.cardId] ??= 0;
214+
weight[item.cardId] += item.numGames * 10;
215+
});
216+
}
217+
catch (error) {
218+
console.error(error);
219+
}
214220
}
215-
}, { immediate: true });
221+
return weight;
222+
});
223+
provide("characterCardsWeight", characterCardsWeight);
216224
</script>

app/components/admin/tournament/match/CharacterCardSelector.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const inputValue = ref("");
3131
const autoCompleteRef = ref<InstanceType<typeof NAutoComplete>>();
3232
const popoverRef = ref<InstanceType<typeof NPopover>>();
3333
34-
const characterCardNumUsages = inject<Ref<Record<CardId, number>>>("characterCardNumUsages", ref({}));
34+
const characterCardsWeight = inject<Ref<Record<CardId, number>>>("characterCardsWeight", () => ref({}), true);
3535
const options = computed(() => {
3636
return characterCardIds.value
3737
.flatMap((cardId) => {
@@ -47,7 +47,7 @@ const options = computed(() => {
4747
.sort((option1, option2) => {
4848
if (option1.match[0] === 0 && option2.match[0] !== 0) return -1;
4949
if (option2.match[0] === 0 && option1.match[0] !== 0) return 1;
50-
return (characterCardNumUsages.value[option2.value] ?? 0) - (characterCardNumUsages.value[option1.value] ?? 0);
50+
return (characterCardsWeight.value[option2.value] ?? 0) - (characterCardsWeight.value[option1.value] ?? 0);
5151
});
5252
});
5353

app/components/main/cards/Cards_CharacterPickRateBarChart.vue renamed to app/components/main/cards/CardsCharacterPickRateBarChart.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
<script lang="ts" setup>
2222
import { divide } from "mathjs/number";
2323
24-
type DataType = Awaited<ReturnType<typeof useApiGetCharacterCardStats>>;
25-
const characterCardStats = inject<DataType["characterCardStats"]>("characterCardStats", computed(() => []));
26-
const numMatches = inject<DataType["numMatches"]>("numMatches", computed(() => 0));
24+
const props = defineProps<{
25+
usages: CharacterCardUsages[];
26+
numMatches: number;
27+
}>();
28+
const { usages: characterCardsUsages, numMatches } = toRefs(props);
2729
2830
const { t } = useLocales();
2931
const { characterCardById } = await useAsyncSharedData();
@@ -34,14 +36,16 @@ const { height: chartHeight, width: chartWidth } = useElementSize(chart);
3436
const barNum = computed(() => Math.floor((chartWidth.value - remToPx(3)) / remToPx(3)));
3537
3638
const data = computed(() => {
37-
return characterCardStats.value
39+
return characterCardsUsages.value
3840
.map(item => ({
3941
cardId: item.cardId,
4042
pickRate: divide(item.numMatches, numMatches.value * 2),
4143
avatar: characterCardById.value[item.cardId].avatar,
4244
}))
43-
.sort(sorter("pickRate"))
44-
.reverse();
45+
.sort(sortBy(
46+
{ field: "pickRate", order: "desc" },
47+
{ field: "cardId" },
48+
));
4549
});
4650
4751
const option = computed<ECOption>(() => {

app/components/main/cards/Cards_CharacterBarChart.vue renamed to app/components/main/cards/CardsCharacterUsageBarChart.vue

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@
1111
<script lang="ts" setup>
1212
import { divide } from "mathjs/number";
1313
14-
type DataType = Awaited<ReturnType<typeof useApiGetCharacterCardStats>>;
15-
const characterCardStats = inject<DataType["characterCardStats"]>("characterCardStats", computed(() => []));
16-
const numMatches = inject<DataType["numMatches"]>("numMatches", computed(() => 0));
17-
const numGames = inject<DataType["numGames"]>("numGames", computed(() => 0));
14+
const props = defineProps<{
15+
usages: CharacterCardUsages[];
16+
numMatches: number;
17+
}>();
18+
const { usages: characterCardsUsages, numMatches } = toRefs(props);
1819
1920
const { t, currentLocalized } = useLocales();
2021
const { characterCardById } = await useAsyncSharedData();
2122
const themeVars = useThemeVars();
2223
24+
const numGames = computed(() => {
25+
return characterCardsUsages.value.reduce((sum, a) => sum + a.numGames, 0) / 6;
26+
});
27+
2328
const data = computed(() => {
24-
return characterCardStats.value
29+
return characterCardsUsages.value
2530
.map(item => ({
2631
cardId: item.cardId,
2732
numGames: item.numGames,
@@ -30,8 +35,12 @@ const data = computed(() => {
3035
numBanned: item.numBanned,
3136
avatar: characterCardById.value[item.cardId].avatar,
3237
}))
33-
.sort(sorter("numGames"))
34-
.reverse();
38+
.sort(sortBy(
39+
{ field: "numGames", order: "desc" },
40+
{ field: "numGamesWin", order: "desc" },
41+
{ field: "numBanned", order: "desc" },
42+
{ field: "cardId" },
43+
));
3544
});
3645
3746
const option = computed<ECOption>(() => {

app/composables/use-apis.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,3 @@ export async function useApiGetTeamMatchupStats(query: { gameVersion: GameVersio
55
matchupStats: computed(() => data.value?.matchupStats ?? []),
66
};
77
}
8-
9-
export async function useApiGetCharacterCardStats(query: { gameVersion: GameVersionId }) {
10-
const { data } = await useFetch("/api/v3/cards/getCharacterCardStats", { query });
11-
return {
12-
characterCardStats: computed(() => data.value?.characterCardStats ?? []),
13-
numGames: computed(() => data.value?.numGames ?? 0),
14-
numMatches: computed(() => data.value?.numMatches ?? 0),
15-
};
16-
}

app/pages/cards/[gameVersion].vue

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
<div>
33
<NTabs justify-content="space-evenly" type="line" size="large">
44
<NTabPane name="characters" :tab="t('terms.characterCards')">
5-
<Cards_CharacterBarChart />
6-
<Cards_CharacterPickRateBarChart />
5+
<template v-if="characterCardsUsages">
6+
<CardsCharacterUsageBarChart :usages="characterCardsUsages" :num-matches="numMatches" />
7+
<CardsCharacterPickRateBarChart :usages="characterCardsUsages" :num-matches="numMatches" />
8+
</template>
9+
<template v-else-if="characterCardsUsagesLoading">
10+
<NSpin size="large" />
11+
</template>
712
</NTabPane>
813
<NTabPane name="actions" :tab="t('terms.actionCards')">
914
<template v-if="actionCardsUsages">
@@ -23,10 +28,18 @@ useHead({ title: t("site.titles.main.cards") });
2328
2429
const { gameVersion } = useGameVersion();
2530
26-
const { characterCardStats, numMatches, numGames } = await useApiGetCharacterCardStats({ gameVersion: gameVersion.value });
27-
provide("characterCardStats", characterCardStats);
28-
provide("numMatches", numMatches);
29-
provide("numGames", numGames);
31+
const { data: overviewData } = await useFetch("/api/v4/overview-stats");
32+
const gameVersionOverviewStats = computed(() => {
33+
return overviewData.value?.find(g => g.gameVersion === gameVersion.value);
34+
});
35+
const numMatches = computed(() => gameVersionOverviewStats.value?.numMatches ?? 0);
36+
37+
const {
38+
data: characterCardsUsages,
39+
pending: characterCardsUsagesLoading,
40+
} = await useFetch("/api/v4/character-cards-usages", {
41+
query: { gameVersion },
42+
});
3043
3144
const {
3245
data: actionCardsUsages,

server/api/v3/cards/getCharacterCardStats.ts

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)