diff --git a/src/services/main/paymentManager.ts b/src/services/main/paymentManager.ts index 81acf2bc..4a18a2f8 100644 --- a/src/services/main/paymentManager.ts +++ b/src/services/main/paymentManager.ts @@ -690,7 +690,7 @@ export default class { throw new Error("user is banned, cannot retrieve operations") } const [outgoingInvoices, outgoingTransactions, incomingInvoices, incomingTransactions, incomingUserToUser, outgoingUserToUser] = await Promise.all([ - this.storage.paymentStorage.GetUserInvoicePayments(userId, req.latestOutgoingInvoice, req.max_size), + this.storage.paymentStorage.GetUserInvoicePayments(userId, req.latestOutgoingInvoice, req.max_size), // this.storage.paymentStorage.GetUserTransactionPayments(userId, req.latestOutgoingTx, req.max_size), this.storage.paymentStorage.GetUserInvoicesFlaggedAsPaid(userId, req.latestIncomingInvoice, req.max_size), this.storage.paymentStorage.GetUserReceivingTransactions(userId, req.latestIncomingTx, req.max_size), diff --git a/src/services/metrics/index.ts b/src/services/metrics/index.ts index 307992f3..20abc735 100644 --- a/src/services/metrics/index.ts +++ b/src/services/metrics/index.ts @@ -70,7 +70,8 @@ export default class Handler { } async GetUsageMetrics(): Promise { - return this.storage.metricsEventStorage.LoadLatestMetrics() + const metrics = await this.storage.metricsEventStorage.LoadLatestMetrics() + return metrics } async GetErrorStats(): Promise { diff --git a/src/services/storage/metricsEventStorage.ts b/src/services/storage/metricsEventStorage.ts index 11727613..f4b26a9d 100644 --- a/src/services/storage/metricsEventStorage.ts +++ b/src/services/storage/metricsEventStorage.ts @@ -107,7 +107,7 @@ export default class { } - LoadLatestMetrics = async (): Promise => { + LoadLatestMetrics = async (limit = 100): Promise => { this.persistMetrics() const metrics: Types.UsageMetrics = { apps: {} } this.foreachMetricMethodFile((app, method, tlvFiles) => { @@ -120,6 +120,9 @@ export default class { if (!metrics.apps[app]) { metrics.apps[app] = { app_metrics: {} } } + if (decoded.length > limit) { + decoded.splice(0, decoded.length - limit) + } metrics.apps[app].app_metrics[method] = { base_64_tlvs: decoded.map(d => Buffer.from(d).toString('base64')), current_chunk: latest, diff --git a/src/services/storage/paymentStorage.ts b/src/services/storage/paymentStorage.ts index 9e7755c3..2964b085 100644 --- a/src/services/storage/paymentStorage.ts +++ b/src/services/storage/paymentStorage.ts @@ -213,7 +213,7 @@ export default class { user_id: userId }, serial_id: MoreThanOrEqual(fromIndex), - paid_at_unix: MoreThan(0), + paid_at_unix: MoreThan(-1), }, order: { paid_at_unix: 'DESC'