Skip to content

Commit 7c248d0

Browse files
committed
include downloads from unstoppableswap-gui repo
1 parent 27a9d73 commit 7c248d0

File tree

2 files changed

+73
-36
lines changed

2 files changed

+73
-36
lines changed

builder/statistics.ts

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import * as vl from 'vega-lite';
66
// API Configuration
77
const LIST_API_URL = 'https://api.unstoppableswap.net/api/list';
88
const LIQUIDITY_DAILY_API_URL = 'https://api.unstoppableswap.net/api/liquidity-daily';
9-
const GITHUB_API_BASE = 'https://api.github.com/repos/eigenwallet/core';
10-
const GITHUB_RELEASES_API = `${GITHUB_API_BASE}/releases`;
9+
const GITHUB_CORE_API_BASE = 'https://api.github.com/repos/eigenwallet/core';
10+
const GITHUB_GUI_API_BASE = 'https://api.github.com/repos/eigenwallet/unstoppableswap-gui';
11+
const GITHUB_CORE_RELEASES_API = `${GITHUB_CORE_API_BASE}/releases`;
12+
const GITHUB_GUI_RELEASES_API = `${GITHUB_GUI_API_BASE}/releases`;
1113

1214
// Cache Configuration
1315
const CACHE_FILE_NAME = '.stats-cache.json';
@@ -134,29 +136,52 @@ async function fetchApiData(): Promise<{ peers: PeerData[]; liquidity: Liquidity
134136
}
135137

136138
/**
137-
* Fetch total downloads from GitHub releases
139+
* Fetch total downloads from GitHub releases (both core and GUI repositories)
138140
*/
139141
async function fetchTotalDownloads(): Promise<number> {
140142
try {
141-
console.log('Fetching GitHub download statistics...');
142-
const response = await fetch(GITHUB_RELEASES_API);
143+
console.log('Fetching GitHub download statistics from both repositories...');
143144

144-
if (!response.ok) {
145-
console.warn(`GitHub API responded with status: ${response.status}`);
146-
return 0;
147-
}
148-
149-
const releases: any[] = await response.json();
145+
// Fetch from both repositories in parallel
146+
const [coreResponse, guiResponse] = await Promise.all([
147+
fetch(GITHUB_CORE_RELEASES_API),
148+
fetch(GITHUB_GUI_RELEASES_API)
149+
]);
150150

151151
let totalDownloads = 0;
152-
for (const release of releases) {
153-
if (release.assets && Array.isArray(release.assets)) {
154-
for (const asset of release.assets) {
155-
if (asset.download_count) {
156-
totalDownloads += asset.download_count;
152+
153+
// Process core repository downloads
154+
if (coreResponse.ok) {
155+
const coreReleases: any[] = await coreResponse.json();
156+
for (const release of coreReleases) {
157+
if (release.assets && Array.isArray(release.assets)) {
158+
for (const asset of release.assets) {
159+
if (asset.download_count) {
160+
totalDownloads += asset.download_count;
161+
}
162+
}
163+
}
164+
}
165+
console.log('Fetched core repository download statistics');
166+
} else {
167+
console.warn(`Core GitHub API responded with status: ${coreResponse.status}`);
168+
}
169+
170+
// Process GUI repository downloads
171+
if (guiResponse.ok) {
172+
const guiReleases: any[] = await guiResponse.json();
173+
for (const release of guiReleases) {
174+
if (release.assets && Array.isArray(release.assets)) {
175+
for (const asset of release.assets) {
176+
if (asset.download_count) {
177+
totalDownloads += asset.download_count;
178+
}
157179
}
158180
}
159181
}
182+
console.log('Fetched GUI repository download statistics');
183+
} else {
184+
console.warn(`GUI GitHub API responded with status: ${guiResponse.status}`);
160185
}
161186

162187
return totalDownloads;
@@ -341,9 +366,11 @@ export async function generateStatsData(): Promise<StatsData> {
341366
if (isDevelopmentMode()) {
342367
const cachedData = loadCache();
343368
if (cachedData) {
369+
console.log(`Using cached downloads: ${cachedData.totalDownloads}`);
344370
apiData = cachedData;
345371
} else {
346372
apiData = await fetchApiData();
373+
console.log(`Caching fresh downloads: ${apiData.totalDownloads}`);
347374
saveCache(apiData);
348375
}
349376
} else {

content/statistics.md

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
## Network Statistics
22

3-
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 2rem; margin: 2rem 0;">
4-
<div style="text-align: center; padding: 1.5rem; border: 1px solid #333; border-radius: 8px;">
5-
<div style="font-size: 2rem; font-weight: bold; color: #ff6b35;">{{TOTAL_LIQUIDITY}}</div>
6-
<div style="font-size: 0.9rem; color: #666; margin-top: 0.5rem;">Total Liquidity (BTC)</div>
7-
</div>
8-
9-
<div style="text-align: center; padding: 1.5rem; border: 1px solid #333; border-radius: 8px;">
10-
<div style="font-size: 2rem; font-weight: bold; color: #ff6b35;">{{MAX_SWAP}}</div>
11-
<div style="font-size: 0.9rem; color: #666; margin-top: 0.5rem;">Maximum Swap (BTC)</div>
12-
</div>
13-
14-
<div style="text-align: center; padding: 1.5rem; border: 1px solid #333; border-radius: 8px;">
15-
<div style="font-size: 2rem; font-weight: bold; color: #ff6b35;">{{MIN_SWAP}}</div>
16-
<div style="font-size: 0.9rem; color: #666; margin-top: 0.5rem;">Minimum Swap (BTC)</div>
17-
</div>
18-
19-
<div style="text-align: center; padding: 1.5rem; border: 1px solid #333; border-radius: 8px;">
20-
<div style="font-size: 2rem; font-weight: bold; color: #ff6b35;">{{TOTAL_DOWNLOADS}}</div>
21-
<div style="font-size: 0.9rem; color: #666; margin-top: 0.5rem;">Total Downloads</div>
22-
</div>
3+
<!-- Hero Metric -->
4+
<div style="text-align: center; margin: 2rem 0 3rem 0; padding: 2rem; border: 2px solid #ff6b35; border-radius: 8px; background: #fafafa;">
5+
<div style="font-size: 3.5rem; font-weight: bold; margin-bottom: 0.5rem; color: #ff6b35;">{{TOTAL_LIQUIDITY}} BTC</div>
6+
<div style="font-size: 1.2rem; color: #666;">Total Network Liquidity</div>
7+
</div>
8+
9+
<!-- Supporting Metrics Table -->
10+
<div style="margin: 2rem 0;">
11+
<table style="width: 100%; border-collapse: collapse; margin: 0; background: white;">
12+
<thead>
13+
<tr style="background: #f8f9fa;">
14+
<th style="padding: 1rem; text-align: left; border-bottom: 2px solid #dee2e6; font-weight: 600;">Metric</th>
15+
<th style="padding: 1rem; text-align: right; border-bottom: 2px solid #dee2e6; font-weight: 600;">Value</th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
<tr style="border-bottom: 1px solid #dee2e6;">
20+
<td style="padding: 1rem; color: #495057;">Maximum Swap Amount</td>
21+
<td style="padding: 1rem; text-align: right; font-weight: 600; color: #ff6b35;">{{MAX_SWAP}} BTC</td>
22+
</tr>
23+
<tr style="border-bottom: 1px solid #dee2e6;">
24+
<td style="padding: 1rem; color: #495057;">Minimum Swap Amount</td>
25+
<td style="padding: 1rem; text-align: right; font-weight: 600; color: #ff6b35;">{{MIN_SWAP}} BTC</td>
26+
</tr>
27+
<tr>
28+
<td style="padding: 1rem; color: #495057;">Total Downloads</td>
29+
<td style="padding: 1rem; text-align: right; font-weight: 600; color: #ff6b35;">{{TOTAL_DOWNLOADS}}</td>
30+
</tr>
31+
</tbody>
32+
</table>
2333
</div>
2434

2535
### Liquidity Over Time

0 commit comments

Comments
 (0)