From b0d5ad76f2b5b8b8e494c9767f3e6fb582372791 Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 5 Apr 2021 13:49:01 -0700 Subject: [PATCH] Use value="" in /api/allWakaValues Oops, I missed something important about the Sheets API here! This was causing us to set `{value: undefined}` for some items, which serialized as `{}`. --- api/allWakaValues.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/allWakaValues.js b/api/allWakaValues.js index 6c158f1..2125640 100644 --- a/api/allWakaValues.js +++ b/api/allWakaValues.js @@ -90,8 +90,12 @@ async function loadWakaValuesByName() { // Reformat the rows as a map from item name to value. We offer the item data // as an object with a single field `value` for extensibility, but we omit // the spreadsheet columns that we don't use on DTI, like Notes. + // + // NOTE: The Sheets API only returns the first non-empty cells of the row. + // So, when there's no value specified, it only returns one cell. + // That's why we set `""` as the default `value`. const itemValuesByName = {}; - for (const [itemName, value] of rows) { + for (const [itemName, value = ""] of rows) { itemValuesByName[itemName] = { value }; }