forgot to update total reqs
All checks were successful
Publish Docker Images / docker (push) Successful in 1m21s

This commit is contained in:
Lee 2023-11-16 19:23:28 +00:00
parent 35cdef1942
commit cb03d5aa42

@ -11,7 +11,7 @@ const IGNORED_PATHS = ["/favicon.ico"];
* The total requests that have been made
* TODO: move this to a metrics file
*/
let totalRequests: number | undefined;
let totalRequests: number | undefined = undefined;
const cache = new Cache({
stdTTL: 300, // 5 minutes
@ -66,14 +66,15 @@ async function logRequestToDatabase({
time,
cached,
}: InfluxLog) {
if (!totalRequests) {
if (totalRequests === undefined) {
const metrics: any = await MetricsSchema.findOne({ _id: "proxy" }).exec();
if (metrics) {
totalRequests = metrics.totalRequests;
totalRequests = metrics.totalRequests as number;
} else {
totalRequests = 0;
}
}
totalRequests++;
MetricsSchema.updateOne(
{ _id: "proxy" },
{ $set: { totalRequests: totalRequests } },