Browse Source

Fix profile stats to show correct fetched count

- Use total pubkeys size instead of newly fetched profile events length
- This accounts for profiles that were already cached
- Update both initial fetch and missing events fetch

The issue was that when profiles were already cached, profileEvents.length
was 0, making it look like no profiles were fetched even though they were
available from cache.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
master
limina1 9 months ago
parent
commit
a5a89434dc
  1. 11
      src/lib/stores/visualizationConfig.ts
  2. 8
      src/routes/visualize/+page.svelte

11
src/lib/stores/visualizationConfig.ts

@ -13,7 +13,7 @@ export interface VisualizationConfig {
// Graph traversal // Graph traversal
searchThroughFetched: boolean; searchThroughFetched: boolean;
// Append mode - add new events to existing graph instead of replacing // Append mode - add new events to existing graph instead of replacing
appendMode?: boolean; appendMode?: boolean;
@ -27,7 +27,7 @@ export interface VisualizationConfig {
// Default configurations for common event kinds // Default configurations for common event kinds
const DEFAULT_EVENT_CONFIGS: EventKindConfig[] = [ const DEFAULT_EVENT_CONFIGS: EventKindConfig[] = [
{ kind: 0, limit: 50 }, // Metadata events (profiles) - controls how many profiles to display { kind: 0, limit: 5 }, // Metadata events (profiles) - controls how many profiles to display
{ kind: 3, limit: 0, depth: 0 }, // Follow lists - limit 0 = don't fetch, >0 = fetch follow lists { kind: 3, limit: 0, depth: 0 }, // Follow lists - limit 0 = don't fetch, >0 = fetch follow lists
{ kind: 30040, limit: 20, nestedLevels: 1 }, { kind: 30040, limit: 20, nestedLevels: 1 },
{ kind: 30041, limit: 20 }, { kind: 30041, limit: 20 },
@ -41,8 +41,8 @@ function createVisualizationConfig() {
searchThroughFetched: true, searchThroughFetched: true,
appendMode: false, appendMode: false,
// Legacy properties // Legacy properties
allowedKinds: DEFAULT_EVENT_CONFIGS.map(ec => ec.kind), allowedKinds: DEFAULT_EVENT_CONFIGS.map((ec) => ec.kind),
disabledKinds: [30041, 30818], disabledKinds: [30041, 30818], // Kind 0 not disabled so it shows as green when profiles are fetched
allowFreeEvents: false, allowFreeEvents: false,
maxPublicationIndices: -1, maxPublicationIndices: -1,
maxEventsPerIndex: -1, maxEventsPerIndex: -1,
@ -147,7 +147,6 @@ function createVisualizationConfig() {
), ),
})), })),
// Get config for a specific kind // Get config for a specific kind
getEventConfig: (kind: number) => { getEventConfig: (kind: number) => {
let config: EventKindConfig | undefined; let config: EventKindConfig | undefined;
@ -162,7 +161,7 @@ function createVisualizationConfig() {
...config, ...config,
searchThroughFetched: !config.searchThroughFetched, searchThroughFetched: !config.searchThroughFetched,
})), })),
toggleAppendMode: () => toggleAppendMode: () =>
update((config) => ({ update((config) => ({
...config, ...config,

8
src/routes/visualize/+page.svelte

@ -21,7 +21,7 @@
import { activePubkey } from "$lib/ndk"; import { activePubkey } from "$lib/ndk";
// Configuration // Configuration
const DEBUG = false; // Set to true to enable debug logging const DEBUG = true; // Set to true to enable debug logging
const INDEX_EVENT_KIND = 30040; const INDEX_EVENT_KIND = 30040;
const CONTENT_EVENT_KINDS = [30041, 30818]; const CONTENT_EVENT_KINDS = [30041, 30818];
@ -72,6 +72,7 @@
counts[event.kind] = (counts[event.kind] || 0) + 1; counts[event.kind] = (counts[event.kind] || 0) + 1;
} }
}); });
debug("All event counts:", counts);
return counts; return counts;
}); });
@ -562,8 +563,9 @@
allEvents = [...allEvents, ...profileEvents]; allEvents = [...allEvents, ...profileEvents];
// Update profile stats for display // Update profile stats for display
// Use the total number of pubkeys, not just newly fetched profiles
profileStats = { profileStats = {
totalFetched: profileEvents.length, totalFetched: allPubkeys.size,
displayLimit: kind0Config.limit displayLimit: kind0Config.limit
}; };
} }
@ -854,7 +856,7 @@
// Update profile stats // Update profile stats
profileStats = { profileStats = {
totalFetched: profileStats.totalFetched + newProfileEvents.length, totalFetched: profileStats.totalFetched + newPubkeys.size,
displayLimit: profileStats.displayLimit displayLimit: profileStats.displayLimit
}; };
} }

Loading…
Cancel
Save