add channel parameter to most-active-nodes.
This commit is contained in:
parent
3cf7c9479e
commit
57d962ae89
1 changed files with 6 additions and 2 deletions
|
|
@ -91,7 +91,9 @@ router.get('/messages-per-hour', async (req, res) => {
|
||||||
|
|
||||||
router.get('/most-active-nodes', async (req, res) => {
|
router.get('/most-active-nodes', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const result = await prisma.$queryRaw`
|
const channelId = req.query.channel_id;
|
||||||
|
const result = await prisma.$queryRaw(
|
||||||
|
Prisma.sql`
|
||||||
SELECT n.long_name, COUNT(*) AS count
|
SELECT n.long_name, COUNT(*) AS count
|
||||||
FROM (
|
FROM (
|
||||||
SELECT DISTINCT \`from\`, packet_id
|
SELECT DISTINCT \`from\`, packet_id
|
||||||
|
|
@ -101,12 +103,14 @@ router.get('/most-active-nodes', async (req, res) => {
|
||||||
AND packet_id IS NOT NULL
|
AND packet_id IS NOT NULL
|
||||||
AND portnum != 73
|
AND portnum != 73
|
||||||
AND \`to\` != 1
|
AND \`to\` != 1
|
||||||
|
${channelId ? Prisma.sql`AND channel_id = ${channelId}` : Prisma.sql``}
|
||||||
) AS unique_packets
|
) AS unique_packets
|
||||||
JOIN nodes n ON unique_packets.from = n.node_id
|
JOIN nodes n ON unique_packets.from = n.node_id
|
||||||
GROUP BY n.long_name
|
GROUP BY n.long_name
|
||||||
ORDER BY count DESC
|
ORDER BY count DESC
|
||||||
LIMIT 25;
|
LIMIT 25;
|
||||||
`;
|
`
|
||||||
|
);
|
||||||
|
|
||||||
res.set('Cache-Control', 'public, max-age=600'); // 10 min cache
|
res.set('Cache-Control', 'public, max-age=600'); // 10 min cache
|
||||||
res.json(result);
|
res.json(result);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue