// Share both sheets with ultimate-nm-2018@solskogen-cubemap.iam.gserviceaccount.com.
'score_sheet_id': '16TOrQX-oOhuxSA478iE8h3l3CD72GyEqVsChZptayxo',
+ 'score_sheet_index': 1088951921, // #gid= in the URL.
'roster_sheet_id': '1ACCrWaicEOFbeoY05SCbCvk2cHF6yAS9WwFOdNJxMIU',
'api_key': 'AIzaSyAuP9yQn8g0bSay6r_RpGtpFeIbwprH1TU',
let games = ultimateconfig['playoff_games'];
get_results('Results', function(response) {
- let updates = [];
+ let updates = [], meta_updates = [];
let game_num = 0;
for (const game of games) {
let team1 = do_replacements(game[0], replacements);
let game_name = game[4];
let game_name2 = game_name.replace("Semi", "semi");
+ let range = {
+ "sheetId": ultimateconfig['score_sheet_index'],
+ "startColumnIndex": cols[1],
+ "endColumnIndex": cols[2] + 1,
+ "startRowIndex": row - 1,
+ "endRowIndex": row
+ };
+
if (parseInt(score1) >= 0 && parseInt(score2) >= 0 && score1 != score2) {
if (parseInt(score1) > parseInt(score2)) {
replacements.unshift(["W " + game_name, team1]);
replacements.unshift(["W " + game_name2, team2]);
replacements.unshift(["L " + game_name2, team1]);
}
+ meta_updates.push({ "unmergeCells": { "range": range }});
} else if (game[5]) {
// No score yet, so write the name of the game (e.g. “L-semi 1”)
// where the score would normally be, to mark what this game is called.
// This is useful with the limited space on the tablet.
score1 = score2 = "";
updates.push({ "range": cell_score1, "values": [ [ game[4] ] ] });
+ meta_updates.push({ "mergeCells": { "range": range, "mergeType": "MERGE_ALL" }});
}
if (game[2] == 0) { // Stream field.
"valueInputOption": "USER_ENTERED",
"data": updates
};
+ let meta_json = {
+ "requests": meta_updates
+ };
possibly_update_oauth_key(function() {
post_json('https://sheets.googleapis.com/v4/spreadsheets/' + ultimateconfig['score_sheet_id'] + '/values:batchUpdate?key=' + ultimateconfig['api_key'], json, function(response) {}, current_oauth_access_token);
+ post_json('https://sheets.googleapis.com/v4/spreadsheets/' + ultimateconfig['score_sheet_id'] + ':batchUpdate?key=' + ultimateconfig['api_key'], meta_json, function(response) {}, current_oauth_access_token);
});
});
}