wm-AllKids-tibi2023/api/jobs/lighthouse.js
robin 8184ffecf4
Some checks failed
deploy to production / lighthouse-evaluation (push) Failing after 1s
deploy to production / deploy (push) Failing after 28s
lighthouse
2023-12-26 12:45:24 +00:00

18 lines
643 B
JavaScript

var { setUpQuery, calculateAverageDynamically, run } = require("../hooks/lib/utils")
;(function () {
console.log("Running lighthouse job")
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) => {
console.log("URL:", url)
dbObjs.push(run(url))
})
let dbObject = calculateAverageDynamically(dbObjs)
dbObject.analyzedPaths = [...subPaths].map((subPath) => subPath.lighthouseSubpath)
context.db.create("lighthouse", dbObject)
})()