Skip to content

Commit

Permalink
Added guard against emitting empty snapshot values
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenHoeffler committed Jul 19, 2024
1 parent 4af0114 commit 73c86a8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions templates/lib/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,12 @@ async function dataAndSnapshot(newElement, snapshot, snapshotKey, standardSnapsh
}
}
this.logger.info("%s items were emitted", emittedItemsCount);
snapshot.lastUpdated = lastObjectDate !== 0 ? lastObjectDate : snapshot.lastUpdated;
await self.emit("snapshot", snapshot);
this.logger.info("A new snapshot was emitted: %j", snapshot);
this.logger.info("Generating snapshot, found latest object date %s", lastObjectDate);
snapshot.lastUpdated = lastObjectDate ? lastObjectDate : snapshot.lastUpdated;
if (snapshot.lastUpdated) {
await self.emit("snapshot", snapshot);
this.logger.info("A new snapshot was emitted: %j", snapshot);
}
} else {
this.logger.info("Found one item in response data, going to emit...");
await self.emit("data", newElement);
Expand Down

0 comments on commit 73c86a8

Please sign in to comment.