wm-AllKids-tibi2023/api/hooks/lighthouse/post_create.js

17 lines
579 B
JavaScript
Raw Normal View History

2023-12-26 13:45:24 +01:00
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) => {
2024-07-11 20:20:59 +02:00
console.log("URL:", url)
2023-12-26 13:45:24 +01:00
dbObjs.push(run(url))
})
let dbObject = calculateAverageDynamically(dbObjs)
dbObject.analyzedPaths = [...subPaths].map((subPath) => subPath.lighthouseSubpath)
return { data: dbObject }
})()