@@ -125,6 +125,8 @@ export function usePackageComparison(packageNames: MaybeRefOrGetter<string[]>) {
125125 if ( ! latestVersion ) return null
126126
127127 // Fetch fast additional data in parallel (optional - failures are ok)
128+ const repoInfo = parseRepositoryInfo ( pkgData . repository )
129+ const isGitHub = repoInfo ?. provider === 'github'
128130 const [ downloads , analysis , vulns , likes , ghStars , ghIssues ] = await Promise . all ( [
129131 $fetch < { downloads : number } > (
130132 `https://api.npmjs.org/downloads/point/last-week/${ encodePackageName ( name ) } ` ,
@@ -138,16 +140,20 @@ export function usePackageComparison(packageNames: MaybeRefOrGetter<string[]>) {
138140 $fetch < PackageLikes > ( `/api/social/likes/${ encodePackageName ( name ) } ` ) . catch (
139141 ( ) => null ,
140142 ) ,
141- $fetch < { repo : { stars : number } } > (
142- `https://ungh.cc/repos/${ parseRepositoryInfo ( pkgData . repository ) ?. owner } /${ parseRepositoryInfo ( pkgData . repository ) ?. repo } ` ,
143- )
144- . then ( res => res ?. repo . stars || 0 )
145- . catch ( ( ) => null ) ,
146- $fetch < { issues : number } > (
147- `/api/github/issues/${ parseRepositoryInfo ( pkgData . repository ) ?. owner } /${ parseRepositoryInfo ( pkgData . repository ) ?. repo } ` ,
148- )
149- . then ( res => res ?. issues || 0 )
150- . catch ( ( ) => null ) ,
143+ isGitHub
144+ ? $fetch < { repo : { stars : number } } > (
145+ `https://ungh.cc/repos/${ repoInfo . owner } /${ repoInfo . repo } ` ,
146+ )
147+ . then ( res => res ?. repo . stars || 0 )
148+ . catch ( ( ) => null )
149+ : Promise . resolve ( null ) ,
150+ isGitHub
151+ ? $fetch < { issues : number } > (
152+ `/api/github/issues/${ repoInfo . owner } /${ repoInfo . repo } ` ,
153+ )
154+ . then ( res => res ?. issues || 0 )
155+ . catch ( ( ) => null )
156+ : Promise . resolve ( null ) ,
151157 ] )
152158 const versionData = pkgData . versions [ latestVersion ]
153159 const packageSize = versionData ?. dist ?. unpackedSize
@@ -272,7 +278,7 @@ export function usePackageComparison(packageNames: MaybeRefOrGetter<string[]>) {
272278
273279 return packagesData . value . map ( pkg => {
274280 if ( ! pkg ) return null
275- console . log ( pkg . package . name , { pkg } )
281+
276282 return computeFacetValue (
277283 facet ,
278284 pkg ,
@@ -565,34 +571,24 @@ function computeFacetValue(
565571 return {
566572 raw : stars ,
567573 display : formatCompactNumber ( stars ) ,
568- status : stars > 1000 ? 'good' : 'neutral' ,
574+ status : 'neutral' ,
569575 }
570576 }
571577 case 'githubIssues' : {
572578 const issues = data . metadata ?. github ?. issues
573579 if ( issues == null ) return null
574- const stars = data . metadata ?. github ?. stars
575- const ratio = stars && issues > 0 ? issues / stars : null
576580 return {
577581 raw : issues ,
578582 display : formatCompactNumber ( issues ) ,
579- // High issues-to-stars ratio suggests the project is struggling relative to its popularity
580- status : ratio == null || ratio < 0.1 ? 'good' : ratio < 0.5 ? 'neutral' : 'warning' ,
583+ status : 'neutral' ,
581584 }
582585 }
583586 case 'createdAt' : {
584587 const createdAt = data . metadata ?. createdAt
585- const resolved = createdAt ? resolveNoDependencyDisplay ( createdAt , t ) : null
586- if ( resolved ) return { raw : 0 , ...resolved }
587588 if ( ! createdAt ) return null
588- const date = new Date ( createdAt )
589- const oneMonthAgo = new Date ( )
590- oneMonthAgo . setMonth ( oneMonthAgo . getMonth ( ) - 1 )
591589 return {
592- raw : date . getTime ( ) ,
590+ raw : createdAt ,
593591 display : createdAt ,
594- // Package is rated "good" if it was created more than a month ago (not brand new)
595- status : date < oneMonthAgo ? 'good' : 'neutral' ,
596592 type : 'date' ,
597593 }
598594 }
0 commit comments