From 36bb3a78eb1c9ad266d2b4bd123acf5ce7134bb6 Mon Sep 17 00:00:00 2001 From: norohind <60548839+norohind@users.noreply.github.com> Date: Tue, 30 Nov 2021 16:20:51 +0300 Subject: [PATCH] fix /diff when squad starts to exists in leaderboard --- model/postgres_sql_requests.py | 10 +++++----- static/js/json2htmltable.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/model/postgres_sql_requests.py b/model/postgres_sql_requests.py index 87909af..4ee43ba 100644 --- a/model/postgres_sql_requests.py +++ b/model/postgres_sql_requests.py @@ -57,16 +57,16 @@ limit %(limit)s;""" select_diff_by_action_id = """select new_stats.name as "SquadronName", new_stats.tag, - new_stats.score as "TotalExperience", - old_stats.score as "TotalExperienceOld", - new_stats.score - old_stats.score as "TotalExperienceDiff", + coalesce(new_stats.score, 0) as "TotalExperience", + coalesce(old_stats.score, 0) as "TotalExperienceOld", + coalesce(new_stats.score, 0) - coalesce(old_stats.score, 0) as "TotalExperienceDiff", new_stats.leaderboard_type as "LeaderBoardType", new_stats.platform as "Platform" from ( select * from squads_stats_states where action_id = %(action_id)s) new_stats -inner join +full join ( select * from squads_stats_states @@ -83,5 +83,5 @@ inner join order by squads_stats_states.action_id desc limit 1)) old_stats on new_stats.squadron_id = old_stats.squadron_id -where new_stats.score - old_stats.score > 0 +where coalesce(new_stats.score, 0) - coalesce(old_stats.score, 0) <> 0 order by new_stats.score - old_stats.score desc;""" \ No newline at end of file diff --git a/static/js/json2htmltable.js b/static/js/json2htmltable.js index e41b176..4fb0763 100644 --- a/static/js/json2htmltable.js +++ b/static/js/json2htmltable.js @@ -13,7 +13,7 @@ function buildHtmlTable(arr) { for (var j = 0, maxj = columns.length; j < maxj; ++j) { var td = _td_.cloneNode(false); cellValue = arr[i][columns[j]]; - td.appendChild(document.createTextNode(arr[i][columns[j]] || '')); + td.appendChild(document.createTextNode(arr[i][columns[j]])); tr.appendChild(td); } table.appendChild(tr);