Skip to content

Commit

Permalink
Update match head-to-head history to have filters for sub event & mat…
Browse files Browse the repository at this point in the history
…ch group
  • Loading branch information
slmnio committed Jul 26, 2023
1 parent 0fc9380 commit 225311b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
16 changes: 13 additions & 3 deletions website/src/utils/content-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ export const MapTypeIcons = {
Assault: "https://cdn.discordapp.com/attachments/1125871284702679041/1125908385250934904/assault.png"
};

export function getTeamsMapStats(teams, requestMatch, requestMap) {
console.log(requestMatch);
export function getTeamsMapStats(teams, requestMatch, requestMap, filters) {
console.log("get teams map stats", requestMatch, filters);
if (!teams) return null;
const stats = teams.map(team => {
const stat = {
Expand All @@ -263,7 +263,17 @@ export function getTeamsMapStats(teams, requestMatch, requestMap) {
const latestMatch = prevMatches.length ? prevMatches[0] : null;


(team.matches || []).forEach(match => {
(team.matches || []).filter(m => {
if (filters?.match_group) {
console.log("match group", filters.match_group, m.match_group, filters.match_group !== m.match_group);
if (filters.match_group !== m.match_group) return false;
}
if (filters?.sub_event) {
console.log("sub event", filters.sub_event, m.sub_event, filters.sub_event !== m.sub_event);
if (filters.sub_event !== m.sub_event) return false;
}
return true;
}).forEach(match => {
(match.maps || []).forEach(matchMap => {
if (!matchMap.map) return; // no proper map data
if (requestMap.id !== cleanID(matchMap.map[0])) return; // isn't this map
Expand Down
20 changes: 18 additions & 2 deletions website/src/views/sub-views/MatchHistory.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<template>
<div class="match-history">
<h1>Map Head To Head</h1>
<div class="settings flex w-100 justify-content-end mb-2" v-if="match.sub_event || match.match_group">
<b-form-checkbox v-if="match.sub_event" v-model="filterSubEvent">
Only show maps from sub event <b>{{ match.sub_event}}</b>.
</b-form-checkbox>
<b-form-checkbox v-if="match.match_group" v-model="filterMatchGroup">
Only show maps from group <b>{{ match.match_group}}</b>.
</b-form-checkbox>
</div>
<div class="text-light">
<div class="map-type" v-for="(mapType, i) in mapGroups" :key="i">
<div class="title">
Expand Down Expand Up @@ -28,11 +36,16 @@ import { ReactiveArray, ReactiveThing } from "@/utils/reactive";
import { getTeamsMapStats } from "@/utils/content-utils";
import MatchMapHistory from "@/components/website/match/MatchMapHistory";
import MapDisplay from "@/components/website/match/MapDisplay";
import { BFormCheckbox } from "bootstrap-vue";
export default {
name: "MatchHistory",
props: ["match"],
components: { MapDisplay, MatchMapHistory },
components: { MapDisplay, MatchMapHistory, BFormCheckbox },
data: () => ({
filterSubEvent: false,
filterMatchGroup: true
}),
computed: {
pool() {
if (!this.match?.event?.map_pool) return [];
Expand Down Expand Up @@ -62,7 +75,10 @@ export default {
},
methods: {
_getTeamMapStats(requestMap) {
return getTeamsMapStats(this.teams, this.match, requestMap);
return getTeamsMapStats(this.teams, this.match, requestMap, {
sub_event: this.filterSubEvent && this.match.sub_event,
match_group: this.filterMatchGroup && this.match.match_group
});
}
}
};
Expand Down

0 comments on commit 225311b

Please sign in to comment.