@@ -8,6 +8,7 @@ import Distribution.PackageDescription
88import Distribution.Server.Features.Documentation
99 ( DocumentationFeature (.. ) )
1010import Distribution.Server.Features.PackageList.MStats
11+ import Distribution.Server.Features.ReverseDependencies (ReverseCount (.. ))
1112import Distribution.Server.Features.PreferredVersions
1213import Distribution.Server.Features.PreferredVersions.State
1314import Distribution.Server.Features.TarIndexCache
@@ -270,19 +271,21 @@ baseScore vers maintainers docs env tarCache versionList lastUploads pkgI = do
270271 documHas = queryHasDocumentation docs pkgId
271272
272273temporalScore
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
275276 fresh <- freshnessScore
276277 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)
279279 where
280280 isApp = (isNothing . library) p && (not . null . executables) p
281281 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 )
282285 calcDownScore i = fracScor
283286 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 )
286289 )
287290 packageFreshness = case safeHead lastUploads of
288291 Nothing -> return 0
@@ -302,11 +305,12 @@ rankPackage
302305 -> ServerEnv
303306 -> [PkgInfo ]
304307 -> Maybe PkgInfo
308+ -> ReverseCount
305309 -> 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
308312 = do
309- t <- temporalScore pkgD uploads versionList recentDownloads
313+ t <- temporalScore pkgD uploads versionList recentDownloads revCount
310314
311315 b <- baseScore versions
312316 maintainers
0 commit comments