backend & types

This commit is contained in:
2024-01-27 18:58:35 +00:00
parent 91bfa0864d
commit 0b4a474180
219 changed files with 5211 additions and 12325 deletions

View File

View File

@@ -1,14 +0,0 @@
# Jedem Job muss ein "cron" Eintrag zugeordnet werden, der die
# Ausführungszeitpunkte definiert.
# Das cron-Schema ist dem üblichen Linux cron-Schema nachempfunden.
cron: "*/10 * * * *"
# "type" des Jobs ist derzeit immer "javascript" mit der "file"-Referenz
# relativ zur "config.yml".
type: javascript
file: jobs/demojob.js
# Es können beliebige "meta"-Daten hinterlegt werden, die im Javascript
# des Jobs über "context.job.meta" abgerufen werden können.
meta:
name: Demo Job

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)
})()