mirror of
https://github.com/ajvpot/meshexplorer.git
synced 2026-03-28 17:42:58 +01:00
stats
This commit is contained in:
@@ -5,12 +5,12 @@ export async function GET() {
|
||||
try {
|
||||
const query = `
|
||||
WITH days AS (
|
||||
SELECT arrayJoin(range(0, 30)) AS offset, toDate(subtractDays(today(), 29 - offset)) AS day
|
||||
SELECT arrayJoin(range(0, 7)) AS offset, toDate(subtractDays(today(), 6 - offset)) AS day
|
||||
),
|
||||
all_nodes AS (
|
||||
SELECT toDate(ingest_timestamp) AS day, public_key, latitude, longitude
|
||||
FROM meshcore_adverts
|
||||
WHERE ingest_timestamp >= subtractDays(today(), 30)
|
||||
WHERE ingest_timestamp >= subtractDays(today(), 7)
|
||||
),
|
||||
node_days AS (
|
||||
SELECT public_key, min(day) AS first_seen, any(latitude) AS latitude, any(longitude) AS longitude
|
||||
|
||||
@@ -27,6 +27,14 @@ export default function StatsPage() {
|
||||
return (
|
||||
<div className="max-w-2xl mx-auto py-8 px-4">
|
||||
<h1 className="text-2xl font-bold mb-6">MeshCore Network Stats</h1>
|
||||
|
||||
<div className="mb-6 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg">
|
||||
<p className="text-sm text-blue-800 dark:text-blue-200">
|
||||
<strong>Note:</strong> The "Nodes Heard Over Time" data shows activity from the past 7 days.
|
||||
This provides a focused view of recent network activity while maintaining good performance.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{loading ? (
|
||||
<div>Loading...</div>
|
||||
) : (
|
||||
|
||||
@@ -108,17 +108,17 @@ export default function ChatBox({ showAllMessagesTab = false, className = "", st
|
||||
<div className={`flex items-center justify-between ${startExpanded ? "px-4 py-2 border-b border-gray-200 dark:border-neutral-800" : ""}`} style={startExpanded ? {} : { minHeight: minimized ? '2rem' : '2rem' }}>
|
||||
<span className="font-semibold text-gray-800 dark:text-gray-100">MeshCore Chat</span>
|
||||
{!startExpanded && (
|
||||
<button
|
||||
className="p-1 rounded hover:bg-neutral-200 dark:hover:bg-neutral-800"
|
||||
onClick={() => setMinimized((m) => !m)}
|
||||
aria-label={minimized ? "Maximize MeshCore Chat" : "Minimize MeshCore Chat"}
|
||||
>
|
||||
{minimized ? (
|
||||
<PlusIcon className="h-5 w-5" />
|
||||
) : (
|
||||
<MinusIcon className="h-5 w-5" />
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
className="p-1 rounded hover:bg-neutral-200 dark:hover:bg-neutral-800"
|
||||
onClick={() => setMinimized((m) => !m)}
|
||||
aria-label={minimized ? "Maximize MeshCore Chat" : "Minimize MeshCore Chat"}
|
||||
>
|
||||
{minimized ? (
|
||||
<PlusIcon className="h-5 w-5" />
|
||||
) : (
|
||||
<MinusIcon className="h-5 w-5" />
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -36,20 +36,27 @@ export default function ChatMessageItem({ msg, showErrorRow, showChannelId }: {
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
(async () => {
|
||||
const result = await decryptMeshcoreGroupMessage({
|
||||
encrypted_message: msg.encrypted_message,
|
||||
mac: msg.mac,
|
||||
channel_hash: msg.channel_hash,
|
||||
knownKeys,
|
||||
parse: true,
|
||||
});
|
||||
if (!cancelled) {
|
||||
if (result === null) {
|
||||
try {
|
||||
const result = await decryptMeshcoreGroupMessage({
|
||||
encrypted_message: msg.encrypted_message,
|
||||
mac: msg.mac,
|
||||
channel_hash: msg.channel_hash,
|
||||
knownKeys,
|
||||
parse: true,
|
||||
});
|
||||
if (!cancelled) {
|
||||
if (result === null) {
|
||||
setParsed(null);
|
||||
setError("Could not decrypt message with any known key.");
|
||||
} else {
|
||||
setParsed(result);
|
||||
setError(null);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (!cancelled) {
|
||||
setParsed(null);
|
||||
setError("Could not decrypt message with any known key.");
|
||||
} else {
|
||||
setParsed(result);
|
||||
setError(null);
|
||||
setError(err instanceof Error ? err.message : "Decryption error occurred.");
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user