wm-AllKids-tibi2023/api/hooks/lighthouse/post_create.js
robin db2a168f4b
Some checks failed
deploy to production / lighthouse-evaluation (push) Failing after 0s
deploy to production / deploy (push) Successful in 1m15s
fix
2023-12-26 14:04:50 +00:00

16 lines
546 B
JavaScript

var { setUpQuery, calculateAverageDynamically, run } = require("../lib/utils")
;(function () {
let subPaths = context.db.find("lighthouseSubpath")
let urls = []
for (let i = 0; i < subPaths.length; i++) {
urls.push(setUpQuery(subPaths[i].lighthouseSubpath))
}
let dbObjs = []
urls.forEach((url) => {
dbObjs.push(run(url))
})
let dbObject = calculateAverageDynamically(dbObjs)
dbObject.analyzedPaths = [...subPaths].map((subPath) => subPath.lighthouseSubpath)
return { data: dbObject }
})()