@@ -6,8 +6,10 @@ import * as vl from 'vega-lite';
66// API Configuration
77const LIST_API_URL = 'https://api.unstoppableswap.net/api/list' ;
88const 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
1315const 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 */
139141async 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 {
0 commit comments