lighthouse
Some checks failed
deploy to production / lighthouse-evaluation (push) Failing after 1s
deploy to production / deploy (push) Failing after 28s

This commit is contained in:
2023-12-26 12:45:24 +00:00
parent edfca1f007
commit 8184ffecf4
20 changed files with 613 additions and 125 deletions

17
api/jobs/lighthouse.js Normal file
View File

@@ -0,0 +1,17 @@
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)
})()

View File

@@ -1,9 +0,0 @@
function requestTemperature() {
let response = context.http.fetch(
"https://api.openweathermap.org/data/2.5/weather?lat=50.98&lon=11.03&appid=21fa3d5930956682000f7a2db5f357c0"
)
let data = response.body.json()
let temperatureEntries = context.db.find("temperature")
context.db.update("temperature", temperatureEntries[0].id, { temperature: data.main.temp - 273.15 })
}
requestTemperature()