Fix statistics:
- Remove unused values - Add additional fetch for Stations data Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
989d14ff95
commit
c4646bc654
@ -8,8 +8,6 @@ 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");
|
||||||
@ -19,12 +17,8 @@ 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;
|
||||||
@ -42,11 +36,9 @@ 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;
|
||||||
@ -55,11 +47,10 @@ 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: "pis" });
|
const pisPromise = db.query("meta", { target: "PisMetadata" });
|
||||||
const corpusPromise = db.query("meta", { target: "corpus" });
|
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 lengthUsersPromise = db.colCount("users");
|
||||||
const lengthRegistrationsPromise = db.colCount("registrations");
|
const lengthRegistrationsPromise = db.colCount("registrations");
|
||||||
@ -70,7 +61,6 @@ async function statistics() {
|
|||||||
const lengthReasonCodesPromise = db.colCount("reasonCodes");
|
const lengthReasonCodesPromise = db.colCount("reasonCodes");
|
||||||
|
|
||||||
const [
|
const [
|
||||||
counters,
|
|
||||||
timetable,
|
timetable,
|
||||||
pis,
|
pis,
|
||||||
corpus,
|
corpus,
|
||||||
@ -81,13 +71,11 @@ async function statistics() {
|
|||||||
lengthStations,
|
lengthStations,
|
||||||
lengthPis,
|
lengthPis,
|
||||||
lengthTimetable,
|
lengthTimetable,
|
||||||
lengthReasonCodes,
|
stations,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
countersPromise,
|
|
||||||
timetablePromise,
|
timetablePromise,
|
||||||
pisPromise,
|
pisPromise,
|
||||||
corpusPromise,
|
corpusPromise,
|
||||||
reasonCodesPromise,
|
|
||||||
lengthUsersPromise,
|
lengthUsersPromise,
|
||||||
lengthRegistrationsPromise,
|
lengthRegistrationsPromise,
|
||||||
lengthCorpusPromise,
|
lengthCorpusPromise,
|
||||||
@ -95,6 +83,7 @@ async function statistics() {
|
|||||||
lengthPisPromise,
|
lengthPisPromise,
|
||||||
lengthTimetablePromise,
|
lengthTimetablePromise,
|
||||||
lengthReasonCodesPromise,
|
lengthReasonCodesPromise,
|
||||||
|
stationsPromise,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -103,18 +92,9 @@ async function statistics() {
|
|||||||
reset: counters[0]["since"],
|
reset: counters[0]["since"],
|
||||||
updateTimes: {
|
updateTimes: {
|
||||||
timetable: (timetable[0]["lastUpdate"]),
|
timetable: (timetable[0]["lastUpdate"]),
|
||||||
pis: pis[0]["updated"],
|
pis: pis[0]["lastUpdate"],
|
||||||
corpus: corpus[0]["updated"],
|
corpus: corpus[0]["updated_time"],
|
||||||
reasonCodes: reasonCodes[0]["updated"],
|
stations: stations[0]["lastUpdate"],
|
||||||
},
|
|
||||||
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,
|
||||||
@ -123,7 +103,6 @@ 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