Skip to content

Commit

Permalink
feat: Implement hideCurrentSeason
Browse files Browse the repository at this point in the history
  • Loading branch information
potato4d committed Sep 27, 2020
1 parent cb13fe2 commit 88944bd
Show file tree
Hide file tree
Showing 8 changed files with 324 additions and 173 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"axios": "^0.19.2",
"dayjs": "^1.8.27",
"dotenv": "^8.2.0",
"firebase": "^7.14.2",
"firebase": "^7.21.1",
"jimp": "^0.10.3",
"nuxt": "^2.0.0",
"nuxt-basic-auth-module": "^1.3.2",
Expand Down
9 changes: 8 additions & 1 deletion src/analyzer/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ async function check(croppedSS: Jimp): Promise<Pokemon> {
debug(r.distance)
const endAt = new Date()
debug(`実行時間: ${endAt.getTime() - startedAt.getTime()}ms`)
return dex.find((p) => p.slug === r.slug)!
return dex
.map((p) => ({
...p,
slug: p.slug.includes('alcremie-')
? p.slug.split('alcremie-')[0]
: p.slug,
}))
.find((p) => p.slug === r.slug)!
}

export async function compare(
Expand Down
18 changes: 18 additions & 0 deletions src/assets/rules/firestore.indexes.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@
"order": "DESCENDING"
}
]
},
{
"collectionGroup": "battlerecords",
"queryScope": "COLLECTION",
"fields": [
{
"fieldPath": "hideCurrentSeason",
"order": "DESCENDING"
},
{
"fieldPath": "season",
"order": "DESCENDING"
},
{
"fieldPath": "createdAt",
"order": "DESCENDING"
}
]
}
],
"fieldOverrides": [
Expand Down
22 changes: 7 additions & 15 deletions src/components/common/AppUsage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,10 @@ export const AppUsage = tsx.component({
{} as WinRates['items']
)
return {
items: Object.entries(items)
.map(([slug, item]) => ({
slug,
...item,
}))
.sort((b, a) => {
if (b.winCount === 0 || b.selectCount === 0) {
return +1
}
if (a.winCount === 0 || a.selectCount === 0) {
return -1
}
return b.selectCount < a.selectCount ? +1 : -1
}),
items: Object.entries(items).map(([slug, item]) => ({
slug,
...item,
})),
bestWin: Object.values(items).reduce((b: number, a) => {
if (a.winCount === 0) {
return 0
Expand All @@ -107,7 +97,9 @@ export const AppUsage = tsx.component({
}}
>
<div class="flex items-center justify-between px-6 py-4">
<h4 class="text-2xl font-bold text-white">この構築の利用統計</h4>
<h4 class="text-2xl font-bold text-white">
この構築の利用統計 (全{this.winRates.battleCount}試合)
</h4>
<div class="flex items-center">
<span class="inline-block w-4 h-4 rounded-full bg-blue-600"></span>
<span class="inline-block ml-2 mr-12">選出率</span>
Expand Down
27 changes: 17 additions & 10 deletions src/components/partials/modal/AnalyzerModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,17 @@
/>
</p>
</div>
<p class="flex flex-col pt-12">
<label class="pb-3">この対戦が含まれる動画のURL</label>
<input
type="text"
class="input-rank"
placeholder="YouTube, Twitter, ニコ生など"
v-model="formData.videoUrl"
/>
<p class="flex flex-col justify-center pt-12">
<label class="pb-3">
<input
type="checkbox"
:value="true"
v-model="formData.hideCurrentSeason"
/>
<span>シーズン中トップに表示しない</span>
</label>
</p>
<p class="flex flex-col pt-12">
<p class="flex flex-col justify-center pt-2">
<label class="pb-3">
<input
type="checkbox"
Expand Down Expand Up @@ -313,9 +314,11 @@ type LocalData = {
}
}
const CURRENT_SEASON = 10
const getInitialFormData = (): Omit<BattleRecord, 'userId'> => ({
captureUrl: null,
season: 10,
season: CURRENT_SEASON,
format: 'single',
result: 'win',
rank: null,
Expand All @@ -326,6 +329,7 @@ const getInitialFormData = (): Omit<BattleRecord, 'userId'> => ({
opponentChoice: [null, null, null],
note: '',
videoUrl: '',
hideCurrentSeason: null,
})
export default Vue.extend({
Expand Down Expand Up @@ -569,6 +573,9 @@ export default Vue.extend({
},
},
computed: {
CURRENT_SEASON() {
return CURRENT_SEASON
},
userId(): string | 'anonymous' {
return this.$auth.currentUser
? this.anonymous
Expand Down
1 change: 1 addition & 0 deletions src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default Vue.extend({
async asyncData({ app }) {
const records = await app.$firestore
.collection('battlerecords')
.where('hideCurrentSeason', '==', false)
.orderBy('season', 'desc')
.orderBy('createdAt', 'desc')
.limit(LIMIT)
Expand Down
1 change: 1 addition & 0 deletions src/types/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ export type BattleRecord = {
note: string
captureUrl: string | null
videoUrl: string | null
hideCurrentSeason?: number | null
createdAt?: firebase.firestore.Timestamp | Date
}

0 comments on commit 88944bd

Please sign in to comment.