diff --git a/daysnap.js b/daysnap.js index cdb16a3..8717c39 100644 --- a/daysnap.js +++ b/daysnap.js @@ -90,7 +90,13 @@ function get(key) { if (key > today) return null; } const d = compute(key); - if (d && key !== today) save(d); + if (!d) return null; + if (key !== today) { + // a past day with nothing in it is either before the contract or beyond the index's reach: + // say not found rather than serving an empty page, and never write a file for it + if (d.totals.payouts + d.totals.joins === 0) return null; + save(d); + } return d; } function save(d) { try { fs.writeFileSync(dayFile(d.key), JSON.stringify(d)); } catch (e) {} }