Added js part of runners by laptime

ref #1
This commit is contained in:
Nicolai Ort 2021-04-06 10:22:35 +02:00
parent 3275ae2609
commit 10b862d43a

View File

@ -6,7 +6,7 @@
function init(el) {
el.focus();
}
$: pages = ["general", "runners_distance", "orgs_distance", "teams_distance"];
$: pages = ["general", "runners_distance","runners_laptime", "orgs_distance", "teams_distance"];
$: current_page = "general";
$: general = {};
$: runners = [];
@ -17,10 +17,22 @@
$: hours = (time.getHours() + "").padStart(2, "0");
$: minutes = (time.getMinutes() + "").padStart(2, "0");
$: seconds = (time.getSeconds() + "").padStart(2, "0");
function format_laptime(laptime){
if(laptime < 60){return `${laptime}s`}
if(laptime < 3600){return `${Math.floor(laptime / 60)}min ${laptime - (Math.floor(laptime / 60)*60)}s`}
return `${Math.floor(laptime / 3600)}h ${laptime - (Math.floor(laptime / 3600)*3600)}min ${laptime - (Math.floor(laptime / 3600)*3600) - (Math.floor(laptime / 60)*60)}`
function format_laptime(laptime) {
if (laptime < 60) {
return `${laptime}s`;
}
if (laptime < 3600) {
return `${Math.floor(laptime / 60)}min ${
laptime - Math.floor(laptime / 60) * 60
}s`;
}
return `${Math.floor(laptime / 3600)}h ${
laptime - Math.floor(laptime / 3600) * 3600
}min ${
laptime -
Math.floor(laptime / 3600) * 3600 -
Math.floor(laptime / 60) * 60
}`;
}
function stats_general() {
axios
@ -50,6 +62,20 @@
console.log(e);
});
}
function stats_runners_by_laptime() {
axios
.request({
method: "GET",
url: $api_endpoint + "api/stats/runners/laptime",
headers: { Authorization: "Bearer " + $apikey },
})
.then(function ({ data }) {
runners_by_laptime = data;
})
.catch(function (e) {
console.log(e);
});
}
function stats_orgs() {
axios
.request({
@ -86,6 +112,7 @@
function fetch_all() {
stats_general();
stats_runners();
stats_runners_by_laptime();
stats_orgs();
stats_teams();
}