@@ -457,8 +457,9 @@ async function fetchNpmPackageDownloadsChunked(
457457 let lastChunkData : { day : string ; downloads : number } [ ] = [ ]
458458
459459 // Load cache functions (dynamic import for Netlify compatibility)
460- const { getCachedNpmDownloadChunk, setCachedNpmDownloadChunk } =
461- await import ( './stats-db.server' )
460+ const { getCachedNpmDownloadChunk, setCachedNpmDownloadChunk } = await import (
461+ './stats-db.server'
462+ )
462463
463464 // Fetch chunks sequentially to avoid nested AsyncQueuer complexity
464465 // The outer queue (per-package) provides concurrency control
@@ -500,7 +501,11 @@ async function fetchNpmPackageDownloadsChunked(
500501 if ( cachedChunk ) {
501502 // Use cached data
502503 console . log (
503- `[NPM Stats] ${ packageName } chunk ${ chunk . from } :${ chunk . to } : using cache (${ cachedChunk . totalDownloads . toLocaleString ( ) } downloads, ${ cachedChunk . isImmutable ? 'immutable' : 'mutable' } )` ,
504+ `[NPM Stats] ${ packageName } chunk ${ chunk . from } :${
505+ chunk . to
506+ } : using cache (${ cachedChunk . totalDownloads . toLocaleString ( ) } downloads, ${
507+ cachedChunk . isImmutable ? 'immutable' : 'mutable'
508+ } )`,
504509 )
505510 totalDownloadCount += cachedChunk . totalDownloads
506511 if ( cachedChunk . dailyData . length > 0 ) {
@@ -614,28 +619,9 @@ async function fetchNpmPackageDownloadsChunked(
614619export async function fetchSingleNpmPackageFresh (
615620 packageName : string ,
616621 retries : number = 3 ,
617- skipCache : boolean = false ,
618622) : Promise < NpmPackageStats > {
619623 // Import db functions dynamically to avoid pulling server code into client bundle
620- const { getCachedNpmPackageStats, setCachedNpmPackageStats } =
621- await import ( './stats-db.server' )
622-
623- // Only check cache if not skipping it
624- if ( skipCache ) {
625- console . log (
626- `[NPM Stats] Bypassing cache for ${ packageName } (skipCache=true)` ,
627- )
628- // Skip cache check entirely when forcing refresh
629- } else {
630- const cached = await getCachedNpmPackageStats ( packageName )
631- if ( cached !== null ) {
632- console . log (
633- `[NPM Stats] Using cached data for ${ packageName } (skipCache=false)` ,
634- )
635- return cached
636- }
637- console . log ( `[NPM Stats] Cache miss for ${ packageName } , fetching from API` )
638- }
624+ const { setCachedNpmPackageStats } = await import ( './stats-db.server' )
639625
640626 // Cache miss or skip cache - fetch from API
641627 let attempt = 0
@@ -775,11 +761,7 @@ export async function computeNpmOrgStats(org: string): Promise<NpmStats> {
775761 await new Promise < void > ( ( resolve , reject ) => {
776762 const queue = new AsyncQueuer (
777763 async ( packageName : string ) => {
778- const stats = await fetchSingleNpmPackageFresh (
779- packageName ,
780- 3 ,
781- true , // Always skip cache for org refresh
782- )
764+ const stats = await fetchSingleNpmPackageFresh ( packageName , 3 )
783765 return stats
784766 } ,
785767 {
@@ -882,8 +864,9 @@ export async function computeNpmOrgStats(org: string): Promise<NpmStats> {
882864 */
883865export async function refreshNpmOrgStats ( org : string ) : Promise < NpmStats > {
884866 // Import db functions dynamically to avoid pulling server code into client bundle
885- const { discoverAndRegisterPackages, setCachedNpmOrgStats } =
886- await import ( './stats-db.server' )
867+ const { discoverAndRegisterPackages, setCachedNpmOrgStats } = await import (
868+ './stats-db.server'
869+ )
887870
888871 // First, discover and register all packages
889872 try {
0 commit comments