Compare commits
17 Commits
637ff144c3
...
html_scrap
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc57e8cceb | ||
|
|
c54d950e30 | ||
|
|
c8a56c08d2 | ||
|
|
a5ef3f6569 | ||
|
|
965d1560f7 | ||
|
|
28c4f4595e | ||
|
|
95d13370c2 | ||
|
|
d999f676ba | ||
|
|
bb88e68f8f | ||
|
|
004f0eb900 | ||
|
|
22fa677d8a | ||
|
|
2faf8038fe | ||
|
|
33180e95a3 | ||
|
|
f37ca5e627 | ||
|
|
7ee8fb23d9 | ||
|
|
8172d4c769 | ||
|
|
29e85397a7 |
776
Cargo.lock
generated
776
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
12
Cargo.toml
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dancing-bot-teachers"
|
||||
version = "0.1.0"
|
||||
name = "teachertracker-rs"
|
||||
version = "0.1.3"
|
||||
edition = "2024"
|
||||
authors = ["Lukas Wölfer <coding@thasky.one>"]
|
||||
description = "A MediaWiki bot that updates score information of teachers"
|
||||
@@ -11,9 +11,15 @@ keywords = ["mediawiki", "bot", "teacher", "score", "automation"]
|
||||
categories = ["web-programming", "api-bindings", "automation"]
|
||||
|
||||
[dependencies]
|
||||
mwbot = { git = "https://gitlab.wikimedia.org/repos/mwbot-rs/mwbot.git", rev = "05cbb12188f18e2da710de158d89a9a4f1b42689", default-features = false, features = ["generators", "mwbot_derive"] }
|
||||
chrono = "0.4.41"
|
||||
futures = "0.3.31"
|
||||
# mwbot = { git = "https://gitlab.wikimedia.org/repos/mwbot-rs/mwbot.git", rev = "05cbb12188f18e2da710de158d89a9a4f1b42689", default-features = false, features = ["generators", "mwbot_derive"] }
|
||||
mwbot = { version = "0.7.0", default-features = false, features = ["generators", "mwbot_derive"] }
|
||||
rand = "0.9.2"
|
||||
reqwest = "0.12.22"
|
||||
scraper = "0.24.0"
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
serde_plain = "1.0.2"
|
||||
thiserror = "2.0.12"
|
||||
tokio = { version = "1.46.1", features = ["rt"] }
|
||||
tracing = { version = "0.1.41", default-features = false, features = ["std"] }
|
||||
|
||||
1
emeline.json
Normal file
1
emeline.json
Normal file
File diff suppressed because one or more lines are too long
586
polina.html
Normal file
586
polina.html
Normal file
@@ -0,0 +1,586 @@
|
||||
<!doctype html>
|
||||
<html lang="en-US" DIR="LTR">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
||||
<meta name="author" content="Andreas Kasper <me@andi.dance>">
|
||||
|
||||
|
||||
<title>Polina Gorushkina [20000] - WSDC Registry - World Swing Dance Council Points Registry</title>
|
||||
|
||||
<link rel="icon" href="/skins/grey/images/favicon.png">
|
||||
<link rel="apple-touch-icon" sizes="57x57" href="/skins/grey/images/favicon/apple-icon-57x57.png">
|
||||
<link rel="apple-touch-icon" sizes="60x60" href="/skins/grey/images/favicon/apple-icon-60x60.png">
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="/skins/grey/images/favicon/apple-icon-72x72.png">
|
||||
<link rel="apple-touch-icon" sizes="76x76" href="/skins/grey/images/favicon/apple-icon-76x76.png">
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="/skins/grey/images/favicon/apple-icon-114x114.png">
|
||||
<link rel="apple-touch-icon" sizes="120x120" href="/skins/grey/images/favicon/apple-icon-120x120.png">
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="/skins/grey/images/favicon/apple-icon-144x144.png">
|
||||
<link rel="apple-touch-icon" sizes="152x152" href="/skins/grey/images/favicon/apple-icon-152x152.png">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/skins/grey/images/favicon/apple-icon-180x180.png">
|
||||
<link rel="icon" type="image/png" sizes="192x192" href="/skins/grey/images/favicon/android-icon-192x192.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/skins/grey/images/favicon/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="96x96" href="/skins/grey/images/favicon/favicon-96x96.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/skins/grey/images/favicon/favicon-16x16.png">
|
||||
<link rel="manifest" href="/skins/grey/images/favicon/manifest.json">
|
||||
<meta name="msapplication-TileColor" content="#dbdbdb">
|
||||
<meta name="msapplication-TileImage" content="/skins/grey/images/favicon/ms-icon-144x144.png">
|
||||
<meta name="theme-color" content="#dbdbdb">
|
||||
<meta name="apple-mobile-web-app-status-bar" content="#FFE1C4">
|
||||
<meta name="facebook-domain-verification" content="3cucv1q0ssr7c0tp1me7r1g57uw0ri" />
|
||||
<meta property="goo1:node" content="v36186.scoring.dance" />
|
||||
<meta property="goo1:load" content="0.68505859375,0.74365234375,0.61279296875" />
|
||||
<!--<script src="/skins/grey/js/pwa_app.js"></script>-->
|
||||
|
||||
|
||||
|
||||
<!-- CSS and JS -->
|
||||
<link href="/skins/grey/css/main.css?v=1" rel="stylesheet">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/js/bootstrap.min.js"></script><script src="/skins/grey/js/main.js?v=2"></script>
|
||||
<meta property="og:type" content="website" />
|
||||
|
||||
<meta property="og:image" content="https://scoring.dance/skins/grey/images/facebook_wsdcpoints.jpg" />
|
||||
<link rel="alternate" hreflang="en-US" href="https://scoring.dance/enUS/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="af-ZA" href="https://scoring.dance/afZA/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="ar-IL" href="https://scoring.dance/arIL/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="az-AZ" href="https://scoring.dance/azAZ/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="id-ID" href="https://scoring.dance/idID/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="ms-MY" href="https://scoring.dance/msMY/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="by-DE" href="https://scoring.dance/byDE/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="bs-BA" href="https://scoring.dance/bsBA/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="cs-CZ" href="https://scoring.dance/csCZ/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="da-DK" href="https://scoring.dance/daDK/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="de-DE" href="https://scoring.dance/deDE/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="et-EE" href="https://scoring.dance/etEE/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="en-CA" href="https://scoring.dance/enCA/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="es-ES" href="https://scoring.dance/esES/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="fr-FR" href="https://scoring.dance/frFR/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="fr-CA" href="https://scoring.dance/frCA/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="ga-IE" href="https://scoring.dance/gaIE/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="it-IT" href="https://scoring.dance/itIT/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="la-VA" href="https://scoring.dance/laVA/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="lv-LV" href="https://scoring.dance/lvLV/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="lb-LU" href="https://scoring.dance/lbLU/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="hu-HU" href="https://scoring.dance/huHU/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="nl-NL" href="https://scoring.dance/nlNL/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="no-NO" href="https://scoring.dance/noNO/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="pl-PL" href="https://scoring.dance/plPL/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="pt-PT" href="https://scoring.dance/ptPT/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="pt-BR" href="https://scoring.dance/ptBR/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="ru-RU" href="https://scoring.dance/ruRU/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="ro-RO" href="https://scoring.dance/roRO/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="rm-CH" href="https://scoring.dance/rmCH/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="de-CH" href="https://scoring.dance/deCH/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="sq-AL" href="https://scoring.dance/sqAL/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="sk-SK" href="https://scoring.dance/skSK/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="sl-SI" href="https://scoring.dance/slSI/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="fi-FI" href="https://scoring.dance/fiFI/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="sv-SE" href="https://scoring.dance/svSE/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="vi-VN" href="https://scoring.dance/viVN/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="tr-TR" href="https://scoring.dance/trTR/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="de-AT" href="https://scoring.dance/deAT/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="el-GR" href="https://scoring.dance/elGR/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="sr-RS" href="https://scoring.dance/srRS/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="uk-UA" href="https://scoring.dance/ukUA/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="he-IL" href="https://scoring.dance/heIL/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="ar-SA" href="https://scoring.dance/arSA/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="hi-IN" href="https://scoring.dance/hiIN/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="bn-BD" href="https://scoring.dance/bnBD/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="th-TH" href="https://scoring.dance/thTH/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="ka-GE" href="https://scoring.dance/kaGE/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="am-ET" href="https://scoring.dance/amET/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="zh-CN" href="https://scoring.dance/zhCN/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="ja-JP" href="https://scoring.dance/jaJP/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="ko-KR" href="https://scoring.dance/koKR/wsdc/registry/20000.html"/>
|
||||
<link rel="alternate" hreflang="x-default" href="https://scoring.dance/wsdc/registry/20000.html"/>
|
||||
<meta name="google-site-verification" content="-8v-Otv_q3ZFkRCSOWkZVwspbNnrrLkRArNf-7CZ0cE" />
|
||||
</head>
|
||||
|
||||
<body class="no-darkmode">
|
||||
<section class="d-none">
|
||||
<h1>Polina Gorushkina [20000] - WSDC Registry - World Swing Dance Council Points Registry</h1>
|
||||
<p></p>
|
||||
</section>
|
||||
|
||||
<nav class="navbar navbar-expand-md navbar-dark fi2xed-top bg-primary sticky-md-first">
|
||||
<a class="navbar-brand" href="/enUS/">scoring.dance</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item ">
|
||||
<a class="nav-link" href="/enUS/"><i class="fa-solid fa-home-alt"></i>Home</a>
|
||||
</li>
|
||||
<li class="nav-item ">
|
||||
<a class="nav-link" href="/enUS/scorer"><i class="fal fa-abacus"></i> Scorekeeper</a>
|
||||
</li>
|
||||
<li class="nav-item ">
|
||||
<a class="nav-link" href="/enUS/comppass"><i class="fal fa-id-card"></i> CompPass</a>
|
||||
</li>
|
||||
<li class="nav-item ">
|
||||
<a class="nav-link" href="/enUS/wsdc/worldranking.html"><i class="fal fa-ranking-star"></i> Ranking</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
<ul class="navbar-nav mr-auto">
|
||||
</ul>
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item dropdown">
|
||||
<a id="nav_languages" class="nav-link dropdown-toggle" data-toggle="dropdown" data-target="DropdownLanguage" aria-haspopup="true" aria-expanded="false"><img src="https://library.goo1.de/flags/USA.png" style="height: 1rem;"/><span class="d-inline d-md-none ml-1">Language English</span></a>
|
||||
<div id="DropdownLanguage" class="dropdown-menu" aria-labelledby="dropdown01">
|
||||
<a class="dropdown-item text-left active" href="/enUS/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/USA.png" style="height: 1rem;"/> English</a><a class="dropdown-item text-left " href="/csCZ/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/CZE.png" style="height: 1rem;"/> Čeština</a><a class="dropdown-item text-left " href="/daDK/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/DNK.png" style="height: 1rem;"/> Dansk</a><a class="dropdown-item text-left " href="/deDE/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/DEU.png" style="height: 1rem;"/> Deutsch</a><a class="dropdown-item text-left " href="/esES/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/ESP.png" style="height: 1rem;"/> Español</a><a class="dropdown-item text-left " href="/frFR/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/FRA.png" style="height: 1rem;"/> Français</a><a class="dropdown-item text-left " href="/itIT/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/ITA.png" style="height: 1rem;"/> Italiano</a><a class="dropdown-item text-left " href="/lvLV/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/LVA.png" style="height: 1rem;"/> Latviešu</a><a class="dropdown-item text-left " href="/lbLU/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/LUX.png" style="height: 1rem;"/> Lëtzebuergesch</a><a class="dropdown-item text-left " href="/huHU/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/HUN.png" style="height: 1rem;"/> Magyar</a><a class="dropdown-item text-left " href="/nlNL/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/NLD.png" style="height: 1rem;"/> Nederlands</a><a class="dropdown-item text-left " href="/noNO/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/NOR.png" style="height: 1rem;"/> Norsk</a><a class="dropdown-item text-left " href="/plPL/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/POL.png" style="height: 1rem;"/> Polski</a><a class="dropdown-item text-left " href="/ptPT/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/PRT.png" style="height: 1rem;"/> Português</a><a class="dropdown-item text-left " href="/ruRU/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/RUS.png" style="height: 1rem;"/> Pусский</a><a class="dropdown-item text-left " href="/roRO/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/ROM.png" style="height: 1rem;"/> Română</a><a class="dropdown-item text-left " href="/slSI/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/SVN.png" style="height: 1rem;"/> Slovenščina</a><a class="dropdown-item text-left " href="/fiFI/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/FIN.png" style="height: 1rem;"/> Suomi</a><a class="dropdown-item text-left " href="/svSE/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/SWE.png" style="height: 1rem;"/> Svenska</a><a class="dropdown-item text-left " href="/ukUA/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/UKR.png" style="height: 1rem;"/> Українська</a><a class="dropdown-item text-left " href="/heIL/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/ISR.png" style="height: 1rem;"/> ישראל</a><a class="dropdown-item text-left " href="/zhCN/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/CHN.png" style="height: 1rem;"/> 中文</a><a class="dropdown-item text-left " href="/jaJP/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/JPN.png" style="height: 1rem;"/> 日本語</a><a class="dropdown-item text-left " href="/koKR/wsdc/registry/20000.html"><img src="https://library.goo1.de/flags/KOR.png" style="height: 1rem;"/> 한국어</a> </div>
|
||||
</li>
|
||||
</ul>
|
||||
<form method="GET" action="/enUS/search" target="_blank" class="form-inline my-2 my-lg-0" rel="nofollow">
|
||||
<span class="input-group w-100 w-md-auto">
|
||||
<input class="form-control" type="text" name="q" placeholder="search" aria-label="search">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-outline-success my-0" type="submit">search</button>
|
||||
</div>
|
||||
</span>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main id="main" role="main" class="pb-4"><section class="container"><h1 class="h3 pt-4">Polina Gorushkina [20000]</h1><div style="width: 100%; height: 7cm; max-height: 50vh; position: relative">
|
||||
<div style="position: absolute; width: 100%; height: 100%; left: 0; top: 0">
|
||||
<canvas id="myChart" style="width: 100%; height: 100%;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.9.1/dist/chart.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns/dist/chartjs-adapter-date-fns.bundle.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/moment@2.29.4/moment.min.js"></script>
|
||||
<script>
|
||||
const ctx = document.getElementById('myChart').getContext('2d');
|
||||
const myChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
datasets: [{"label":"NOV (F)","data":[{"x":"2020-12-15","y":1,"tt":"<div><b>December 2020<\/b><\/div><div><b><\/b> Shooba Dooba Swing: +1p<\/div>"},{"x":"2021-10-15","y":2,"tt":"<div><b>October 2021<\/b><\/div><div><b><\/b> Moscow Westie Dance Fest: +1p<\/div>"},{"x":"2021-12-15","y":3,"tt":"<div><b>December 2021<\/b><\/div><div><b><\/b> Shooba Dooba Swing: +1p<\/div>"},{"x":"2022-02-15","y":9,"tt":"<div><b>February 2022<\/b><\/div><div><b>5th place<\/b> Swing&Snow: +6p<\/div>"},{"x":"2022-07-15","y":15,"tt":"<div><b>July 2022<\/b><\/div><div><b>5th place<\/b> St.Petersburg WCS Nights: +6p<\/div>"},{"x":"2022-11-15","y":30,"tt":"<div><b>November 2022<\/b><\/div><div><b>1st place<\/b> Moscow Westie Fest: +15p<\/div>"}],"backgroundColor":"#ce93d880","borderColor":"#ce93d8","fill":false,"cubicInterpolationMode":"monotone","tension":0.4},{"label":"INT (F)","data":[{"x":"2022-12-15","y":6,"tt":"<div><b>December 2022<\/b><\/div><div><b>3rd place<\/b> Shooba Dooba Swing: +6p<\/div>"}],"backgroundColor":"#ffd54f80","borderColor":"#ffd54f","fill":false,"cubicInterpolationMode":"monotone","tension":0.4}]},
|
||||
options: {
|
||||
scales: {
|
||||
x: {
|
||||
type: 'time',
|
||||
time: {
|
||||
unit: 'year'
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Date'
|
||||
}
|
||||
},
|
||||
y: {
|
||||
beginAtZero: true
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
tooltip: {
|
||||
enabled: false,
|
||||
position: 'nearest',
|
||||
external: externalTooltipHandler
|
||||
/*callbacks: {
|
||||
title: tooltiptitle,
|
||||
/*label: footer,
|
||||
afterBody: footer
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const getOrCreateTooltip = (chart) => {
|
||||
let tooltipEl = chart.canvas.parentNode.querySelector('div');
|
||||
|
||||
if (!tooltipEl) {
|
||||
tooltipEl = document.createElement('div');
|
||||
tooltipEl.id = "ChartsJSTooltip";
|
||||
tooltipEl.style.background = 'rgba(0, 0, 0, 0.7)';
|
||||
tooltipEl.style.borderRadius = '3px';
|
||||
tooltipEl.style.color = 'white';
|
||||
tooltipEl.style.opacity = 1;
|
||||
tooltipEl.style.pointerEvents = 'none';
|
||||
tooltipEl.style.position = 'absolute';
|
||||
tooltipEl.style.transform = 'translate(-50%, 0)';
|
||||
tooltipEl.style.transition = 'all .1s ease';
|
||||
|
||||
const table = document.createElement('table');
|
||||
table.style.margin = '0px';
|
||||
|
||||
tooltipEl.appendChild(table);
|
||||
chart.canvas.parentNode.appendChild(tooltipEl);
|
||||
}
|
||||
|
||||
return tooltipEl;
|
||||
};
|
||||
|
||||
function externalTooltipHandler(context) {
|
||||
// Tooltip Element
|
||||
const {chart, tooltip} = context;
|
||||
const tooltipEl = getOrCreateTooltip(chart);
|
||||
|
||||
// Hide if no tooltip
|
||||
if (tooltip.opacity === 0) {
|
||||
tooltipEl.style.opacity = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
$("#ChartsJSTooltip").css("z-index","10").html(tooltip.dataPoints[0].raw.tt);
|
||||
|
||||
const {offsetLeft: positionX, offsetTop: positionY} = chart.canvas;
|
||||
|
||||
// Display, position, and set styles for font
|
||||
tooltipEl.style.opacity = 1;
|
||||
tooltipEl.style.left = positionX + tooltip.caretX + 'px';
|
||||
tooltipEl.style.top = positionY + tooltip.caretY + 'px';
|
||||
tooltipEl.style.font = tooltip.options.bodyFont.string;
|
||||
tooltipEl.style.padding = tooltip.options.padding + 'px ' + tooltip.options.padding + 'px';
|
||||
};
|
||||
|
||||
function tooltiptitle(tti) {
|
||||
return "tooltiptitle";
|
||||
}
|
||||
|
||||
function footer(tooltipItems) {
|
||||
return "Hallo<br/>Dies ist ein Test";
|
||||
}
|
||||
|
||||
function plusaday(days) {
|
||||
var a = (new Date()).getTime();
|
||||
return new Date();
|
||||
}
|
||||
|
||||
function newDate(days) {
|
||||
var a = new Date();
|
||||
|
||||
return a; //DateTime.now().plus(days).toJSDate();
|
||||
}
|
||||
console.log("Hallo", ctx);
|
||||
</script>
|
||||
|
||||
<div style="width: 100%; height: 0; padding-bottom: 56.25%; position: relative">
|
||||
<div id="map" style="position: absolute; width: 100%; height: 100%; left: 0; top: 0">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<link href="/skins/grey/libs/OpenLayers/6.5.0/ol.css" rel="stylesheet" crossorigin="anonymous">
|
||||
<script src="/skins/grey/libs/OpenLayers/6.5.0/ol.js"></script>
|
||||
|
||||
<script>
|
||||
var map_markers = []
|
||||
|
||||
var background = new ol.layer.Tile({
|
||||
className: 'stamen',
|
||||
source: new ol.source.Stamen({
|
||||
layer: 'toner-lite',
|
||||
}),
|
||||
});
|
||||
|
||||
background = new ol.layer.Tile({source:new ol.source.XYZ({url:'https://filmerbe-bw.de/wp-json/filmkarte/v1/maptiles/stamen-terrain/{z}/{x}/{y}.png'})});
|
||||
|
||||
var map = new ol.Map({
|
||||
controls: ol.control.defaults().extend([new ol.control.FullScreen()]),
|
||||
target: 'map',
|
||||
layers: [/*
|
||||
new ol.layer.Tile({
|
||||
//source: new ol.source.OSM({url: 'https://cartodb-basemaps-{1-3}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png', crossOrigin: null})
|
||||
source: new ol.source.OSM({url: 'https://img.doksite.de/osm/bw-mapnik/{z}/{x}/{y}.png', crossOrigin: null})
|
||||
}),*/background/*, base, clipLayer, outlineLayer*/],
|
||||
/*overlays: [overlay],*/
|
||||
view: new ol.View({
|
||||
center: ol.proj.fromLonLat([9.43692, 48.81148]),
|
||||
/*center: ol.proj.fromLonLat([9.041169, 48.53775]),*/
|
||||
zoom: 1
|
||||
})
|
||||
});
|
||||
|
||||
var rows = [["37.6173000000","55.7558260000"],["30.3609097000","59.9310584000"]];
|
||||
for (var i =0; i < rows.length; i++) {
|
||||
var row = rows[i];
|
||||
var madrid = new ol.Feature({
|
||||
geometry: new ol.geom.Point(ol.proj.fromLonLat(row)),
|
||||
name: "test",
|
||||
});
|
||||
map_markers.push(madrid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
map.addLayer(new ol.layer.Vector({
|
||||
source: new ol.source.Vector({
|
||||
features: map_markers
|
||||
}),
|
||||
style: new ol.style.Style({
|
||||
image: new ol.style.Icon({
|
||||
anchor: [0.5, 1],
|
||||
src: '/skins/grey/images/icon/map_marker_32.png'
|
||||
})
|
||||
})
|
||||
}));
|
||||
</script>
|
||||
<style>
|
||||
#map .ol-attribution { display: none; }
|
||||
#map .ol-zoom { display: none; }
|
||||
#map .ol-rotate { display: none; }
|
||||
#map .ol-full-screen { text-align: right; }
|
||||
</style>
|
||||
<div class="row py-4">
|
||||
<div class="col-12 col-sm-6">
|
||||
<div class="card">
|
||||
<div class="card-header"><i class="fa-solid fa-address-card"></i> Details</div>
|
||||
<div class="card-body">
|
||||
<table>
|
||||
<tr>
|
||||
<th>First name:</th>
|
||||
<td>Polina</td>
|
||||
<tr>
|
||||
<tr>
|
||||
<th>Last name:</th>
|
||||
<td>Gorushkina</td>
|
||||
<tr>
|
||||
<tr>
|
||||
<th>Birth name:</th>
|
||||
<td>Gorushkina</td>
|
||||
<tr>
|
||||
<tr>
|
||||
<th>Nickname:</th>
|
||||
<td></td>
|
||||
<tr>
|
||||
<tr>
|
||||
<th>Previous Names:</th>
|
||||
<td><span class="badge badge-secondary"><i class="fa-solid fa-lock"></i> Pro</span></td>
|
||||
<tr>
|
||||
<tr>
|
||||
<th style="vertical-align:top;">Transliteral:</th>
|
||||
<td>
|
||||
<div><img src="/skins/grey/images/flags/GBR.png" style="height: 1rem;"> Polina Gorushkina</div>
|
||||
</td>
|
||||
<tr>
|
||||
<tr>
|
||||
<th>WSDC-ID:</th>
|
||||
<td>20000</td>
|
||||
<tr>
|
||||
<tr>
|
||||
<th>Allowed Divisions:</th>
|
||||
<td>NOV,INT</td>
|
||||
<tr>
|
||||
<tr>
|
||||
<th>Date of birth:</th>
|
||||
<td><span class="badge badge-secondary"><i class="fa-solid fa-lock"></i> Pro</span></td>
|
||||
<tr>
|
||||
<tr>
|
||||
<th>Age:</th>
|
||||
<td><span class="badge badge-secondary"><i class="fa-solid fa-lock"></i> Pro</span></td>
|
||||
<tr>
|
||||
<tr>
|
||||
<th>Country:</th>
|
||||
<td><span class="badge badge-secondary"><i class="fa-solid fa-lock"></i> Pro</span> </td>
|
||||
<tr>
|
||||
<tr>
|
||||
<th>City:</th>
|
||||
<td><span class="badge badge-secondary"><i class="fa-solid fa-lock"></i> Pro</span></td>
|
||||
<tr>
|
||||
|
||||
</table>
|
||||
<div class="text-muted"><small><a href="https://fb.me/dancescoring" TARGET="_blank">Something is wrong? Request a change…</a></small></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><div class="col-12 col-sm-6">
|
||||
<div class="card">
|
||||
<div class="card-header"><i class="fa-solid fa-chart-pie"></i> Stats</div>
|
||||
<div class="card-body">
|
||||
<table class="w-100 table-striped">
|
||||
<tr>
|
||||
<td colspan="3"><h4>All Time</h4></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
<th>Primary Role</th>
|
||||
<td class="text-right text-muted"><small></small></td>
|
||||
<td class="text-right">Follower</td>
|
||||
</tr><tr>
|
||||
<th>Points</th>
|
||||
<td class="text-right text-muted"><small></small></td>
|
||||
<td class="text-right">36</td>
|
||||
</tr><tr>
|
||||
<th>Points Follower</th>
|
||||
<td class="text-right text-muted"><small>100.00%</small></td>
|
||||
<td class="text-right">36</td>
|
||||
</tr><tr>
|
||||
<th>Points Last 3 years</th>
|
||||
<td class="text-right text-muted"><small></small></td>
|
||||
<td class="text-right">21</td>
|
||||
</tr><tr>
|
||||
<th>Timeframe</th>
|
||||
<td class="text-right text-muted"><small>2years </small></td>
|
||||
<td class="text-right">December 2020 - December 2022</td>
|
||||
</tr><tr>
|
||||
<th>Wins</th>
|
||||
<td class="text-right text-muted"><small>14.29%</small></td>
|
||||
<td class="text-right">1</td>
|
||||
</tr><tr>
|
||||
<th>Placements</th>
|
||||
<td class="text-right text-muted"><small>57.14%</small></td>
|
||||
<td class="text-right">4</td>
|
||||
</tr><tr>
|
||||
<th>Finals</th>
|
||||
<td class="text-right text-muted"><small>1.00x</small></td>
|
||||
<td class="text-right">7</td>
|
||||
</tr><tr>
|
||||
<th>Events</th>
|
||||
<td class="text-right text-muted"><small>1.75x</small></td>
|
||||
<td class="text-right">7</td>
|
||||
</tr><tr>
|
||||
<th>Unique Events</th>
|
||||
<td class="text-right text-muted"><small></small></td>
|
||||
<td class="text-right">4</td>
|
||||
</tr>
|
||||
<tr><td colspan="3" style="border-bottom: 2px solid #ffd54f; padding-bottom: 0; padding-top: 0.5rem; color: #ffd54f"><h4>Intermediate</h4></td></tr><tr>
|
||||
<th>Points</th>
|
||||
<td class="text-right text-muted"><small>20.00%</small></td>
|
||||
<td class="text-right">6</td>
|
||||
</tr><tr>
|
||||
<th>Points Follower</th>
|
||||
<td class="text-right text-muted"><small>100.00%</small></td>
|
||||
<td class="text-right">6</td>
|
||||
</tr><tr>
|
||||
<th>Points Last 3 years</th>
|
||||
<td class="text-right text-muted"><small></small></td>
|
||||
<td class="text-right">6</td>
|
||||
</tr><tr>
|
||||
<th>Timeframe</th>
|
||||
<td class="text-right text-muted"><small></small></td>
|
||||
<td class="text-right">December 2022 - December 2022</td>
|
||||
</tr><tr>
|
||||
<th>Wins</th>
|
||||
<td class="text-right text-muted"><small>0.00%</small></td>
|
||||
<td class="text-right">0</td>
|
||||
</tr><tr>
|
||||
<th>Placements</th>
|
||||
<td class="text-right text-muted"><small>100.00%</small></td>
|
||||
<td class="text-right">1</td>
|
||||
</tr><tr>
|
||||
<th>Finals</th>
|
||||
<td class="text-right text-muted"><small>1.00x</small></td>
|
||||
<td class="text-right">1</td>
|
||||
</tr><tr>
|
||||
<th>Events</th>
|
||||
<td class="text-right text-muted"><small>1.00x</small></td>
|
||||
<td class="text-right">1</td>
|
||||
</tr><tr>
|
||||
<th>Unique Events</th>
|
||||
<td class="text-right text-muted"><small></small></td>
|
||||
<td class="text-right">1</td>
|
||||
</tr><tr><td colspan="3" style="border-bottom: 2px solid #ce93d8; padding-bottom: 0; padding-top: 0.5rem; color: #ce93d8"><h4>Novice</h4></td></tr><tr>
|
||||
<th>Points</th>
|
||||
<td class="text-right text-muted"><small>187.50%</small></td>
|
||||
<td class="text-right">30</td>
|
||||
</tr><tr>
|
||||
<th>Points Follower</th>
|
||||
<td class="text-right text-muted"><small>100.00%</small></td>
|
||||
<td class="text-right">30</td>
|
||||
</tr><tr>
|
||||
<th>Points Last 3 years</th>
|
||||
<td class="text-right text-muted"><small></small></td>
|
||||
<td class="text-right">15</td>
|
||||
</tr><tr>
|
||||
<th>Timeframe</th>
|
||||
<td class="text-right text-muted"><small>1year 11months</small></td>
|
||||
<td class="text-right">December 2020 - November 2022</td>
|
||||
</tr><tr>
|
||||
<th>Wins</th>
|
||||
<td class="text-right text-muted"><small>16.67%</small></td>
|
||||
<td class="text-right">1</td>
|
||||
</tr><tr>
|
||||
<th>Placements</th>
|
||||
<td class="text-right text-muted"><small>50.00%</small></td>
|
||||
<td class="text-right">3</td>
|
||||
</tr><tr>
|
||||
<th>Finals</th>
|
||||
<td class="text-right text-muted"><small>1.00x</small></td>
|
||||
<td class="text-right">6</td>
|
||||
</tr><tr>
|
||||
<th>Events</th>
|
||||
<td class="text-right text-muted"><small>1.50x</small></td>
|
||||
<td class="text-right">6</td>
|
||||
</tr><tr>
|
||||
<th>Unique Events</th>
|
||||
<td class="text-right text-muted"><small></small></td>
|
||||
<td class="text-right">4</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div></div>
|
||||
|
||||
<div class="alert alert-info mt-2">
|
||||
<div class="row">
|
||||
<div class="col-auto"><i class="fa-light fa-circle-info" style="font-size: 2rem;"></i></div>
|
||||
<div class="col">Polina Gorushkina is allowed to dance as a leader in the following divisions:<br/><span class="badge badge-secondary">Novice</span> </div></div></div><div class="alert alert-info mt-2">
|
||||
<div class="row">
|
||||
<div class="col-auto"><i class="fa-light fa-circle-info" style="font-size: 2rem;"></i></div>
|
||||
<div class="col">Polina Gorushkina is allowed to dance as a follower in the following divisions:<br/><span class="badge badge-secondary">Intermediate</span> </div></div></div><h5 class="pt-2">Intermediate: 6 of 30 total points</h5><table class="table table-striped"><tr><td><span class="badge" style="background:#ef5350; color: #fff;">F</span></td><td><div><a href="/enUS/wsdc/results/290/2022-12.html">Shooba Dooba Swing</a></div><div><small>Moscow, Russia - December 2022</small></div><div><small>Partner: <a href="16925.html">Aleksey Artemiev</a></small></div></td><td class="text-center">3rd</td><td class="text-center">6</td></tr><tr><td colspan="3"><b>TOTAL:</b></td><td class="text-center" style="border-top: 3px solid #000; font-weight: bold;">6</td></tr></table><h5 class="pt-2">Novice: 30 of 16 total points</h5><table class="table table-striped"><tr><td><span class="badge" style="background:#ef5350; color: #fff;">F</span></td><td><div><a href="/enUS/wsdc/results/194/2022-11.html">Moscow Westie Fest</a></div><div><small>Moscow, Russia - November 2022</small></div><div><small>Partner: <a href="20062.html">Anna Danilova</a></small></div></td><td class="text-center">1st</td><td class="text-center">15</td></tr><tr><td><span class="badge" style="background:#ef5350; color: #fff;">F</span></td><td><div><a href="/enUS/wsdc/results/280/2022-07.html">St.Petersburg WCS Nights</a></div><div><small>St.Petersburg, Russia - July 2022</small></div><div><small>Partner: <a href="18683.html">Ilya Kramarenko</a></small></div></td><td class="text-center">5th</td><td class="text-center">6</td></tr><tr><td><span class="badge" style="background:#ef5350; color: #fff;">F</span></td><td><div><a href="/enUS/wsdc/results/215/2022-02.html">Swing&Snow</a></div><div><small>St. Petersburg, Russia - February 2022</small></div><div><small>Partner: <a href="19576.html">Maksim Zaidov</a></small></div></td><td class="text-center">5th</td><td class="text-center">6</td></tr><tr><td><span class="badge" style="background:#ef5350; color: #fff;">F</span></td><td><div><a href="/enUS/wsdc/results/290/2021-12.html">Shooba Dooba Swing</a></div><div><small>Moscow, Russia - December 2021</small></div></td><td class="text-center">Final</td><td class="text-center">1</td></tr><tr><td><span class="badge" style="background:#ef5350; color: #fff;">F</span></td><td><div><a href="/enUS/wsdc/results/194/2021-10.html">Moscow Westie Dance Fest</a></div><div><small>Moscow, Russia - October 2021</small></div></td><td class="text-center">Final</td><td class="text-center">1</td></tr><tr><td><span class="badge" style="background:#ef5350; color: #fff;">F</span></td><td><div><a href="/enUS/wsdc/results/290/2020-12.html">Shooba Dooba Swing</a></div><div><small>Moscow, Russia - December 2020</small></div></td><td class="text-center">Final</td><td class="text-center">1</td></tr><tr><td colspan="3"><b>TOTAL:</b></td><td class="text-center" style="border-top: 3px solid #000; font-weight: bold;">30</td></tr></table></section> </main>
|
||||
|
||||
<footer class="pt-4 pb-5 d-print-none ">
|
||||
<div class="container"><div class="row"><div class="col-auto" style="font-size: 8px;">
|
||||
© <a href="https://danceapp.net" target="_blank" rel="nofollow">Danceapp</a>
|
||||
<a href="https://www.facebook.com/AndiKDance/" target="_blank" rel="nofollow">Andreas Kasper</a> v0.1.251002<script>
|
||||
try {
|
||||
document.writeln(" bs"+bootstrap.Tooltip.VERSION);
|
||||
document.writeln(" vu"+Vue.version);
|
||||
} catch (err) {}
|
||||
</script>
|
||||
<div id="WebPushrSID"></div>
|
||||
<script>
|
||||
function _webpushrScriptReady(){
|
||||
webpushr('fetch_id',function (sid) {
|
||||
$("#WebPushrSID").html('WPID'+sid);
|
||||
$("#webpushr-prompt-wrapper").css("display", "none");
|
||||
//save id to database
|
||||
console.log('webpushr subscriber id', sid);
|
||||
});
|
||||
}</script>
|
||||
</div>
|
||||
<div class="col-auto" style="font-size:0.8rem;">
|
||||
<a href="https://m.me/dancescoring" target="_blank" class="d-block d-md-inline mb-1 mr-1" rel="nofollow"><i class="fab fa-facebook"></i><i class="far fa-robot"></i><span class="d-inline d-md-none"> Chatbot Facebook Messenger</span></a>
|
||||
<a href="https://t.me/DanceScoreBot" target="_blank" class="d-block d-md-inline mb-1 mr-1" rel="nofollow"><i class="fab fa-telegram"></i><i class="far fa-robot"></i><span class="d-inline d-md-none"> Chatbot Telegram</span></a>
|
||||
<a href="https://github.com/andreaskasper/scoringCE/issues" target="_blank" class="d-block d-md-inline mb-1 mr-1" rel="nofollow"><i class="fas fa-bug"></i> bug found</a>
|
||||
<a href="/enUS/translate" class="d-block d-md-inline mb-1 mr-1" TARGET="_blank" rel="nofollow"><i class="far fa-language"></i> please help to translate this page into your language</a>
|
||||
<a href="https://www.patreon.com/AndreasKasper" class="d-block d-md-inline mb-1 mr-1" TARGET="_blank" rel="nofollow"><i class="far fa-donate"></i> support us</a>
|
||||
<a href="/datenschutz" class="d-block d-md-inline mb-1 mr-1" TARGET="_blank" rel="nofollow">data privacy</a>
|
||||
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
</div></div>
|
||||
</div></footer>
|
||||
|
||||
<!-- start webpushr tracking code -->
|
||||
<script>(function(w,d, s, id) {if(typeof(w.webpushr)!=='undefined') return;w.webpushr=w.webpushr||function(){(w.webpushr.q=w.webpushr.q||[]).push(arguments)};var js, fjs = d.getElementsByTagName(s)[0];js = d.createElement(s); js.id = id;js.async=1;js.src = "https://cdn.webpushr.com/app.min.js";
|
||||
fjs.parentNode.appendChild(js);}(window,document, 'script', 'webpushr-jssdk'));
|
||||
webpushr('setup',{'key':'BJANqDvin764ySQNqrsGDR3tJstkuhfRQNJ22gJptkjkHW33MF4gZ-PjiGOutjmAAhDvmI5kfPTokHVr6UGOU7Q' });</script>
|
||||
<!-- end webpushr tracking code -->
|
||||
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-486839-36"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'UA-486839-36');
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,19 +1,10 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(serde::Deserialize, Debug, PartialEq, Eq)]
|
||||
#[derive(serde::Deserialize, serde::Serialize, Debug, PartialEq, Eq)]
|
||||
pub enum DanceRole {
|
||||
Leader,
|
||||
Follower,
|
||||
}
|
||||
|
||||
impl DanceRole {
|
||||
pub const fn as_str(&self) -> &str {
|
||||
match self {
|
||||
Self::Leader => "Leader",
|
||||
Self::Follower => "Follower",
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub const fn other(&self) -> Self {
|
||||
match self {
|
||||
@@ -23,65 +14,32 @@ impl DanceRole {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Debug, PartialEq, Eq)]
|
||||
serde_plain::derive_display_from_serialize!(DanceRole);
|
||||
serde_plain::derive_fromstr_from_deserialize!(DanceRole);
|
||||
|
||||
#[derive(
|
||||
serde::Serialize, serde::Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy,
|
||||
)]
|
||||
pub enum DanceRank {
|
||||
Newcomer,
|
||||
Novice,
|
||||
Intermediate,
|
||||
#[serde(rename = "Advance")]
|
||||
Advanced,
|
||||
#[serde(rename = "All Star")]
|
||||
#[serde(rename = "All Star", alias = "All-Stars")]
|
||||
AllStars,
|
||||
Champions,
|
||||
}
|
||||
|
||||
impl DanceRank {
|
||||
pub const fn as_str(&self) -> &str {
|
||||
match self {
|
||||
Self::Newcomer => "Newcomer",
|
||||
Self::Novice => "Novice",
|
||||
Self::Intermediate => "Intermediate",
|
||||
Self::Advanced => "Advanced",
|
||||
Self::AllStars => "All-Stars",
|
||||
Self::Champions => "Champions",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Debug)]
|
||||
enum OptionalDanceRank {
|
||||
#[serde(rename = "N/A")]
|
||||
NotAvailable,
|
||||
#[serde(untagged)]
|
||||
Rank(DanceRank),
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Debug)]
|
||||
enum OptionalDancePoints {
|
||||
#[serde(rename = "N/A")]
|
||||
NotAvailable,
|
||||
#[serde(untagged)]
|
||||
Points(u16),
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Debug)]
|
||||
struct DanceInfoParser {
|
||||
pub dancer_first: String,
|
||||
pub dancer_last: String,
|
||||
pub short_dominate_role: DanceRole,
|
||||
#[allow(dead_code)]
|
||||
pub short_non_dominate_role: DanceRole,
|
||||
pub dominate_role_highest_level_points: u16,
|
||||
pub dominate_role_highest_level: DanceRank,
|
||||
pub non_dominate_role_highest_level_points: OptionalDancePoints,
|
||||
pub non_dominate_role_highest_level: OptionalDanceRank,
|
||||
}
|
||||
serde_plain::derive_display_from_serialize!(DanceRank);
|
||||
serde_plain::derive_fromstr_from_deserialize!(DanceRank);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CompState {
|
||||
pub rank: DanceRank,
|
||||
pub points: u16,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DanceInfo {
|
||||
pub firstname: String,
|
||||
pub lastname: String,
|
||||
@@ -94,63 +52,4 @@ impl DanceInfo {
|
||||
pub fn name(&self) -> String {
|
||||
format!("{} {}", self.firstname, self.lastname)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub const fn non_dominant_role(&self) -> DanceRole {
|
||||
self.dominant_role.other()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DanceInfoParser> for DanceInfo {
|
||||
fn from(value: DanceInfoParser) -> Self {
|
||||
let non_dominant_role_comp = if let OptionalDanceRank::Rank(r) =
|
||||
value.non_dominate_role_highest_level
|
||||
&& let OptionalDancePoints::Points(l) = value.non_dominate_role_highest_level_points
|
||||
{
|
||||
Some(CompState { rank: r, points: l })
|
||||
} else {
|
||||
None
|
||||
};
|
||||
Self {
|
||||
firstname: value.dancer_first,
|
||||
lastname: value.dancer_last,
|
||||
dominant_role: value.short_dominate_role,
|
||||
dominant_role_comp: CompState {
|
||||
rank: value.dominate_role_highest_level,
|
||||
points: value.dominate_role_highest_level_points,
|
||||
},
|
||||
non_dominant_role_comp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum DanceInfoError {
|
||||
#[error("Failed to build client: {0}")]
|
||||
ClientBuild(reqwest::Error),
|
||||
#[error("Request error: {0}")]
|
||||
Request(reqwest::Error),
|
||||
#[error("Failed to parse response: {0}")]
|
||||
JsonParse(reqwest::Error),
|
||||
}
|
||||
|
||||
pub async fn fetch_wsdc_info(id: u32) -> Result<DanceInfo, DanceInfoError> {
|
||||
let client = reqwest::ClientBuilder::new()
|
||||
.build()
|
||||
.map_err(DanceInfoError::ClientBuild)?;
|
||||
|
||||
let mut params = HashMap::new();
|
||||
params.insert("q", id.to_string());
|
||||
let response = client
|
||||
.request(
|
||||
reqwest::Method::POST,
|
||||
"https://points.worldsdc.com/lookup2020/find",
|
||||
)
|
||||
.form(¶ms)
|
||||
.send()
|
||||
.await
|
||||
.map_err(DanceInfoError::Request)?;
|
||||
|
||||
let x: DanceInfoParser = response.json().await.map_err(DanceInfoError::JsonParse)?;
|
||||
Ok(x.into())
|
||||
}
|
||||
|
||||
61
src/main.rs
61
src/main.rs
@@ -5,6 +5,10 @@
|
||||
clippy::multiple_crate_versions,
|
||||
reason = "Don't know how to fix this, should be fine"
|
||||
)]
|
||||
#![allow(
|
||||
clippy::future_not_send,
|
||||
reason = "Probably makes sense to fix this, I'll wait for mwbot to fix it"
|
||||
)]
|
||||
#![allow(
|
||||
clippy::cast_possible_truncation,
|
||||
clippy::cast_precision_loss,
|
||||
@@ -12,18 +16,23 @@
|
||||
clippy::cast_possible_wrap,
|
||||
reason = "Disable this for most of the time, enable this for cleanup later"
|
||||
)]
|
||||
#![feature(hash_map_macro)]
|
||||
#![feature(never_type)]
|
||||
|
||||
use mwbot::{
|
||||
Bot,
|
||||
Bot, ConfigError,
|
||||
generators::{Generator, SortDirection, categories::CategoryMemberSort},
|
||||
};
|
||||
use std::{error::Error, path::Path};
|
||||
use std::path::Path;
|
||||
|
||||
use crate::watchdog::watch_wanted;
|
||||
|
||||
mod dance_info;
|
||||
mod updater;
|
||||
mod watchdog;
|
||||
mod wikiinfo;
|
||||
mod wikipage;
|
||||
mod worldsdc;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[allow(clippy::print_stdout, reason = "We want to print here")]
|
||||
@@ -38,31 +47,37 @@ fn list_teacher_pages(bot: &Bot) -> tokio::sync::mpsc::Receiver<Result<mwbot::Pa
|
||||
pages.generate(bot)
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
#[must_use]
|
||||
pub fn app_signature() -> String {
|
||||
format!("{} [{}]", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"))
|
||||
}
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum AppError {
|
||||
#[error("Runtime error: {0}")]
|
||||
RuntimeError(#[from] std::io::Error),
|
||||
#[error("Bot initialization error: {0}")]
|
||||
BotError(#[from] ConfigError),
|
||||
}
|
||||
|
||||
fn main() -> Result<(), AppError> {
|
||||
tracing_subscriber::fmt()
|
||||
.with_level(true)
|
||||
.with_max_level(tracing::Level::INFO)
|
||||
.init();
|
||||
tracing::info!("Starting {}", app_signature());
|
||||
|
||||
let rt = match tokio::runtime::Builder::new_current_thread()
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
{
|
||||
Ok(o) => o,
|
||||
Err(e) => {
|
||||
tracing::error!("Could not start runtime: {e}");
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
rt.block_on(async {
|
||||
let bot = match Bot::from_path(Path::new("./mwbot.toml")).await {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
dbg!(e);
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
watch_wanted(bot).await;
|
||||
Ok(())
|
||||
})
|
||||
.build()?;
|
||||
|
||||
let bot = rt.block_on(Bot::from_path(Path::new("./mwbot.toml")))?;
|
||||
|
||||
#[allow(
|
||||
unreachable_code,
|
||||
reason = "This is a false positive I think, I just want to loop infinitely on two futures"
|
||||
)]
|
||||
rt.block_on(async { futures::join!(watch_wanted(bot.clone()), updater::update_wsdc(bot)) });
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
39
src/updater.rs
Normal file
39
src/updater.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use mwbot::Bot;
|
||||
use rand::seq::SliceRandom as _;
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::{watchdog::generate_page, wikiinfo::index_wsdc_ids};
|
||||
|
||||
pub async fn update_wsdc(bot: Bot) -> ! {
|
||||
loop {
|
||||
update_all_teachers(&bot).await;
|
||||
}
|
||||
}
|
||||
|
||||
/// Updates all teachers once
|
||||
async fn update_all_teachers(bot: &Bot) {
|
||||
let mut l = index_wsdc_ids(bot).await;
|
||||
l.shuffle(&mut rand::rng());
|
||||
tracing::info!("We have to update {} pages", l.len());
|
||||
let wait_duration = Duration::from_hours(6);
|
||||
|
||||
for (index, page) in l {
|
||||
process_page(wait_duration, index, page).await;
|
||||
}
|
||||
tracing::info!("Updates all pages");
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(page, wait_duration))]
|
||||
async fn process_page(wait_duration: Duration, index: u32, page: mwbot::Page) {
|
||||
tracing::info!("Next up");
|
||||
sleep(wait_duration).await;
|
||||
|
||||
match generate_page(index, page).await {
|
||||
Ok(()) => (),
|
||||
Err(err) => {
|
||||
tracing::error!("Error updating: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
174
src/watchdog.rs
174
src/watchdog.rs
@@ -1,106 +1,92 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::{
|
||||
dance_info::{DanceInfo, fetch_wsdc_info},
|
||||
wikiinfo::wanted_ids,
|
||||
};
|
||||
use mwbot::{
|
||||
Bot,
|
||||
parsoid::{self, Template, Wikicode, map::IndexMap},
|
||||
};
|
||||
use mwbot::{SaveOptions, parsoid::WikinodeIterator};
|
||||
use tracing::Level;
|
||||
use crate::app_signature;
|
||||
use crate::wikipage::InfoCompileError;
|
||||
use crate::worldsdc::DanceInfoError;
|
||||
use crate::{wikiinfo::wanted_ids, wikipage::page_from_info, worldsdc::fetch_wsdc_info};
|
||||
use mwbot::SaveOptions;
|
||||
use mwbot::{Bot, Page};
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
enum InfoCompileError {
|
||||
#[error("Could not compile wikipage: {0}")]
|
||||
CompileError(#[from] parsoid::Error),
|
||||
pub struct Ticker {
|
||||
count: usize,
|
||||
max: usize,
|
||||
}
|
||||
|
||||
fn page_from_info(info: DanceInfo) -> Result<Wikicode, InfoCompileError> {
|
||||
let mut params = IndexMap::new();
|
||||
params.insert("name".to_string(), info.name());
|
||||
params.insert(
|
||||
"dominant_role".to_string(),
|
||||
info.dominant_role.as_str().to_string(),
|
||||
);
|
||||
params.insert(
|
||||
"allowed_rank".to_string(),
|
||||
info.dominant_role_comp.rank.as_str().to_string(),
|
||||
);
|
||||
params.insert(
|
||||
"dominant_rank".to_string(),
|
||||
info.dominant_role_comp.rank.as_str().to_string(),
|
||||
);
|
||||
params.insert(
|
||||
"dominant_points".to_string(),
|
||||
info.dominant_role_comp.points.to_string(),
|
||||
);
|
||||
if let Some(u) = info.non_dominant_role_comp {
|
||||
params.insert("non_dominant_rank".to_string(), u.rank.as_str().to_string());
|
||||
params.insert("non_dominant_points".to_string(), u.points.to_string());
|
||||
impl Ticker {
|
||||
pub const fn new(max: usize) -> Self {
|
||||
Self { count: 0, max }
|
||||
}
|
||||
let t = Template::new("Template:WSDCBox", ¶ms)?;
|
||||
let result = Wikicode::new("");
|
||||
result.append(&t);
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub async fn watch_wanted(bot: Bot) {
|
||||
let span = tracing::span!(Level::INFO, "wanted_watchdog");
|
||||
let _enter = span.enter();
|
||||
|
||||
let mut ignored_ids = vec![];
|
||||
loop {
|
||||
if ignored_ids.is_empty() {
|
||||
tracing::info!("Watchdog check...");
|
||||
/// Returns `true` if the ticker has "ticked" (i.e., reached `max` and reset).
|
||||
pub const fn tick(&mut self) -> bool {
|
||||
self.count += 1;
|
||||
if self.count >= self.max {
|
||||
self.count = 0;
|
||||
true
|
||||
} else {
|
||||
tracing::info!("Watchdog check [{} failed ids]...", ignored_ids.len());
|
||||
}
|
||||
let wanted = wanted_ids(bot.clone()).await;
|
||||
let mut new_ignored = vec![];
|
||||
for (id, page) in wanted.into_iter().filter(|(x, _)| ignored_ids.contains(x)) {
|
||||
if !generate_page(id, page).await {
|
||||
new_ignored.push(id);
|
||||
}
|
||||
}
|
||||
if !new_ignored.is_empty() {
|
||||
ignored_ids.extend(new_ignored);
|
||||
}
|
||||
tokio::time::sleep(Duration::from_secs(30)).await;
|
||||
}
|
||||
}
|
||||
|
||||
async fn generate_page(id: u32, page: mwbot::Page) -> bool {
|
||||
tracing::info!("Taking care of {id}");
|
||||
let info = match fetch_wsdc_info(id).await {
|
||||
Ok(o) => o,
|
||||
Err(e) => {
|
||||
tracing::error!("Error fetching wsdc info for {id}: {e}");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
let code = match page_from_info(info) {
|
||||
Ok(o) => o,
|
||||
Err(e) => {
|
||||
tracing::error!("Creating wikicode for {id}: {e}");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
match page
|
||||
.save(
|
||||
code,
|
||||
&SaveOptions::summary("Created WSDC info from worldsdc.com")
|
||||
.mark_as_bot(true)
|
||||
.mark_as_minor(false),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => true,
|
||||
Err(e) => {
|
||||
tracing::error!("Could not save page for {id}: {e}");
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Continuously monitors teacher IDs that do not have a corresponding teacher WSDC page, ignoring those that fail processing.
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn watch_wanted(bot: Bot) -> ! {
|
||||
let mut ignored_ids = vec![];
|
||||
let mut heartbeat_ticker = Ticker::new(120);
|
||||
loop {
|
||||
if heartbeat_ticker.tick() {
|
||||
tracing::info!(failed_id_count = ignored_ids.len(), "Watchdog check...");
|
||||
}
|
||||
let wanted = wanted_ids(bot.clone()).await;
|
||||
let new_ignored = update_wanted_ids(&wanted, &ignored_ids).await;
|
||||
ignored_ids.extend(new_ignored);
|
||||
tokio::time::sleep(Duration::from_secs(30)).await;
|
||||
}
|
||||
}
|
||||
|
||||
async fn update_wanted_ids(wanted: &[(u32, Page)], ignored_ids: &[u32]) -> Vec<u32> {
|
||||
let mut new_ignored = vec![];
|
||||
|
||||
for (id, page) in wanted.iter().filter(|(x, _)| ignored_ids.contains(x)) {
|
||||
let span = tracing::info_span!("update", id);
|
||||
let _enter = span.enter();
|
||||
if let Err(e) = generate_page(*id, page.clone()).await {
|
||||
tracing::error!("{e}");
|
||||
new_ignored.push(*id);
|
||||
}
|
||||
}
|
||||
new_ignored
|
||||
}
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum GeneratePageError {
|
||||
#[error("Error fetching WSDC info for {0}")]
|
||||
Fetch(#[from] DanceInfoError),
|
||||
#[error("Error creating wikicode for {0}")]
|
||||
Wikicode(#[from] InfoCompileError),
|
||||
#[error("Error saving page for {0}")]
|
||||
Save(#[from] mwbot::Error),
|
||||
}
|
||||
|
||||
pub async fn generate_page(id: u32, page: mwbot::Page) -> Result<(), GeneratePageError> {
|
||||
tracing::info!("Generating page for {id}");
|
||||
let info = fetch_wsdc_info(id).await?;
|
||||
|
||||
let code = page_from_info(info)?;
|
||||
|
||||
page.save(
|
||||
code,
|
||||
&SaveOptions::summary(&format!(
|
||||
"Created WSDC info from worldsdc.com -- {}",
|
||||
app_signature()
|
||||
))
|
||||
.mark_as_bot(true)
|
||||
.mark_as_minor(false),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -42,8 +42,20 @@ fn parse_wsdc_page_name(name: &str) -> Result<u32, TitleParseError> {
|
||||
}
|
||||
}
|
||||
|
||||
// fn get_wsdc_page_date(bot: &Bot, page: &Page) -> Option<SystemTime> {
|
||||
// todo!();
|
||||
// let prefix = "Updated-On: ";
|
||||
// page.filter_comments()
|
||||
// .iter()
|
||||
// .filter_map(|x| {
|
||||
// let c = x.text_contents();
|
||||
// if c.starts_with(prefix) { Some(c) } else { None }
|
||||
// })
|
||||
// .map(|x| x.trim_start_matches(prefix).parse::<u64>());
|
||||
// }
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn index_wsdc_ids(bot: &Bot) -> Vec<u32> {
|
||||
pub async fn index_wsdc_ids(bot: &Bot) -> Vec<(u32, Page)> {
|
||||
let mut gene = Search::new("WSDC/").generate(bot);
|
||||
let mut result = vec![];
|
||||
while let Some(x) = gene.recv().await {
|
||||
@@ -55,7 +67,7 @@ pub async fn index_wsdc_ids(bot: &Bot) -> Vec<u32> {
|
||||
}
|
||||
};
|
||||
if let Ok(n) = parse_wsdc_page_name(p.title()) {
|
||||
result.push(n);
|
||||
result.push((n, p));
|
||||
}
|
||||
}
|
||||
result
|
||||
|
||||
35
src/wikipage.rs
Normal file
35
src/wikipage.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use crate::dance_info::DanceInfo;
|
||||
use mwbot::parsoid::WikinodeIterator;
|
||||
use mwbot::parsoid::{self, Template, Wikicode, map::IndexMap};
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum InfoCompileError {
|
||||
#[error("Could not compile wikipage: {0}")]
|
||||
CompileError(#[from] parsoid::Error),
|
||||
}
|
||||
|
||||
pub fn page_from_info(info: DanceInfo) -> Result<Wikicode, InfoCompileError> {
|
||||
let mut params = IndexMap::new();
|
||||
params.insert("name".to_string(), info.name());
|
||||
params.insert("dominant_role".to_string(), info.dominant_role.to_string());
|
||||
params.insert(
|
||||
"allowed_rank".to_string(),
|
||||
info.dominant_role_comp.rank.to_string(),
|
||||
);
|
||||
params.insert(
|
||||
"dominant_rank".to_string(),
|
||||
info.dominant_role_comp.rank.to_string(),
|
||||
);
|
||||
params.insert(
|
||||
"dominant_points".to_string(),
|
||||
info.dominant_role_comp.points.to_string(),
|
||||
);
|
||||
if let Some(u) = info.non_dominant_role_comp {
|
||||
params.insert("non_dominant_rank".to_string(), u.rank.to_string());
|
||||
params.insert("non_dominant_points".to_string(), u.points.to_string());
|
||||
}
|
||||
let t = Template::new("Template:WSDCBox", ¶ms)?;
|
||||
let result = Wikicode::new("");
|
||||
result.append(&t);
|
||||
Ok(result)
|
||||
}
|
||||
48
src/worldsdc/caching.rs
Normal file
48
src/worldsdc/caching.rs
Normal file
@@ -0,0 +1,48 @@
|
||||
use std::{collections::HashMap, path::Path};
|
||||
|
||||
use reqwest::{Client, ClientBuilder};
|
||||
|
||||
use crate::{dance_info::DanceInfo, worldsdc::DanceInfoError};
|
||||
|
||||
use super::DanceInfoParser;
|
||||
|
||||
struct CachingFetcher {
|
||||
hitcache: Vec<(u32, String)>,
|
||||
errorcache: Vec<(u32, String)>,
|
||||
client: Client,
|
||||
}
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
enum CachingFetcherCreationError {
|
||||
#[error("Could not create client: {0}")]
|
||||
ClientError(#[from] reqwest::Error),
|
||||
}
|
||||
|
||||
impl CachingFetcher {
|
||||
pub fn new(cachepath: &Path) -> Result<Self, CachingFetcherCreationError> {
|
||||
let client = ClientBuilder::new().build()?;
|
||||
|
||||
Ok(Self {
|
||||
hitcache: vec![],
|
||||
errorcache: vec![],
|
||||
client,
|
||||
})
|
||||
}
|
||||
pub async fn fetch(&mut self, id: u32) -> Result<DanceInfo, DanceInfoError> {
|
||||
let mut params = HashMap::new();
|
||||
params.insert("q", id.to_string());
|
||||
let response = self
|
||||
.client
|
||||
.request(
|
||||
reqwest::Method::POST,
|
||||
"https://points.worldsdc.com/lookup2020/find",
|
||||
)
|
||||
.form(¶ms)
|
||||
.send()
|
||||
.await
|
||||
.map_err(DanceInfoError::Request)?;
|
||||
|
||||
let x: DanceInfoParser = response.json().await.map_err(DanceInfoError::JsonParse)?;
|
||||
Ok(x.into())
|
||||
}
|
||||
}
|
||||
132
src/worldsdc/mod.rs
Normal file
132
src/worldsdc/mod.rs
Normal file
@@ -0,0 +1,132 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
app_signature,
|
||||
dance_info::{CompState, DanceInfo, DanceRank, DanceRole},
|
||||
worldsdc::scoringdance::fetch_wsdc_info_scoring_dance,
|
||||
};
|
||||
use reqwest::ClientBuilder;
|
||||
mod scoringdance;
|
||||
|
||||
pub async fn fetch_wsdc_info_wsdc(id: u32) -> Result<DanceInfo, DanceInfoError> {
|
||||
let client = ClientBuilder::new()
|
||||
.user_agent(app_signature())
|
||||
.build()
|
||||
.map_err(DanceInfoError::ClientBuild)?;
|
||||
|
||||
let mut params = HashMap::new();
|
||||
|
||||
let url = if cfg!(test) {
|
||||
// "https://o5grQU3Y.free.beeceptor.com/lookup2020/find"
|
||||
"http://localhost:8000"
|
||||
} else {
|
||||
"https://points.worldsdc.com/lookup2020/find"
|
||||
};
|
||||
params.insert("num", id.to_string());
|
||||
let request = client
|
||||
.request(reqwest::Method::POST, url)
|
||||
.form(¶ms)
|
||||
.build()
|
||||
.map_err(DanceInfoError::RequestBuild)?;
|
||||
let response = client
|
||||
.execute(request)
|
||||
.await
|
||||
.map_err(DanceInfoError::Request)?;
|
||||
|
||||
let x: DanceInfoParser = response.json().await.map_err(DanceInfoError::JsonParse)?;
|
||||
Ok(x.into())
|
||||
}
|
||||
|
||||
pub async fn fetch_wsdc_info(id: u32) -> Result<DanceInfo, DanceInfoError> {
|
||||
fetch_wsdc_info_scoring_dance(id).await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#![allow(clippy::unwrap_used, reason = "Allow unwrap in tests")]
|
||||
use crate::worldsdc::fetch_wsdc_info;
|
||||
|
||||
#[test]
|
||||
#[ignore = "Only run when the mock api is setup"]
|
||||
fn test_fetch_wsdc() {
|
||||
let rt = match tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
{
|
||||
Ok(o) => o,
|
||||
Err(e) => {
|
||||
tracing::error!("Could not start runtime: {e}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
let x = rt.block_on(fetch_wsdc_info(7));
|
||||
dbg!(&x);
|
||||
x.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum DanceInfoError {
|
||||
#[error("Failed to build client: {0}")]
|
||||
ClientBuild(reqwest::Error),
|
||||
#[error("Failed to build request: {0}")]
|
||||
RequestBuild(reqwest::Error),
|
||||
#[error("Request error: {0}")]
|
||||
Request(reqwest::Error),
|
||||
#[error("Failed to parse response: {0}")]
|
||||
JsonParse(reqwest::Error),
|
||||
#[error("Failed to parse html: {0}")]
|
||||
HtmlParse(#[from] scoringdance::ScoringParseError),
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Debug)]
|
||||
enum OptionalDanceRank {
|
||||
#[serde(rename = "N/A")]
|
||||
NotAvailable,
|
||||
#[serde(untagged)]
|
||||
Rank(DanceRank),
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Debug)]
|
||||
enum OptionalDancePoints {
|
||||
#[serde(rename = "N/A")]
|
||||
NotAvailable,
|
||||
#[serde(untagged)]
|
||||
Points(u16),
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Debug)]
|
||||
struct DanceInfoParser {
|
||||
pub dancer_first: String,
|
||||
pub dancer_last: String,
|
||||
pub short_dominate_role: DanceRole,
|
||||
#[allow(dead_code)]
|
||||
pub short_non_dominate_role: DanceRole,
|
||||
pub dominate_role_highest_level_points: u16,
|
||||
pub dominate_role_highest_level: DanceRank,
|
||||
pub non_dominate_role_highest_level_points: OptionalDancePoints,
|
||||
pub non_dominate_role_highest_level: OptionalDanceRank,
|
||||
}
|
||||
|
||||
impl From<DanceInfoParser> for DanceInfo {
|
||||
fn from(value: DanceInfoParser) -> Self {
|
||||
let non_dominant_role_comp = if let OptionalDanceRank::Rank(r) =
|
||||
value.non_dominate_role_highest_level
|
||||
&& let OptionalDancePoints::Points(l) = value.non_dominate_role_highest_level_points
|
||||
{
|
||||
Some(CompState { rank: r, points: l })
|
||||
} else {
|
||||
None
|
||||
};
|
||||
Self {
|
||||
firstname: value.dancer_first,
|
||||
lastname: value.dancer_last,
|
||||
dominant_role: value.short_dominate_role,
|
||||
dominant_role_comp: CompState {
|
||||
rank: value.dominate_role_highest_level,
|
||||
points: value.dominate_role_highest_level_points,
|
||||
},
|
||||
non_dominant_role_comp,
|
||||
}
|
||||
}
|
||||
}
|
||||
196
src/worldsdc/scoringdance.rs
Normal file
196
src/worldsdc/scoringdance.rs
Normal file
@@ -0,0 +1,196 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use reqwest::ClientBuilder;
|
||||
use scraper::{ElementRef, Html, Selector};
|
||||
|
||||
use crate::{
|
||||
app_signature,
|
||||
dance_info::{CompState, DanceInfo, DanceRank, DanceRole},
|
||||
worldsdc::DanceInfoError,
|
||||
};
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum ScoringParseError {
|
||||
#[error("Could not parse: {0}")]
|
||||
ParseMismatch(String),
|
||||
}
|
||||
|
||||
fn parse_card(t: ElementRef) -> Result<(String, Vec<Vec<String>>), ScoringParseError> {
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let title_selector = Selector::parse("div.card-header").unwrap();
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let table_selector = Selector::parse("div.card-body > table").unwrap();
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let row_selector = Selector::parse("tr").unwrap();
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let cell_selector = Selector::parse("th,td").unwrap();
|
||||
let table = t
|
||||
.select(&table_selector)
|
||||
.next()
|
||||
.ok_or_else(|| ScoringParseError::ParseMismatch("table".to_owned()))?;
|
||||
let title = t
|
||||
.select(&title_selector)
|
||||
.next()
|
||||
.ok_or_else(|| ScoringParseError::ParseMismatch("title".to_owned()))?
|
||||
.text()
|
||||
.collect::<Vec<_>>()
|
||||
.join("")
|
||||
.trim()
|
||||
.to_owned();
|
||||
|
||||
let parsed_table = table
|
||||
.select(&row_selector)
|
||||
.map(|row| {
|
||||
row.select(&cell_selector)
|
||||
.map(|v| v.text().collect::<String>().trim().to_string())
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
Ok((title, parsed_table))
|
||||
}
|
||||
|
||||
fn parse_details(d: &[Vec<String>]) -> Result<(String, String), ScoringParseError> {
|
||||
let first_name_row = d.iter().find(|v| {
|
||||
v.first()
|
||||
.is_some_and(|v| v.to_lowercase().contains("first name"))
|
||||
});
|
||||
let last_name_row = d.iter().find(|v| {
|
||||
v.first()
|
||||
.is_some_and(|v| v.to_lowercase().contains("last name"))
|
||||
});
|
||||
let first_name = first_name_row
|
||||
.ok_or_else(|| ScoringParseError::ParseMismatch("first_name".to_owned()))?
|
||||
.last()
|
||||
.ok_or_else(|| ScoringParseError::ParseMismatch("first_name value".to_owned()))?;
|
||||
let last_name = last_name_row
|
||||
.ok_or_else(|| ScoringParseError::ParseMismatch("last_name".to_owned()))?
|
||||
.last()
|
||||
.ok_or_else(|| ScoringParseError::ParseMismatch("first_name value".to_owned()))?;
|
||||
Ok((first_name.clone(), last_name.clone()))
|
||||
}
|
||||
|
||||
fn parse_stats(
|
||||
d: &[Vec<String>],
|
||||
) -> Result<(DanceRole, CompState, Option<CompState>), ScoringParseError> {
|
||||
let chapters = d.chunk_by(|_, b| b.len() != 1).map(|v| {
|
||||
let (a, b) = v.split_first().unwrap();
|
||||
let a = a.first().unwrap();
|
||||
let b = b
|
||||
.iter()
|
||||
.map(|v| [v.first().unwrap(), v.last().unwrap()])
|
||||
.collect::<Vec<_>>();
|
||||
(a, b)
|
||||
});
|
||||
|
||||
let (all_time, rest) = chapters.partition::<Vec<_>, _>(|(a, _)| a.to_lowercase() == "all time");
|
||||
let all_time = &all_time.split_first().unwrap().0.1;
|
||||
let mut sorted_chapters = rest
|
||||
.into_iter()
|
||||
.map(|(chapter, items)| {
|
||||
let rank: DanceRank = serde_plain::from_str(chapter).map_err(|_| chapter.to_owned())?;
|
||||
Ok::<(DanceRank, Vec<[&String; 2]>), String>((rank, items))
|
||||
})
|
||||
.filter_map(|v| match v {
|
||||
Ok(v) => Some(v),
|
||||
Err(e) => {
|
||||
tracing::warn!("Unknown chapter in parsed html: {e}");
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
sorted_chapters.sort_by_key(|(a, _)| *a);
|
||||
sorted_chapters.reverse();
|
||||
let leader_rank = sorted_chapters.iter().find_map(|(rank, items)| {
|
||||
items
|
||||
.iter()
|
||||
.find(|[a, _]| a.to_lowercase().contains("points leader"))
|
||||
.map(|[_, points]| (rank, points))
|
||||
});
|
||||
let follower_rank = sorted_chapters.iter().find_map(|(rank, items)| {
|
||||
items
|
||||
.iter()
|
||||
.find(|[a, _]| a.to_lowercase().contains("points follower"))
|
||||
.map(|[_, points]| (rank, points))
|
||||
});
|
||||
let primary_role: DanceRole = all_time
|
||||
.iter()
|
||||
.find_map(|[key, value]| {
|
||||
if !key.to_lowercase().contains("primary role") {
|
||||
return None;
|
||||
}
|
||||
Some(value)
|
||||
})
|
||||
.map(|arg0: &&std::string::String| DanceRole::from_str(arg0.as_str()).unwrap())
|
||||
.unwrap();
|
||||
|
||||
let ((rank, points), non_d) = match primary_role {
|
||||
DanceRole::Leader => (leader_rank.unwrap(), follower_rank),
|
||||
DanceRole::Follower => (follower_rank.unwrap(), leader_rank),
|
||||
};
|
||||
let dominant_comp = CompState {
|
||||
points: points.parse().unwrap(),
|
||||
rank: *rank,
|
||||
};
|
||||
let non_dominant_comp = non_d.map(|(rank, points)| CompState {
|
||||
points: points.parse().unwrap(),
|
||||
rank: *rank,
|
||||
});
|
||||
Ok((primary_role, dominant_comp, non_dominant_comp))
|
||||
|
||||
// dbg!(chapters.collect::<Vec<_>>());
|
||||
}
|
||||
|
||||
fn extract_tables(html: &str) -> Result<Vec<(String, Vec<Vec<String>>)>, ScoringParseError> {
|
||||
let document = Html::parse_document(html);
|
||||
let card_selector = Selector::parse("div:has( > div.card-header)").unwrap();
|
||||
|
||||
document.select(&card_selector).map(parse_card).collect()
|
||||
}
|
||||
|
||||
fn parse_info(html: &str) -> Result<DanceInfo, ScoringParseError> {
|
||||
let tables = extract_tables(html)?;
|
||||
let details = &tables
|
||||
.iter()
|
||||
.find(|(v, _)| v.to_lowercase().contains("detail"))
|
||||
.ok_or_else(|| ScoringParseError::ParseMismatch("detail card".to_owned()))?
|
||||
.1;
|
||||
let stats = &tables
|
||||
.iter()
|
||||
.find(|(v, _)| v.to_lowercase().contains("stats"))
|
||||
.ok_or_else(|| ScoringParseError::ParseMismatch("stats card".to_owned()))?
|
||||
.1;
|
||||
|
||||
let (dominant_role, dominant_role_comp, non_dominant_role_comp) = parse_stats(stats)?;
|
||||
let (firstname, lastname) = parse_details(details)?;
|
||||
|
||||
Ok(DanceInfo {
|
||||
firstname,
|
||||
lastname,
|
||||
dominant_role,
|
||||
dominant_role_comp,
|
||||
non_dominant_role_comp,
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_table() {
|
||||
dbg!(parse_info(include_str!("../../polina.html")));
|
||||
}
|
||||
|
||||
pub async fn fetch_wsdc_info_scoring_dance(id: u32) -> Result<DanceInfo, DanceInfoError> {
|
||||
let client = ClientBuilder::new()
|
||||
.user_agent(app_signature())
|
||||
.build()
|
||||
.map_err(DanceInfoError::ClientBuild)?;
|
||||
|
||||
let url = format!("https://scoring.dance/enUS/wsdc/registry/{id}.html");
|
||||
let request = client
|
||||
.request(reqwest::Method::GET, url)
|
||||
.build()
|
||||
.map_err(DanceInfoError::RequestBuild)?;
|
||||
let response = client
|
||||
.execute(request)
|
||||
.await
|
||||
.map_err(DanceInfoError::Request)?;
|
||||
|
||||
parse_info(response.text().await.unwrap().as_str()).map_err(DanceInfoError::HtmlParse)
|
||||
}
|
||||
Reference in New Issue
Block a user