Compare commits

...

2 Commits

Author SHA1 Message Date
dependabot[bot]
3a69db9290 Bump command-line-usage from 7.0.3 to 7.0.4
Bumps [command-line-usage](https://github.com/75lb/command-line-usage) from 7.0.3 to 7.0.4.
- [Release notes](https://github.com/75lb/command-line-usage/releases)
- [Commits](https://github.com/75lb/command-line-usage/compare/v7.0.3...v7.0.4)

---
updated-dependencies:
- dependency-name: command-line-usage
  dependency-version: 7.0.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-02 21:54:57 +00:00
Anton Roslund
3cccf80d07 Enhance traceroute retrieval by deduplicating results based on packet_id, ensuring only the latest entry for each packet_id is returned. 2026-02-28 11:04:42 +01:00
3 changed files with 21 additions and 12 deletions

15
package-lock.json generated
View File

@@ -11,7 +11,7 @@
"dependencies": {
"@prisma/client": "^6.16.2",
"command-line-args": "^6.0.1",
"command-line-usage": "^7.0.3",
"command-line-usage": "^7.0.4",
"compression": "^1.8.1",
"cors": "^2.8.5",
"express": "^5.2.1",
@@ -69,7 +69,6 @@
"integrity": "sha512-yDBHV9kQNcr2/sUr9jghVyz9C3Y5G2zUM2H2lo+9mKv4sFgbA8s8Z9t8D1jiTkGoO/NoIfKMyKWr4s6CN23ZwQ==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@ampproject/remapping": "^2.2.0",
"@babel/code-frame": "^7.27.1",
@@ -2010,7 +2009,6 @@
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"caniuse-lite": "^1.0.30001737",
"electron-to-chromium": "^1.5.211",
@@ -2395,15 +2393,15 @@
}
},
"node_modules/command-line-usage": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-7.0.3.tgz",
"integrity": "sha512-PqMLy5+YGwhMh1wS04mVG44oqDsgyLRSKJBdOo1bnYhMKBW65gZF1dRp2OZRhiTjgUHljy99qkO7bsctLaw35Q==",
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-7.0.4.tgz",
"integrity": "sha512-85UdvzTNx/+s5CkSgBm/0hzP80RFHAa7PsfeADE5ezZF3uHz3/Tqj9gIKGT9PTtpycc3Ua64T0oVulGfKxzfqg==",
"license": "MIT",
"dependencies": {
"array-back": "^6.2.2",
"chalk-template": "^0.4.0",
"table-layout": "^4.1.0",
"typical": "^7.1.1"
"table-layout": "^4.1.1",
"typical": "^7.3.0"
},
"engines": {
"node": ">=12.20.0"
@@ -5150,7 +5148,6 @@
"devOptional": true,
"hasInstallScript": true,
"license": "Apache-2.0",
"peer": true,
"dependencies": {
"@prisma/config": "6.16.2",
"@prisma/engines": "6.16.2"

View File

@@ -11,7 +11,7 @@
"dependencies": {
"@prisma/client": "^6.16.2",
"command-line-args": "^6.0.1",
"command-line-usage": "^7.0.3",
"command-line-usage": "^7.0.4",
"compression": "^1.8.1",
"cors": "^2.8.5",
"express": "^5.2.1",

View File

@@ -547,10 +547,22 @@ app.get('/api/v1/nodes/:nodeId/traceroutes', async (req, res) => {
return;
}
// get latest traceroutes
// get latest traceroutes, deduplicated by packet_id
// We want replies where want_response is false and it will be "to" the
// requester.
const traceroutes = await prisma.$queryRaw`SELECT * FROM traceroutes WHERE want_response = false and \`to\` = ${node.node_id} and gateway_id is not null order by id desc limit ${count}`;
// Deduplicate by packet_id, keeping the latest traceroute (highest id) for each packet_id
const traceroutes = await prisma.$queryRaw`
SELECT t1.*
FROM traceroutes t1
INNER JOIN (
SELECT packet_id, MAX(id) as max_id
FROM traceroutes
WHERE want_response = false and \`to\` = ${node.node_id} and gateway_id is not null
GROUP BY packet_id
) t2 ON t1.packet_id = t2.packet_id AND t1.id = t2.max_id
ORDER BY t1.id DESC
LIMIT ${count}
`;
res.json({
traceroutes: traceroutes.map((trace) => {