Skip to content

Commit 560050c

Browse files
committed
moved PackageRank into PackageList Feature and changed UI so packageRank will display as Int between 1000 and 0
1 parent 618dea1 commit 560050c

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
@@ -310,6 +310,8 @@ library lib-server
310310
Distribution.Server.Features.PackageCandidates.Backup
311311
Distribution.Server.Features.PackageFeed
312312
Distribution.Server.Features.PackageList
313+
Distribution.Server.Features.PackageList.PackageRank
314+
Distribution.Server.Features.PackageList.MStats
313315
Distribution.Server.Features.Distro
314316
Distribution.Server.Features.Distro.Distributions
315317
Distribution.Server.Features.Distro.Backup
@@ -359,8 +361,6 @@ library lib-server
359361
Distribution.Server.Features.StaticFiles
360362
Distribution.Server.Features.ServerIntrospect
361363
Distribution.Server.Features.Sitemap
362-
Distribution.Server.Features.PackageRank
363-
Distribution.Server.Features.PackageRank.Parser
364364

365365
if flag(debug)
366366
cpp-options: -DDEBUG

src/Distribution/Server/Features/Browse.hs

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

1314
import Data.Aeson (Value(Array), object, toJSON, (.=))
1415
import qualified Data.Aeson.Key as Key
@@ -147,7 +148,7 @@ packageIndexInfoToValue
147148
, Key.fromString "tags" .= map renderTag (S.toAscList itemTags)
148149
, Key.fromString "lastUpload" .= iso8601Show itemLastUpload
149150
, Key.fromString "maintainers" .= map renderUser itemMaintainer
150-
, Key.fromString "packageRank" .= itemPackageRank
151+
, Key.fromString "packageRank" .= (roundFloatInteger (1000 * itemPackageRank))
151152
]
152153
where
153154
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)