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