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 `{}`.
This commit is contained in:
Emi Matchu 2021-04-05 13:49:01 -07:00
parent d918162a2f
commit b0d5ad76f2

View file

@ -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 };
}