Skip to content

Commit 27371f5

Browse files
committed
Merge branch 'main' into fix-game-length-labels
2 parents 7193d8f + 4b6987d commit 27371f5

19 files changed

+275
-89
lines changed

src/components/Card.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const isStormgatenexus = data.source == "news" && data.author_url?.includes("sto
8282
)
8383
}
8484
<div class="flex-auto"></div>
85-
<div class="mt-4 flex flex-wrap gap-4 text-sm">
85+
<div class="mt-4 flex flex-wrap items-center gap-4 text-sm">
8686
{
8787
data.source === "reddit" ? (
8888
<RedditMeta data={data} />

src/components/sources/NewsMeta.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
2+
import Svg from "@jasikpark/astro-svg-loader"
23
import type { Content } from "../../lib/content"
34
45
export interface Props {
56
data: Content
67
}
78
89
const { data } = Astro.props
9-
const isStormgatenexus = data.source == "news" && data.author_url.includes("stormgatenexus.com")
10+
const isStormgatenexus = data.source == "news" && data.author_url?.includes("stormgatenexus.com")
1011
function prefixUrl(url: string) {
1112
if (url.startsWith("http")) {
1213
return url
@@ -24,7 +25,7 @@ function prefixUrl(url: string) {
2425
) : (
2526
<>
2627
<span class="inline-flex items-center text-orange-400">
27-
<i class="ti ti-rss w-4" />
28+
<Svg src={import("lucide-static/icons/rss.svg?raw")} class="inline-block w-4" />
2829
</span>
2930

3031
{data.author_url ? (
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { createEffect, createSignal, onMount } from "solid-js"
2+
import { SelectButton, type SelectButtonOption } from "../ui/SelectButton"
3+
import infernals from "../../assets/game/factions/infernals-small-glow.png"
4+
import vanguard from "../../assets/game/factions/vanguard-small-glow.png"
5+
import { Race } from "../../lib/api"
6+
7+
const factionOptions: SelectButtonOption[] = [
8+
{
9+
label: "Infernals",
10+
value: Race.INFERNALS,
11+
icon: infernals.src,
12+
},
13+
{ label: "Vanguard", value: Race.VANGUARD, icon: vanguard.src },
14+
]
15+
16+
export function FactionDropdown(props: { queryParam: string; selected: (typeof factionOptions)[number]["value"] }) {
17+
const selected = props.selected ?? "all"
18+
const [faction, setFaction] = createSignal(
19+
factionOptions.find((option) => option.value === selected) || factionOptions[0]
20+
)
21+
22+
createEffect(() => {
23+
const urlParams = new URLSearchParams(window.location.search)
24+
if (faction()?.value === selected) return
25+
if (faction()?.value && faction()?.value != "all") urlParams.set(props.queryParam, faction()?.value!)
26+
else urlParams.delete(props.queryParam)
27+
window.location.href = `${window.location.pathname}${urlParams.size ? "?" + urlParams.toString() : ""}`
28+
})
29+
30+
return <SelectButton options={factionOptions} value={faction} setValue={setFaction} />
31+
}

src/components/widgets/GameLengthChart.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const prettyLabels = {
1919
"841-960": "14-16m",
2020
"961-1080": "16-18m",
2121
"1081-1200": "18-20m",
22-
"1200+": "20m+",
22+
"1201-1320": "20-22m",
23+
"1320+": "22m+",
2324
} as const
2425

2526
export function GameLengthChart(props: GameLengthProps) {
@@ -55,6 +56,7 @@ export function GameLengthChart(props: GameLengthProps) {
5556
intersect: false,
5657
mode: "index",
5758
},
59+
maxBarThickness: 50,
5860
plugins: {
5961
title: {
6062
display: false,

src/components/widgets/Leaderboard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function Leaderboard(props: Props) {
4343
const [query, setQuery] = createSignal(props.query || undefined)
4444
const [page, setPage] = createSignal(props.page || 1)
4545
const [mode, setMode] = createSignal(props.mode ?? "ranked_1v1")
46-
const [order, setOrder] = createSignal(props.order ?? undefined)
46+
const [order, setOrder] = createSignal(props.order ?? LeaderboardOrder.POINTS)
4747
const [faction, setFaction] = createSignal(props.faction ?? undefined)
4848
const [isPending, start] = useTransition()
4949
const [isBrowserNavigation, setIsBrowserNavigation] = createSignal(true)
@@ -164,11 +164,11 @@ export function Leaderboard(props: Props) {
164164
class={classes(styles.button.sm, "flex-auto bg-transparent text-white outline-none")}
165165
placeholder="Search"
166166
ref={searchInput}
167-
onKeyDown={(e) => e.key === "Enter" && setQuery(searchInput?.value)}
167+
onKeyDown={(e) => e.key === "Enter" && setQuery(searchInput?.value.trim() || undefined)}
168168
/>
169169
<button
170170
class={classes(styles.button.sm, styles.button.control, styles.button.trigger)}
171-
onClick={() => setQuery(searchInput?.value)}
171+
onClick={() => setQuery(searchInput?.value.trim() || undefined)}
172172
>
173173
<span innerHTML={searchIcon} class="text-gray-200 *:w-4" />
174174
</button>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// @ts-nocheck
2+
3+
import { onMount } from "solid-js"
4+
import { Chart, Title, Tooltip, Colors, TimeScale, type ChartOptions, type ChartData } from "chart.js"
5+
import { Line } from "solid-chartjs"
6+
import "chartjs-adapter-date-fns"
7+
8+
type MmrHistoryChartProps = {
9+
labels: string[]
10+
data: number[]
11+
}
12+
13+
const longNumberFormatter = new Intl.NumberFormat("en-us")
14+
15+
export function MmrHistoryChart(props: MmrHistoryChartProps) {
16+
let canvas: HTMLCanvasElement
17+
onMount(() => {
18+
Chart.register(Title, Tooltip, Colors, TimeScale)
19+
})
20+
21+
const chartData: ChartData = {
22+
labels: props.labels,
23+
datasets: [
24+
{
25+
label: "MMR",
26+
data: props.data,
27+
tension: 0.3,
28+
borderColor: "#9E9E9E",
29+
pointRadius: 5,
30+
pointHoverRadius: 2,
31+
pointBorderColor: "transparent",
32+
},
33+
],
34+
}
35+
36+
const chartOptions: ChartOptions = {
37+
responsive: true,
38+
maintainAspectRatio: true,
39+
interaction: {
40+
intersect: false,
41+
mode: "index",
42+
},
43+
scales: {
44+
y: {
45+
ticks: {
46+
precision: 0,
47+
},
48+
offset: true,
49+
},
50+
x: {
51+
type: "time",
52+
time: { unit: "day", tooltipFormat: "d MMM, y" },
53+
},
54+
},
55+
plugins: {
56+
tooltip: {
57+
displayColors: false,
58+
callbacks: {
59+
label: (c) => `MMR: ${Math.round(c.parsed.y)}`,
60+
},
61+
},
62+
},
63+
}
64+
65+
return (
66+
<div class="relative w-full overflow-hidden">
67+
<Line data={chartData} options={chartOptions} height={100} width={300} ref={(c) => (canvas = c)} />
68+
</div>
69+
)
70+
}

src/layouts/PlayerLayout.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const playerInfo = (await getCollection("players")).find((p) => p.data.playerId
4444
current={[
4545
{ href: `/players/${slug}`, label: "Overview" },
4646
{ href: `/players/${slug}/matches`, label: "Match History" },
47+
{ href: `/players/${slug}/statistics`, label: "Statistics" },
4748
]}
4849
/>
4950
<HeaderContent>

src/lib/api/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ export type { ActivityStatistics } from "./models/ActivityStatistics"
1111
export type { ActivityStatisticsActivity } from "./models/ActivityStatisticsActivity"
1212
export type { ActivityStatisticsEntry } from "./models/ActivityStatisticsEntry"
1313
export type { ActivityStatisticsServerEntry } from "./models/ActivityStatisticsServerEntry"
14+
export { Aggregation } from "./models/Aggregation"
1415
export type { ErrorResponse } from "./models/ErrorResponse"
1516
export { Leaderboard } from "./models/Leaderboard"
1617
export type { LeaderboardDumpResponse } from "./models/LeaderboardDumpResponse"
1718
export type { LeaderboardEntryHistory } from "./models/LeaderboardEntryHistory"
18-
export type { LeaderboardEntryHistoryEntry } from "./models/LeaderboardEntryHistoryEntry"
19+
export type { LeaderboardEntryHistoryRow } from "./models/LeaderboardEntryHistoryRow"
1920
export type { LeaderboardEntryResponse } from "./models/LeaderboardEntryResponse"
2021
export { LeaderboardOrder } from "./models/LeaderboardOrder"
2122
export type { LeaderboardResponse } from "./models/LeaderboardResponse"
@@ -35,13 +36,13 @@ export type { PlayerMatchupsStatsEntry } from "./models/PlayerMatchupsStatsEntry
3536
export type { PlayerMatchupsStatsMatchup } from "./models/PlayerMatchupsStatsMatchup"
3637
export type { PlayerOpponentsStats } from "./models/PlayerOpponentsStats"
3738
export type { PlayerOpponentsStatsOpponent } from "./models/PlayerOpponentsStatsOpponent"
38-
export type { PlayerPreferences } from "./models/PlayerPreferences"
3939
export type { PlayerResponse } from "./models/PlayerResponse"
4040
export type { PlayerStatsEntry } from "./models/PlayerStatsEntry"
4141
export type { PlayerStatsEntryAggregated } from "./models/PlayerStatsEntryAggregated"
4242
export type { PlayerStatsEntryNumBreakdown } from "./models/PlayerStatsEntryNumBreakdown"
4343
export { ProfilePrivacy } from "./models/ProfilePrivacy"
4444
export { Race } from "./models/Race"
45+
export { Resolution } from "./models/Resolution"
4546
export type { StatsByTime } from "./models/StatsByTime"
4647
export type { StatsByTimeEntry } from "./models/StatsByTimeEntry"
4748
export type { StatsByTimeHistoryPoint } from "./models/StatsByTimeHistoryPoint"

src/lib/api/models/PlayerPreferences.ts renamed to src/lib/api/models/Aggregation.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
/* istanbul ignore file */
33
/* tslint:disable */
44
/* eslint-disable */
5-
import type { ProfilePrivacy } from "./ProfilePrivacy"
6-
export type PlayerPreferences = {
7-
privacy_profile?: ProfilePrivacy | null
5+
export enum Aggregation {
6+
LAST = "last",
7+
MAX_MMR = "max_mmr",
8+
MAX_POINTS = "max_points",
89
}

src/lib/api/models/LeaderboardEntryHistory.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
/* istanbul ignore file */
33
/* tslint:disable */
44
/* eslint-disable */
5-
import type { LeaderboardEntryHistoryEntry } from "./LeaderboardEntryHistoryEntry"
5+
import type { Aggregation } from "./Aggregation"
6+
import type { LeaderboardEntryHistoryRow } from "./LeaderboardEntryHistoryRow"
7+
import type { Resolution } from "./Resolution"
68
export type LeaderboardEntryHistory = {
7-
history: Array<LeaderboardEntryHistoryEntry>
9+
cached_at: string
10+
resolution: Resolution
11+
aggregation: Aggregation
12+
history: Array<LeaderboardEntryHistoryRow>
813
}

0 commit comments

Comments
 (0)