add analyze links to PathVisualization

This commit is contained in:
ajvpot
2025-09-23 03:13:10 +02:00
parent 580c315a20
commit 665b91f1fa
5 changed files with 39 additions and 5 deletions

View File

@@ -17,6 +17,7 @@ interface AdvertDetailsProps {
is_chat_node: number;
is_room_server: number;
has_location: number;
packet_hash: string;
};
initiatingNodeKey?: string;
}
@@ -97,6 +98,7 @@ export default function AdvertDetails({ advert, initiatingNodeKey }: AdvertDetai
}))}
className="text-sm"
initiatingNodeKey={initiatingNodeKey}
packetHash={advert.packet_hash}
/>
</div>

View File

@@ -160,6 +160,7 @@ function ChatMessageItem({ msg, showErrorRow }: { msg: ChatMessage, showErrorRow
paths={pathData}
title={`Heard ${pathData.length} repeat${pathData.length !== 1 ? 's' : ''}`}
className="text-xs"
packetHash={msg.message_id}
/>
</div>
);
@@ -180,6 +181,7 @@ function ChatMessageItem({ msg, showErrorRow }: { msg: ChatMessage, showErrorRow
paths={pathData}
title={`Heard ${pathData.length} repeat${pathData.length !== 1 ? 's' : ''}`}
className="text-xs"
packetHash={msg.message_id}
/>
</div>
);
@@ -200,6 +202,7 @@ function ChatMessageItem({ msg, showErrorRow }: { msg: ChatMessage, showErrorRow
paths={pathData}
title={`Heard ${pathData.length} repeat${pathData.length !== 1 ? 's' : ''}`}
className="text-xs"
packetHash={msg.message_id}
/>
</div>
);

View File

@@ -5,6 +5,7 @@ import { createPortal } from "react-dom";
import Link from "next/link";
import Tree from 'react-d3-tree';
import { ArrowsPointingOutIcon, ArrowsPointingInIcon } from "@heroicons/react/24/outline";
import { ExternalLink } from "lucide-react";
import PathDisplay from "./PathDisplay";
import { useMeshcoreSearches } from "@/hooks/useMeshcoreSearch";
import type { MeshcoreSearchResult } from "@/hooks/useMeshcoreSearch";
@@ -33,6 +34,7 @@ interface PathVisualizationProps {
className?: string;
showDropdown?: boolean;
initiatingNodeKey?: string;
packetHash?: string;
}
@@ -41,7 +43,8 @@ export default function PathVisualization({
title = "Paths",
className = "",
showDropdown = true,
initiatingNodeKey
initiatingNodeKey,
packetHash
}: PathVisualizationProps) {
const [expanded, setExpanded] = useState(false);
const [showGraph, setShowGraph] = useState(false);
@@ -340,6 +343,17 @@ export default function PathVisualization({
<span>{showGraph ? 'Hide Graph' : 'Show Graph'}</span>
</button>
)}
{packetHash && (
<a
href={`https://analyzer.letsme.sh/packets?packet_hash=${packetHash}`}
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-1 hover:text-gray-800 dark:hover:text-gray-100 transition-colors text-sm"
>
<span>Analyze</span>
<ExternalLink className="w-3 h-3" />
</a>
)}
</div>
<PathsList />
{showGraph && <GraphView />}
@@ -373,6 +387,18 @@ export default function PathVisualization({
<span>{showGraph ? 'Hide Graph' : 'Show Graph'}</span>
</button>
)}
{packetHash && (
<a
href={`https://analyzer.letsme.sh/packets?packet_hash=${packetHash}`}
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-1 hover:text-gray-800 dark:hover:text-gray-100 transition-colors"
>
<span>Analyze</span>
<ExternalLink className="w-3 h-3" />
</a>
)}
</div>
{expanded && pathsCount > 0 && (

View File

@@ -29,6 +29,7 @@ export interface Advert {
is_chat_node: number;
is_room_server: number;
has_location: number;
packet_hash: string;
}
export interface LocationHistory {

View File

@@ -157,7 +157,7 @@ export async function getMeshcoreNodeInfo(publicKey: string, limit: number = 50)
// Get recent adverts grouped by adv_timestamp with origin_path_pubkey tuples
const advertsQuery = `
SELECT
adv_timestamp,
argMax(adv_timestamp, ingest_timestamp) as adv_timestamp,
groupArray((origin, path, origin_pubkey)) as origin_path_pubkey_tuples,
count() as advert_count,
min(ingest_timestamp) as earliest_timestamp,
@@ -167,7 +167,8 @@ export async function getMeshcoreNodeInfo(publicKey: string, limit: number = 50)
argMax(is_repeater, ingest_timestamp) as is_repeater,
argMax(is_chat_node, ingest_timestamp) as is_chat_node,
argMax(is_room_server, ingest_timestamp) as is_room_server,
argMax(has_location, ingest_timestamp) as has_location
argMax(has_location, ingest_timestamp) as has_location,
packet_hash
FROM (
SELECT
ingest_timestamp,
@@ -182,12 +183,13 @@ export async function getMeshcoreNodeInfo(publicKey: string, limit: number = 50)
is_room_server,
has_location,
hex(origin_pubkey) as origin_pubkey,
origin
origin,
packet_hash
FROM meshcore_adverts
WHERE public_key = {publicKey:String}
ORDER BY ingest_timestamp DESC
)
GROUP BY adv_timestamp
GROUP BY packet_hash
ORDER BY max(ingest_timestamp) DESC
LIMIT {limit:UInt32}
`;