diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 439857e..5d3f1a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ stages: - build - deploy + - refresh build: stage: build @@ -23,3 +24,22 @@ deploy: environment: name: production url: https://40k-rankings.gateway-gamers.net + +refresh-elo: + stage: refresh + image: python:3.12-slim + variables: + GIT_STRATEGY: clone + script: + - cd statcheck-elo-scraper && python refresh_elo.py && cd .. + - git config user.email "gitlab-ci@gateway-gamers.net" + - git config user.name "GitLab CI" + - git remote set-url origin "https://oauth2:${GITLAB_ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" + - git add public/elo-data.json + - | + if ! git diff --cached --quiet; then + git commit -m "data: refresh stat-check ELO rankings [skip ci]" + git push origin HEAD:main + fi + only: + - schedules diff --git a/index.html b/index.html index acdda31..6a4f757 100644 --- a/index.html +++ b/index.html @@ -76,7 +76,7 @@ W–L–T Win % ITC Rank - Stat-Check ELO + Stat-Check ELO diff --git a/src/main.js b/src/main.js index 758954c..15824fd 100644 --- a/src/main.js +++ b/src/main.js @@ -304,6 +304,8 @@ function render(state) { // Rows applySort(kept).forEach((r, i) => { const u = r.user || {}, name = fullName(u) || u.nickname || "Unknown"; + const uid = r.userId || r.user?.id; + const eloMatch = findElo(name, uid); const tr = document.createElement("tr"); tr.innerHTML = `${i === 0 ? `1` : (i + 1)}` + @@ -312,7 +314,6 @@ function render(state) { `${r.wins || 0}${r.losses || 0}–${r.ties || 0} · ITC #${r.placing ?? "—"}` + `` + (() => { - const uid = r.userId || r.user?.id; const d = uid && careerData[uid]; const careerSub = d == null ? `` @@ -323,8 +324,9 @@ function render(state) { : (d.w + d.l + d.t) === 0 ? '' : `${fmtWpct(d.w, d.l, d.t)} career`; const mobilePct = `${fmtWpct(r.wins, r.losses, r.ties)} win rate`; + const mobileElo = eloMatch ? `ELO ${Math.round(eloMatch.elo)}` : ''; return `${fmtPts(r.ITCPoints)}` + - mobilePct + `` + + mobilePct + mobileElo + `` + `` + `${r.wins || 0}${r.losses || 0}–${r.ties || 0}` + careerSub + `` + @@ -333,11 +335,9 @@ function render(state) { })() + `#${r.placing ?? "—"}` + (() => { - const uid = r.userId || r.user?.id; - const e = findElo(fullName(r.user || {}), uid); - if (e === undefined) return ``; - if (!e) return `—`; - return `${Math.round(e.elo)}`; + if (eloMatch === undefined) return ``; + if (!eloMatch) return `—`; + return `${Math.round(eloMatch.elo)}`; })(); tb.appendChild(tr); }); @@ -406,7 +406,7 @@ function showSkeleton() { `
` + `
` + `
` + - `
`; + `
`; tb.appendChild(tr); } }