Initial commit
This commit is contained in:
16
api/jobs/lighthouse.js
Normal file
16
api/jobs/lighthouse.js
Normal file
@@ -0,0 +1,16 @@
|
||||
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) => {
|
||||
dbObjs.push(run(url))
|
||||
})
|
||||
let dbObject = calculateAverageDynamically(dbObjs)
|
||||
dbObject.analyzedPaths = [...subPaths].map((subPath) => subPath.lighthouseSubpath)
|
||||
context.db.create("lighthouse", dbObject)
|
||||
})()
|
||||
14
api/jobs/lighthouse.yml
Normal file
14
api/jobs/lighthouse.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
# Jedem Job muss ein "cron" Eintrag zugeordnet werden, der die
|
||||
# Ausführungszeitpunkte definiert.
|
||||
# Das cron-Schema ist dem üblichen Linux cron-Schema nachempfunden.
|
||||
cron: "0 0 * * 1"
|
||||
|
||||
# "type" des Jobs ist derzeit immer "javascript" mit der "file"-Referenz
|
||||
# relativ zur "config.yml".
|
||||
type: javascript
|
||||
file: jobs/lighthouse.js
|
||||
# Es können beliebige "meta"-Daten hinterlegt werden, die im Javascript
|
||||
# des Jobs über "context.job.meta" abgerufen werden können.
|
||||
|
||||
meta:
|
||||
name: Lighthouse job
|
||||
Reference in New Issue
Block a user