idac: added TA eval ranks to the frontend

This commit is contained in:
Dniel97 2023-11-21 23:54:02 +01:00
parent 6ea8cca1a2
commit 989cbdf748
Signed by: Dniel97
GPG Key ID: 6180B3C768FB2E08
3 changed files with 27 additions and 5 deletions

View File

@ -24,6 +24,7 @@ class RankingData:
rank: int,
name: str,
record: int,
eval_id: int,
store: str,
style_car_id: int,
update_date: str,
@ -32,6 +33,7 @@ class RankingData:
self.name: str = name
self.record: str = record
self.store: str = store
self.eval_id: int = eval_id
self.style_car_id: int = style_car_id
self.update_date: str = update_date
@ -245,6 +247,7 @@ class IDACRankingFrontend(FE_Base):
name=profile["username"],
record=rank["goal_time"],
store=arcade["name"],
eval_id=rank["eval_id"],
style_car_id=rank["style_car_id"],
update_date=str(rank["play_dt"]),
)

View File

@ -1,6 +1,26 @@
// Declare a global variable to store the JSON data
var constData;
function evaluateRank(evalId) {
if (evalId >= 1 && evalId <= 4) {
return "Rookie";
} else if (evalId >= 5 && evalId <= 8) {
return "Regular";
} else if (evalId >= 9 && evalId <= 12) {
return "Specialist";
} else if (evalId >= 13 && evalId <= 16) {
return "Expert";
} else if (evalId >= 17 && evalId <= 20) {
return "Professional";
} else if (evalId >= 21 && evalId <= 24) {
return "Master";
} else if (evalId == 25) {
return "Master+";
} else {
return "Invalid";
}
}
function formatGoalTime(milliseconds) {
// Convert the milliseconds to a time string
var minutes = Math.floor(milliseconds / 60000);

View File

@ -19,16 +19,15 @@ function loadRanking(courseId, pageNumber = 1) {
var total_pages = data.total_pages;
// Generate the HTML table
var tableHtml = '<div class="table-responsive"><table class="table table-hover"><thead><tr><th scope="col">#</th><th scope="col">Name</th><th scope="col">Car</th><th scope="col">Time</th><th scope="col" class="d-none d-lg-table-cell">Store</th><th scope="col" class="d-none d-lg-table-cell">Date</th></tr></thead><tbody>';
var tableHtml = '<div class="table-responsive"><table class="table table-hover"><thead><tr><th scope="col">#</th><th scope="col">Name/Car</th><th scope="col">Time</th><th scope="col">Eval</th><th scope="col" class="d-none d-lg-table-cell">Store/Date</th></tr></thead><tbody>';
$.each(data.ranking, function (i, ranking) {
tableHtml += '<tr class="align-middle">';
tableHtml += '<td>' + ranking.rank + '</td>';
tableHtml += '<td>' + ranking.name + '</td>';
tableHtml += '<td>' + getCarName(ranking.style_car_id) + '</td>';
tableHtml += '<td>' + ranking.name + '<br/>' + getCarName(ranking.style_car_id) + '</td>';
tableHtml += '<td>' + formatGoalTime(ranking.record) + '</td>';
tableHtml += '<td>' + evaluateRank(ranking.eval_id) + '</td>';
// Ignore the Store and Date columns on small screens
tableHtml += '<td class="d-none d-lg-table-cell">' + ranking.store + '</td>';
tableHtml += '<td class="d-none d-lg-table-cell">' + ranking.update_date + '</td>';
tableHtml += '<td class="d-none d-lg-table-cell">' + ranking.store + '<br/>' + ranking.update_date + '</td>';
tableHtml += '</tr>';
});
tableHtml += '</tbody></table></div>';