@@ -8,6 +8,7 @@ import Distribution.PackageDescription
8
8
import Distribution.Server.Features.Documentation
9
9
( DocumentationFeature (.. ) )
10
10
import Distribution.Server.Features.PackageList.MStats
11
+ import Distribution.Server.Features.ReverseDependencies (ReverseCount (.. ))
11
12
import Distribution.Server.Features.PreferredVersions
12
13
import Distribution.Server.Features.PreferredVersions.State
13
14
import Distribution.Server.Features.TarIndexCache
@@ -270,19 +271,21 @@ baseScore vers maintainers docs env tarCache versionList lastUploads pkgI = do
270
271
documHas = queryHasDocumentation docs pkgId
271
272
272
273
temporalScore
273
- :: PackageDescription -> [CL. UTCTime ] -> [Version ] -> Int -> IO Scorer
274
- temporalScore p lastUploads versionList recentDownloads = do
274
+ :: PackageDescription -> [CL. UTCTime ] -> [Version ] -> Int -> ReverseCount -> IO Scorer
275
+ temporalScore p lastUploads versionList recentDownloads ( ReverseCount dir tot) = do
275
276
fresh <- freshnessScore
276
277
tract <- tractionScore
277
- -- Reverse dependencies are added
278
- return $ tract <> fresh <> downloadScore
278
+ return $ tract <> fresh <> downloadScore <> (if isApp then scorer 0 2 else dirScore <> indirScore)
279
279
where
280
280
isApp = (isNothing . library) p && (not . null . executables) p
281
281
downloadScore = calcDownScore recentDownloads
282
+ dirScore = fracScor 5 (logBase 2 (int2Float $ max 0 (dir - 32 ) + 32 ) - 5 )
283
+ indirScore = fracScor 2 (logBase 2 (int2Float $ max 0 (tot - dir - 32 ) + 32 )
284
+ - 5 / 3 )
282
285
calcDownScore i = fracScor
283
286
5
284
- ( ( logBase 2 (int2Float $ max 0 (i - 32 ) + 32 ) - 5 )
285
- / (if isApp then 6 else 8 )
287
+ ( logBase 2 (int2Float $ max 0 (i - 16 ) + 16 )
288
+ - (if isApp then 3 else 4 )
286
289
)
287
290
packageFreshness = case safeHead lastUploads of
288
291
Nothing -> return 0
@@ -302,11 +305,12 @@ rankPackage
302
305
-> ServerEnv
303
306
-> [PkgInfo ]
304
307
-> Maybe PkgInfo
308
+ -> ReverseCount
305
309
-> IO Float
306
- rankPackage _ _ _ _ _ _ _ Nothing = return 0
307
- rankPackage versions recentDownloads maintainers docs tarCache env pkgs (Just pkgUsed)
310
+ rankPackage _ _ _ _ _ _ _ Nothing _ = return 0
311
+ rankPackage versions recentDownloads maintainers docs tarCache env pkgs (Just pkgUsed) revCount
308
312
= do
309
- t <- temporalScore pkgD uploads versionList recentDownloads
313
+ t <- temporalScore pkgD uploads versionList recentDownloads revCount
310
314
311
315
b <- baseScore versions
312
316
maintainers
0 commit comments