]> git.sesse.net Git - ultimatescore/commitdiff
Also write the points total to the seeding.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 16 Mar 2018 08:35:45 +0000 (09:35 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 16 Mar 2018 08:35:45 +0000 (09:35 +0100)
update_sheets.js

index 2a2461b00cc258fe400c78e96d539006659b9c40..020742a4fd62fc62bae813cd101503aeff01f7b2 100644 (file)
@@ -68,26 +68,31 @@ function possibly_update_oauth_key(cb) {
 function publish_group_rank(group_name)
 {
        get_group(group_name, function(response, group_name) {
+               let updates = [];
+               let cols = ["Results!B", "Results!C", "Results!D"];
+               if (group_name === 'Group B') {
+                       cols = ["Results!F", "Results!G", "Results!H"];
+               }
+
                let teams = parse_teams_from_spreadsheet(response);
                let games = parse_games_from_spreadsheet(response, group_name, false);
                apply_games_to_teams(games, teams);
-               let tiebreakers = [];
-               teams = rank(games, teams, 1, tiebreakers);
 
-               let cols = ["Results!B", "Results!C", "Results!D"];
-               if (group_name === 'Group B') {
-                       cols = ["Results!F", "Results!G", "Results!H"];
+               // Write the points total to the unsorted columns.
+               for (let i = 0; i < teams.length; ++i) {
+                       updates.push({ "range": cols[2] + (4 + i), "values": [ [ teams[i].pts ] ] });
                }
 
-               let updates = [];
+               let tiebreakers = [];
+               teams = rank(games, teams, 1, tiebreakers);
+
+               // Write the ranking table, from scratch.
                for (let i = 0; i < teams.length; ++i) {
                        updates.push({ "range": cols[0] + (10 + i), "values": [ [ teams[i].rank ] ] });
                        updates.push({ "range": cols[1] + (10 + i), "values": [ [ teams[i].shortname ] ] });
                        updates.push({ "range": cols[2] + (10 + i), "values": [ [ teams[i].pts ] ] });
                }
 
-               // TODO: update the points total at the seeding?
-
                let tb_str = "";
                if (tiebreakers.length != 0) {
                        tb_str = tiebreakers.join("\n");