Skip to content

Commit

Permalink
Merge pull request #13 from wp-media/fix/save-data-conditionally
Browse files Browse the repository at this point in the history
Only save data if one beacon feature ran
  • Loading branch information
MathieuLamiot authored Aug 14, 2024
2 parents 74760fb + 17e500a commit 821dd18
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
9 changes: 8 additions & 1 deletion dist/wpr-beacon.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,21 @@
this._handleInfiniteLoop();
}, 1e4);
const isGeneratedBefore = await this._getGeneratedBefore();
let shouldSaveResultsIntoDB = false;
const shouldGenerateLcp = this.config.status.atf && isGeneratedBefore === false;
if (shouldGenerateLcp) {
this.lcpBeacon = new BeaconLcp_default(this.config, this.logger);
await this.lcpBeacon.run();
shouldSaveResultsIntoDB = true;
} else {
this.logger.logMessage("Not running BeaconLcp because data is already available");
}
this._saveFinalResultIntoDB();
if (shouldSaveResultsIntoDB) {
this._saveFinalResultIntoDB();
} else {
this.logger.logMessage("Not saving results into DB as no beacon features ran.");
this._finalize();
}
}
async _isValidPreconditions() {
const threshold = {
Expand Down
2 changes: 1 addition & 1 deletion dist/wpr-beacon.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 821dd18

Please sign in to comment.