Compare commits
2 Commits
a561357fbe
...
c4646bc654
Author | SHA1 | Date | |
---|---|---|---|
c4646bc654 | |||
989d14ff95 |
@ -5,7 +5,7 @@ interface versions {
|
||||
|
||||
const version: versions = {
|
||||
api: ["/api/v2"],
|
||||
app: "2024.11.2",
|
||||
app: "2025.03.1",
|
||||
};
|
||||
|
||||
module.exports = version;
|
||||
|
@ -10,6 +10,7 @@ import { queryAggregate } from "./dbAccess.services";
|
||||
import {
|
||||
getPartialEndTiplocMatchPipeline,
|
||||
getFullTiplocMatchPipeline,
|
||||
getPartialStartTiplocMatchPipeline,
|
||||
} from "../utils/pis.utils";
|
||||
import { Document } from "mongodb";
|
||||
|
||||
|
@ -8,8 +8,6 @@ async function buildJson() {
|
||||
let json = {};
|
||||
json.count = {};
|
||||
// Async call all db queries
|
||||
const counters = db.query("meta", { target: "counters" });
|
||||
const versions = db.query("meta", { target: "versions" });
|
||||
const userCount = db.colCount("users");
|
||||
const regCount = db.colCount("registrations");
|
||||
const pisCount = db.colCount("pis");
|
||||
@ -19,12 +17,8 @@ async function buildJson() {
|
||||
|
||||
// Insert data
|
||||
json.mode = process.env.NODE_ENV;
|
||||
json.verBkend = vers.app;
|
||||
json.verApi = vers.api;
|
||||
json.host = os.hostname();
|
||||
// Await and insert async calls
|
||||
json.dat = await counters;
|
||||
json.ver = await versions;
|
||||
json.count.users = await userCount;
|
||||
json.count.reg = await regCount;
|
||||
json.count.pis = await pisCount;
|
||||
@ -42,11 +36,9 @@ async function hits() {
|
||||
|
||||
async function getVersions() {
|
||||
logger.debug("statsServices.getVersions: Fetching versions");
|
||||
const dbMan = await db.query("versions", { target: "dbmanager" });
|
||||
const mqClt = await db.query("versions", { target: "timetable-mgr" });
|
||||
const data = {
|
||||
backend: vers.app,
|
||||
"db-manager": dbMan[0]?.["version"] || "",
|
||||
"mq-client": mqClt[0]?.["version"] || "",
|
||||
};
|
||||
return data;
|
||||
@ -55,11 +47,10 @@ async function getVersions() {
|
||||
async function statistics() {
|
||||
logger.debug("statsServices.statistics: Fetching statistics");
|
||||
|
||||
const countersPromise = db.query("meta", { target: "counters" });
|
||||
const timetablePromise = db.query("meta", { type: "CifMetadata" });
|
||||
const pisPromise = db.query("meta", { target: "pis" });
|
||||
const pisPromise = db.query("meta", { target: "PisMetadata" });
|
||||
const corpusPromise = db.query("meta", { target: "corpus" });
|
||||
const reasonCodesPromise = db.query("meta", { target: "reasonCodes" });
|
||||
const stationsPromise = db.query("meta", {type: "StationsMetadata"});
|
||||
|
||||
const lengthUsersPromise = db.colCount("users");
|
||||
const lengthRegistrationsPromise = db.colCount("registrations");
|
||||
@ -70,7 +61,6 @@ async function statistics() {
|
||||
const lengthReasonCodesPromise = db.colCount("reasonCodes");
|
||||
|
||||
const [
|
||||
counters,
|
||||
timetable,
|
||||
pis,
|
||||
corpus,
|
||||
@ -81,13 +71,11 @@ async function statistics() {
|
||||
lengthStations,
|
||||
lengthPis,
|
||||
lengthTimetable,
|
||||
lengthReasonCodes,
|
||||
stations,
|
||||
] = await Promise.all([
|
||||
countersPromise,
|
||||
timetablePromise,
|
||||
pisPromise,
|
||||
corpusPromise,
|
||||
reasonCodesPromise,
|
||||
lengthUsersPromise,
|
||||
lengthRegistrationsPromise,
|
||||
lengthCorpusPromise,
|
||||
@ -95,6 +83,7 @@ async function statistics() {
|
||||
lengthPisPromise,
|
||||
lengthTimetablePromise,
|
||||
lengthReasonCodesPromise,
|
||||
stationsPromise,
|
||||
]);
|
||||
|
||||
return {
|
||||
@ -103,18 +92,9 @@ async function statistics() {
|
||||
reset: counters[0]["since"],
|
||||
updateTimes: {
|
||||
timetable: (timetable[0]["lastUpdate"]),
|
||||
pis: pis[0]["updated"],
|
||||
corpus: corpus[0]["updated"],
|
||||
reasonCodes: reasonCodes[0]["updated"],
|
||||
},
|
||||
requestCounts: {
|
||||
ldbws_api: counters[0]["ldbws"] || 0,
|
||||
lsbsvws_api: counters[0]["ldbsvws"] || 0,
|
||||
corpus_api: counters[0]["corpus_api"] || 0,
|
||||
timetable_db: counters[0]["timetable"] || 0,
|
||||
pis_db: counters[0]["pis"] || 0,
|
||||
corpus_db: counters[0]["corpus"] || 0,
|
||||
stations_db: counters[0]["stations"] || 0,
|
||||
pis: pis[0]["lastUpdate"],
|
||||
corpus: corpus[0]["updated_time"],
|
||||
stations: stations[0]["lastUpdate"],
|
||||
},
|
||||
dbLengths: {
|
||||
users: lengthUsers,
|
||||
@ -123,7 +103,6 @@ async function statistics() {
|
||||
stations: lengthStations,
|
||||
pis: lengthPis,
|
||||
timetable: lengthTimetable,
|
||||
reasonCodes: lengthReasonCodes,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user