Skip to content

Commit 9d4d811

Browse files
committed
moved PackageRank into PackageList Feature and changed UI so packageRank will display as Int between 1000 and 0
1 parent ead8f6b commit 9d4d811

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

hackage-server.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@ library
348348
Distribution.Server.Features.PackageCandidates.Backup
349349
Distribution.Server.Features.PackageFeed
350350
Distribution.Server.Features.PackageList
351+
Distribution.Server.Features.PackageList.PackageRank
352+
Distribution.Server.Features.PackageList.MStats
351353
Distribution.Server.Features.Distro
352354
Distribution.Server.Features.Distro.Distributions
353355
Distribution.Server.Features.Distro.Backup
@@ -398,8 +400,6 @@ library
398400
Distribution.Server.Features.StaticFiles
399401
Distribution.Server.Features.ServerIntrospect
400402
Distribution.Server.Features.Sitemap
401-
Distribution.Server.Features.PackageRank
402-
Distribution.Server.Features.PackageRank.Parser
403403
Distribution.Server.Util.NLP.Snowball
404404

405405
if flag(debug)

src/Distribution/Server/Features/Browse.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import qualified Data.Set as S
1010
import Data.Time (getCurrentTime)
1111
import Data.Time.Format.ISO8601 (iso8601Show)
1212
import System.FilePath ((</>))
13+
import GHC.Float.RealFracMethods (roundFloatInteger)
1314

1415
import Data.Aeson (Value(Array), object, toJSON, (.=))
1516
import qualified Data.Aeson.Key as Key
@@ -150,7 +151,7 @@ packageIndexInfoToValue
150151
, Key.fromString "lastUpload" .= iso8601Show itemLastUpload
151152
, Key.fromString "referenceVersion" .= itemReferenceVersion
152153
, Key.fromString "maintainers" .= map renderUser itemMaintainer
153-
, Key.fromString "packageRank" .= itemPackageRank
154+
, Key.fromString "packageRank" .= (roundFloatInteger (1000 * itemPackageRank))
154155
]
155156
where
156157
renderTag :: Tag -> Value

src/Distribution/Server/Features/PackageList.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Distribution.Server.Features.Users
1717
import Distribution.Server.Features.Upload(UploadFeature(..))
1818
import Distribution.Server.Features.Documentation (DocumentationFeature(..))
1919
import Distribution.Server.Features.TarIndexCache (TarIndexCacheFeature(..))
20-
import Distribution.Server.Features.PackageRank
20+
import Distribution.Server.Features.PackageList.PackageRank
2121

2222
import Distribution.Server.Users.Users (userIdToName)
2323
import qualified Distribution.Server.Users.UserIdSet as UserIdSet

src/Distribution/Server/Features/PackageRank/Parser.hs renamed to src/Distribution/Server/Features/PackageList/MStats.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{-# LANGUAGE ScopedTypeVariables, FlexibleInstances, MultiParamTypeClasses, ConstraintKinds #-}
2-
module Distribution.Server.Features.PackageRank.Parser
2+
module Distribution.Server.Features.PackageList.MStats
33
( parseM
44
, sumMStat
55
, getListsTables
@@ -53,13 +53,13 @@ data MarkdownStats = NotImportant MStats |
5353

5454
getCode :: [MarkdownStats] -> (Int, Int) -- number of code blocks, size of code
5555
getCode [] = (0, 0)
56-
getCode (Code (MStats code _) : xs) = (1, code) >< getCode xs
57-
getCode (HCode (MStats code _) : xs) = (1, code) >< getCode xs
56+
getCode (Code (MStats codeT _) : xs) = (1, codeT) >< getCode xs
57+
getCode (HCode (MStats codeT _) : xs) = (1, codeT) >< getCode xs
5858
getCode (_ : xs) = getCode xs
5959

6060
getHCode :: [MarkdownStats] -> (Int, Int) -- number of code blocks, size of code
6161
getHCode [] = (0, 0)
62-
getHCode (HCode (MStats code _) : xs) = (1, code) >< getHCode xs
62+
getHCode (HCode (MStats codeT _) : xs) = (1, codeT) >< getHCode xs
6363
getHCode (_ : xs) = getHCode xs
6464

6565
getSections :: [MarkdownStats] -> Int -- number of code blocks, size of code

src/Distribution/Server/Features/PackageRank.hs renamed to src/Distribution/Server/Features/PackageList/PackageRank.hs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
-- TODO change the module name probably Distribution.Server.Features.PackageList.PackageRank
44

5-
module Distribution.Server.Features.PackageRank
5+
module Distribution.Server.Features.PackageList.PackageRank
66
( rankPackage
77
) where
88

9-
import Distribution.Server.Features.PackageRank.Parser
9+
import Distribution.Server.Features.PackageList.MStats
1010

1111
import Data.TarIndex ( TarEntryOffset )
1212
import Distribution.Package
@@ -274,9 +274,7 @@ temporalScore
274274
temporalScore p lastUploads versionList recentDownloads = do
275275
fresh <- freshnessScore
276276
tract <- tractionScore
277-
-- Reverse dependencies are to be done
278-
279-
f <- packageFreshness
277+
-- Reverse dependencies are added
280278
return $ tract <> fresh <> downloadScore
281279
where
282280
isApp = (isNothing . library) p && (not . null . executables) p

0 commit comments

Comments
 (0)