Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@

**Learning:** Using `on:keyup` for search input debouncing triggers unnecessary API calls on navigation keys (arrows, home, end) and misses changes from paste/cut. Svelte's reactive statements `$: debounce(value)` provide a robust, declarative way to trigger debouncing only when the value actually changes.
**Action:** Replace `on:keyup` handlers with reactive statements for input debouncing to improve performance and correctness.

## 2024-10-25 - Avoid waterfall in metaNamesSdk
**Learning:** Sequential await operations involving `metaNamesSdk.domainRepository.count()`, `getOwners()`, and `getRecentDomains()` cause a waterfall latency, especially when communicating with the blockchain context or external services.
**Action:** Since these fetches are completely independent of each other, group them up and run them concurrently using `Promise.all` to save on round-trips latency and reduce execution time.
12 changes: 7 additions & 5 deletions src/lib/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ export interface DomainStats {
}

export const getStats = async (): Promise<DomainStats> => {
const domainCount = await metaNamesSdk.domainRepository.count();
const ownerCount = await metaNamesSdk.domainRepository
.getOwners()
.then((owners) => owners.length);
const recentDomains = await getRecentDomains();
// ⚑ Bolt: Execute independent async operations concurrently using Promise.all
// to avoid waterfall latency and significantly reduce total execution time.
const [domainCount, ownerCount, recentDomains] = await Promise.all([
metaNamesSdk.domainRepository.count(),
metaNamesSdk.domainRepository.getOwners().then((owners) => owners.length),
getRecentDomains()
]);

return {
domainCount,
Expand Down