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

This commit is contained in:
2024-07-11 18:20:59 +00:00
parent 81724cb20d
commit ab3f5cfbbf
8 changed files with 421 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ const { apiClientBaseURL } = require("../config-client")
/**
* convert object to string
* @param {any} obj object
* @returns {Object | undefined}
*/
function obj2str(obj) {
if (Array.isArray(obj)) {

View File

@@ -9,6 +9,7 @@ function log(str) {
/**
* convert object to string
* @param {any} obj object
* @returns {Object | undefined}
*/
function obj2str(obj) {
if (Array.isArray(obj)) {
@@ -46,16 +47,22 @@ function clearSSRCache() {
var info = context.db.deleteMany("ssr", {})
context.response.header("X-SSR-Cleared", info.removed)
}
/**
* @param {{ [x: string]: any; }[]} dbObjs
*/
function calculateAverageDynamically(dbObjs) {
const sumObj = {}
let count = 0
dbObjs.forEach((obj) => {
dbObjs.forEach((/** @type {{ [x: string]: any; }} */ obj) => {
accumulate(obj, sumObj)
count++
})
/**
* @param {{ [x: string]: any; }} sourceObj
* @param {{ [x: string]: any; }} targetObj
*/
function accumulate(sourceObj, targetObj) {
for (const key in sourceObj) {
if (typeof sourceObj[key] === "number") {
@@ -67,6 +74,9 @@ function calculateAverageDynamically(dbObjs) {
}
}
/**
* @param {{ [x: string]: any; }} targetObj
*/
function average(targetObj) {
for (const key in targetObj) {
if (typeof targetObj[key] === "number") {
@@ -81,6 +91,9 @@ function calculateAverageDynamically(dbObjs) {
return sumObj
}
/**
* @param {string} url
*/
function run(url) {
const response = context.http
.fetch(url, {
@@ -133,6 +146,7 @@ function setUpQuery(subPath = "/") {
let query = `${api}?`
for (let key in parameters) {
// @ts-ignore
query += `${key}=${parameters[key]}&`
}
query += params // Append other parameters without URL encoding