Skip to content

Commit

Permalink
Fix plotting of measurements with long comments
Browse files Browse the repository at this point in the history
Long comments were clogging up the JSON cache (Firestore has a limit
of 1 MB per document). Cropping the comments down to 500 characters
should push this problem many years into the future.
  • Loading branch information
simenheg committed Nov 7, 2024
1 parent 9cd4ddf commit 868771e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ All notable changes to this project will be documented in this file. The format

- Dropped support for Node.js 18 and below.

### Fixed

- Fixed plotting of measurements with very long comments.

### Security

- Updated dependencies.
Expand Down
6 changes: 5 additions & 1 deletion functions/kpi/progress/handleKpiProgress.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export default async function updateKpiProgress(change, { params }) {
progressCollection.map((p) => [
p.timestamp.toDate().toISOString().slice(0, 10),
parseFloat(p.value.toFixed(4)),
p.comment || '',
/*
* Crop the comment to avoid bloating the cache as Firestore has a limit
* of 1 MB per document.
*/
p.comment ? p.comment.substring(0, 500) : '',
])
);

Expand Down

0 comments on commit 868771e

Please sign in to comment.