mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 16:06:08 +02:00
fix: relay analytics chart filtering by relay
This commit is contained in:
@@ -120,7 +120,7 @@ async function updateCharts() {
|
||||
const hostFilterEl = document.getElementById('hostFilter');
|
||||
const termEl = document.getElementById('term');
|
||||
console.log(hostFilterEl.value, termEl.value);
|
||||
const data = await get(`/api${ajaxify.data.url}?host=${hostFilterEl.value}&term=${termEl.value}`);
|
||||
const data = await get(`/api${ajaxify.data.url}?relay=${hostFilterEl.value}&term=${termEl.value}`);
|
||||
|
||||
chart.data.labels = labels.get(termEl.value || 'hourly');
|
||||
chart.data.datasets[0].data = data.data.in;
|
||||
|
||||
@@ -62,11 +62,9 @@ Analytics.receiptError = async (body, error) => {
|
||||
Analytics.relays = {};
|
||||
|
||||
Analytics.relays.in = (relay) => {
|
||||
const { hostname } = new URL(relay);
|
||||
analytics.increment(['ap.relayIn', `ap.relayIn:byHost:${hostname}`]);
|
||||
analytics.increment(['ap.relayIn', `ap.relayIn:byRelay:${relay}`]);
|
||||
};
|
||||
|
||||
Analytics.relays.out = (relay) => {
|
||||
const { hostname } = new URL(relay);
|
||||
analytics.increment(['ap.relayOut', `ap.relayOut:byHost:${hostname}`]);
|
||||
analytics.increment(['ap.relayOut', `ap.relayOut:byRelay:${relay}`]);
|
||||
};
|
||||
@@ -34,9 +34,9 @@ federationController.relays = async function (req, res) {
|
||||
const relays = await activitypub.relays.list();
|
||||
const urls = relays.map(({ url }) => url);
|
||||
|
||||
let { host, term } = req.query;
|
||||
if (!urls.includes(host)) {
|
||||
host = undefined;
|
||||
let { relay, term } = req.query;
|
||||
if (!urls.includes(relay)) {
|
||||
relay = undefined;
|
||||
}
|
||||
let method = 'getHourlyStatsForSet';
|
||||
let count = 24;
|
||||
@@ -44,8 +44,8 @@ federationController.relays = async function (req, res) {
|
||||
method = 'getDailyStatsForSet';
|
||||
count = 30;
|
||||
}
|
||||
const inSet = host ? `ap.relayIn:byHost:${host}` : 'ap.relayIn';
|
||||
const outSet = host ? `ap.relayOut:byHost:${host}` : 'ap.relayOut';
|
||||
const inSet = relay ? `ap.relayIn:byRelay:${relay}` : 'ap.relayIn';
|
||||
const outSet = relay ? `ap.relayOut:byRelay:${relay}` : 'ap.relayOut';
|
||||
const incoming = await analytics[method](inSet, Date.now(), count);
|
||||
const out = await analytics[method](outSet, Date.now(), count);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user