Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PackageRank #1091

Open
wants to merge 130 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
2563231
started new PageRank branch
kubaneko Jul 1, 2022
64b7f9b
correct the error
kubaneko Jul 1, 2022
b937df5
Created PackageRank module and added it to build
kubaneko Jul 3, 2022
5eed33c
write out ranking criteria
kubaneko Jul 3, 2022
d6abb2f
started with maintainer number
kubaneko Jul 4, 2022
1cf1a9f
added Upload Feature and got number of maintainers for package
kubaneko Jul 5, 2022
6ad9db2
divided rankPackage to pure and IO version
kubaneko Jul 5, 2022
b9a2417
added benchmark and test info
kubaneko Jul 5, 2022
9dbea87
added Download Feature
kubaneko Jul 7, 2022
fcbdd2d
formatted a bit
kubaneko Jul 8, 2022
d0b73cf
used brittany
kubaneko Jul 8, 2022
8a80277
added further info about the package
kubaneko Jul 11, 2022
9d68303
added isApp function
kubaneko Jul 12, 2022
2af5b62
added Scorer type and started to extract versions
kubaneko Jul 13, 2022
3d6b96e
more work on versions
kubaneko Jul 14, 2022
7dc4589
got versions and partitioned based on status
kubaneko Jul 15, 2022
96cdd01
separated versions into versionList and verPart
kubaneko Jul 15, 2022
206a412
added last upload times
kubaneko Jul 15, 2022
1676b3d
added freshnessScore
kubaneko Jul 15, 2022
19d200d
added Download Scorer
kubaneko Jul 15, 2022
22ed2b4
finished simple temporalScore (rankPackageIO)
kubaneko Jul 16, 2022
05c74bf
separated rankIO from temporalScore
kubaneko Jul 17, 2022
f8f78bc
added pageRank
kubaneko Jul 17, 2022
a1f5315
added versionScore
kubaneko Jul 18, 2022
0e6db67
added authorScore
kubaneko Jul 19, 2022
10d14a2
Fix `non-canonical-return` warnings
andreasabel Jul 21, 2022
1daad17
Bump CI to GHC 9.2.3 and restrict to master branch
andreasabel Jul 21, 2022
5329594
Check authorisation (#1111)
AliasQli Jul 21, 2022
22614b5
instance Semigroup Scorer
kubaneko Jul 22, 2022
90717dd
got tarballs and fixed warnings
kubaneko Jul 23, 2022
973a957
extracted documentation length
kubaneko Jul 25, 2022
03b3f81
got tarEntries for package and fixed it for documentation
kubaneko Jul 27, 2022
c84f467
Fix #1105: change order of markdown parsers to allow pipes in lists
andreasabel Jul 24, 2022
09e058c
added codeScore
kubaneko Jul 29, 2022
a8ae12e
replaced some Features by ListFeature
kubaneko Aug 2, 2022
124006f
added some Features to BrowseFeatures - prototype
kubaneko Aug 3, 2022
f8d176b
Revert "added some Features to BrowseFeatures - prototype"
kubaneko Aug 4, 2022
18e769d
Revert "replaced some Features by ListFeature"
kubaneko Aug 5, 2022
0bae698
changed ListFeature to fit PackageRank
kubaneko Aug 5, 2022
500571b
changed PackageRank to fit in constructItem
kubaneko Aug 5, 2022
de621f7
integrated PackageRank into ListFeature
kubaneko Aug 7, 2022
327af26
--no-edit
kubaneko Aug 7, 2022
343af58
tried to add an column and failed
kubaneko Aug 7, 2022
3ec7a86
switch Doubles for Floats
kubaneko Aug 7, 2022
82444ac
added the column and redid some packageRank issues
kubaneko Aug 9, 2022
c3aa816
fixed some basic bugs
kubaneko Aug 9, 2022
212d169
removed Browse/parser changes
kubaneko Aug 16, 2022
7304a06
Fixed missing titile and changed fixed description
kubaneko Aug 16, 2022
8380020
Strict Scorer
kubaneko Aug 16, 2022
868e58d
fixed some partial functions
kubaneko Aug 17, 2022
e033aa5
fixed some bugs
kubaneko Aug 17, 2022
60f8b83
fixed a bug
kubaneko Aug 17, 2022
ff667de
retrieves src correctly
kubaneko Aug 18, 2022
137d09d
fixed documentation retrieval
kubaneko Aug 19, 2022
33d7807
Fix #1128, fix #1130 by adding bounds to Cabal-syntax and haddock-lib…
andreasabel Aug 23, 2022
2377900
Bump CI to 9.2.4 and some deps
andreasabel Aug 23, 2022
a36abf9
changed the algorithm to match cargo
kubaneko Aug 23, 2022
c8a07a6
prototype for readme parser (collects some info about markdown)
kubaneko Aug 25, 2022
919b311
forgot to add the parser
kubaneko Aug 25, 2022
db0f10a
Force .txt and .text to have UTF-8 MIME charset (#1133)
Kleidukos Aug 25, 2022
f6c1e48
Upgrade to haddock-library-1.11.0 (#1126)
AliasQli Aug 26, 2022
0a8a85d
finished readmeScore
kubaneko Aug 26, 2022
a0e7a8f
changed documentation parameter to get reasonable output
kubaneko Aug 27, 2022
07fb0a2
changed some parameters to reflect hackage
kubaneko Aug 27, 2022
413038c
moved PackageRank into PackageList Feature and changed UI so packageR…
kubaneko Aug 28, 2022
834a12f
added some Exception handling
kubaneko Aug 30, 2022
7c36cf7
some comments and refactoring
kubaneko Sep 4, 2022
3a4ebbc
Use NonEmpty (#1)
ysangkok Sep 7, 2022
4f60d74
started new PageRank branch
kubaneko Jul 1, 2022
d071bd7
correct the error
kubaneko Jul 1, 2022
c5eb106
Created PackageRank module and added it to build
kubaneko Jul 3, 2022
a8f4d09
write out ranking criteria
kubaneko Jul 3, 2022
6abacff
started with maintainer number
kubaneko Jul 4, 2022
745ba37
added Upload Feature and got number of maintainers for package
kubaneko Jul 5, 2022
5b83f9a
divided rankPackage to pure and IO version
kubaneko Jul 5, 2022
1b3ddb1
added benchmark and test info
kubaneko Jul 5, 2022
d28983a
added Download Feature
kubaneko Jul 7, 2022
7b989ee
formatted a bit
kubaneko Jul 8, 2022
cec9c72
used brittany
kubaneko Jul 8, 2022
51ee598
added further info about the package
kubaneko Jul 11, 2022
ce5d6ae
added isApp function
kubaneko Jul 12, 2022
902f404
added Scorer type and started to extract versions
kubaneko Jul 13, 2022
29104fa
more work on versions
kubaneko Jul 14, 2022
62021ba
got versions and partitioned based on status
kubaneko Jul 15, 2022
4a521b8
separated versions into versionList and verPart
kubaneko Jul 15, 2022
c0d0e34
added last upload times
kubaneko Jul 15, 2022
9413a0d
added freshnessScore
kubaneko Jul 15, 2022
8f0f49c
added Download Scorer
kubaneko Jul 15, 2022
7ae9ac8
finished simple temporalScore (rankPackageIO)
kubaneko Jul 16, 2022
f0e7920
separated rankIO from temporalScore
kubaneko Jul 17, 2022
0eb4c94
added pageRank
kubaneko Jul 17, 2022
924c06a
added versionScore
kubaneko Jul 18, 2022
a6bfafd
added authorScore
kubaneko Jul 19, 2022
0186f6e
instance Semigroup Scorer
kubaneko Jul 22, 2022
d3a6c06
got tarballs and fixed warnings
kubaneko Jul 23, 2022
a34fed2
extracted documentation length
kubaneko Jul 25, 2022
6058249
got tarEntries for package and fixed it for documentation
kubaneko Jul 27, 2022
b1ac101
added codeScore
kubaneko Jul 29, 2022
68d2d67
replaced some Features by ListFeature
kubaneko Aug 2, 2022
544e9c0
added some Features to BrowseFeatures - prototype
kubaneko Aug 3, 2022
5e5cc6a
Revert "added some Features to BrowseFeatures - prototype"
kubaneko Aug 4, 2022
8c08fd1
Revert "replaced some Features by ListFeature"
kubaneko Aug 5, 2022
2e5ac4b
changed ListFeature to fit PackageRank
kubaneko Aug 5, 2022
8e8bf89
changed PackageRank to fit in constructItem
kubaneko Aug 5, 2022
da3c345
integrated PackageRank into ListFeature
kubaneko Aug 7, 2022
a9351aa
--no-edit
kubaneko Aug 7, 2022
728fb0d
tried to add an column and failed
kubaneko Aug 7, 2022
0d538ec
switch Doubles for Floats
kubaneko Aug 7, 2022
83cf50c
added the column and redid some packageRank issues
kubaneko Aug 9, 2022
1865b9d
fixed some basic bugs
kubaneko Aug 9, 2022
3c562bf
removed Browse/parser changes
kubaneko Aug 16, 2022
2e266dc
Fixed missing titile and changed fixed description
kubaneko Aug 16, 2022
7ed9cf5
Strict Scorer
kubaneko Aug 16, 2022
30d48cc
fixed some partial functions
kubaneko Aug 17, 2022
830cfd5
fixed some bugs
kubaneko Aug 17, 2022
df26e92
fixed a bug
kubaneko Aug 17, 2022
d889087
retrieves src correctly
kubaneko Aug 18, 2022
40bfc1b
fixed documentation retrieval
kubaneko Aug 19, 2022
a568a40
changed the algorithm to match cargo
kubaneko Aug 23, 2022
bec7e05
prototype for readme parser (collects some info about markdown)
kubaneko Aug 25, 2022
c0d4cb6
forgot to add the parser
kubaneko Aug 25, 2022
0a98ed2
finished readmeScore
kubaneko Aug 26, 2022
e1e6452
changed documentation parameter to get reasonable output
kubaneko Aug 27, 2022
618dea1
changed some parameters to reflect hackage
kubaneko Aug 27, 2022
560050c
moved PackageRank into PackageList Feature and changed UI so packageR…
kubaneko Aug 28, 2022
0bb394e
added some Exception handling
kubaneko Aug 30, 2022
dbc9141
some comments and refactoring
kubaneko Sep 4, 2022
b9b73cc
Use NonEmpty (#1)
ysangkok Sep 7, 2022
8f119d2
Merge branch 'PageRank' of github.com:kubaneko/hackage-server into Pa…
kubaneko Sep 18, 2022
a41b375
test commit
kubaneko Oct 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions datafiles/static/browse.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const replaceRows = (response) => {
tr.appendChild(createTags(row.tags));
tr.appendChild(createLastUpload(row.lastUpload));
tr.appendChild(createMaintainers(row.maintainers));
tr.appendChild(createSimpleText(row.packageRank));
kubaneko marked this conversation as resolved.
Show resolved Hide resolved
l.appendChild(tr);
}
};
Expand Down
4 changes: 4 additions & 0 deletions datafiles/templates/Html/browse.html.st
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@
#arrow-maintainers {
width: 100px;
}
#arrow-packageRank {
width: 150px;
}
.lastUpload, #sliderAndOutput {
white-space: nowrap;
}
Expand Down Expand Up @@ -250,6 +253,7 @@
<th id=arrow-tags><a href="javascript: sort('tags')">Tags</a></th>
<th id=arrow-lastUpload><a href="javascript: sort('lastUpload')">Last U/L</a></th>
<th id=arrow-maintainers><a href="javascript: sort('maintainers')">Maintainers</a></th>
<th id=arrow-packageRank><a href="javascript: sort('packageRank')">Package Rank</a></th>
</tr>
</thead>
<tbody id="listing"></tbody>
Expand Down
1 change: 1 addition & 0 deletions datafiles/templates/Html/noscript-search-form.html.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<option $if(tags)$ selected $endif$ value=tags>tags</option>
<option $if(lastUpload)$ selected $endif$ value=lastUpload>date of last upload</option>
<option $if(maintainers)$ selected $endif$ value=maintainers>maintainers</option>
<option $if(packageRank)$ selected $endif$ value=packageRank>rank of the package</option>
</select>
</label>
</div>
Expand Down
1 change: 1 addition & 0 deletions hackage-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ library lib-server
Distribution.Server.Features.StaticFiles
Distribution.Server.Features.ServerIntrospect
Distribution.Server.Features.Sitemap
Distribution.Server.Features.PackageRank

if flag(debug)
cpp-options: -DDEBUG
Expand Down
2 changes: 2 additions & 0 deletions src/Distribution/Server/Features.hs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ initHackageFeatures env@ServerEnv{serverVerbosity = verbosity} = do
versionsFeature
usersFeature
uploadFeature
documentationCoreFeature
tarIndexCacheFeature

searchFeature <- mkSearchFeature
coreFeature
Expand Down
3 changes: 2 additions & 1 deletion src/Distribution/Server/Features/Browse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ packageIndexInfoToValue :: CoreResource -> TagsResource -> UserResource -> Packa
packageIndexInfoToValue
coreResource tagsResource userResource
PackageItem{itemName, itemDownloads, itemVotes,
itemDesc, itemTags, itemLastUpload, itemMaintainer} =
itemDesc, itemTags, itemLastUpload, itemMaintainer, itemPackageRank} =
object
[ Key.fromString "name" .= renderPackage itemName
, Key.fromString "downloads" .= itemDownloads
Expand All @@ -147,6 +147,7 @@ packageIndexInfoToValue
, Key.fromString "tags" .= map renderTag (S.toAscList itemTags)
, Key.fromString "lastUpload" .= iso8601Show itemLastUpload
, Key.fromString "maintainers" .= map renderUser itemMaintainer
, Key.fromString "packageRank" .= itemPackageRank
]
where
renderTag :: Tag -> Value
Expand Down
1 change: 1 addition & 0 deletions src/Distribution/Server/Features/Browse/ApplyFilter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ sort isSearch sortColumn sortDirection =
Tags -> comparing (S.toAscList . itemTags)
LastUpload -> comparing itemLastUpload
Maintainers -> comparing itemMaintainer
PackageRank -> comparing itemPackageRank
in sortBy (maybeReverse comparer)
where
maybeReverse =
Expand Down
4 changes: 3 additions & 1 deletion src/Distribution/Server/Features/Browse/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Distribution.Server.Features.Browse.Parsers (Filter, conditions, condsToF

data IsSearch = IsSearch | IsNotSearch

data NormalColumn = Name | Downloads | Rating | Description | Tags | LastUpload | Maintainers
data NormalColumn = Name | Downloads | Rating | Description | Tags | LastUpload | Maintainers | PackageRank
deriving (Show, Eq)

data Column = DefaultColumn | NormalColumn NormalColumn
Expand Down Expand Up @@ -37,6 +37,7 @@ instance FromJSON Column where
"tags" -> pure $ NormalColumn Tags
"lastUpload" -> pure $ NormalColumn LastUpload
"maintainers" -> pure $ NormalColumn Maintainers
"packageRank" -> pure $ NormalColumn PackageRank
t -> fail $ "Column invalid: " ++ T.unpack t

columnToTemplateName :: Column -> String
Expand All @@ -49,6 +50,7 @@ columnToTemplateName = \case
NormalColumn Tags -> "tags"
NormalColumn LastUpload -> "lastUpload"
NormalColumn Maintainers -> "maintainers"
NormalColumn PackageRank -> "packageRank"

instance FromJSON Direction where
parseJSON =
Expand Down
2 changes: 1 addition & 1 deletion src/Distribution/Server/Features/HaskellPlatform.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE RankNTypes, NamedFieldPuns, RecordWildCards #-}
module Distribution.Server.Features.HaskellPlatform (
PlatformFeature,
PlatformFeature(..),
PlatformResource(..),
initPlatformFeature,
) where
Expand Down
40 changes: 28 additions & 12 deletions src/Distribution/Server/Features/PackageList.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import Distribution.Server.Features.DownloadCount
import Distribution.Server.Features.Tags
import Distribution.Server.Features.Users
import Distribution.Server.Features.Upload(UploadFeature(..))
import Distribution.Server.Features.Documentation (DocumentationFeature(..))
import Distribution.Server.Features.TarIndexCache (TarIndexCacheFeature(..))
import Distribution.Server.Features.PackageRank

import Distribution.Server.Users.Users (userIdToName)
import qualified Distribution.Server.Users.UserIdSet as UserIdSet
import Distribution.Server.Users.Group(UserGroup(..), GroupDescription(..))
Expand All @@ -39,7 +43,6 @@ import Data.Set (Set)
import qualified Data.Set as Set
import Data.Time.Clock (UTCTime(..))


data ListFeature = ListFeature {
listFeatureInterface :: HackageFeature,

Expand Down Expand Up @@ -85,18 +88,20 @@ data PackageItem = PackageItem {
-- How many benchmarks (>=0) this package has.
itemNumBenchmarks :: !Int,
-- Last upload date
itemLastUpload :: !UTCTime
itemLastUpload :: !UTCTime,
-- Hotness: a more heuristic way to sort packages. presently non-existent.
--itemHotness :: Int
--itemHotness :: Int
-- heuristic way to sort packages
itemPackageRank :: !Float
}

instance MemSize PackageItem where
memSize (PackageItem a b c d e f g h i j k l) = memSize12 a b c d e f g h i j k l
memSize (PackageItem a b c d e f g h i j k l m) = memSize13 a b c d e f g h i j k l m


emptyPackageItem :: PackageName -> PackageItem
emptyPackageItem pkg = PackageItem pkg Set.empty Nothing "" []
0 0 False 0 0 0 (UTCTime (toEnum 0) 0)
0 0 False 0 0 0 (UTCTime (toEnum 0) 0) 0


initListFeature :: ServerEnv
Expand All @@ -108,6 +113,8 @@ initListFeature :: ServerEnv
-> VersionsFeature
-> UserFeature
-> UploadFeature
-> DocumentationFeature
-> TarIndexCacheFeature
-> IO ListFeature)
initListFeature _env = do
itemCache <- newMemStateWHNF Map.empty
Expand All @@ -120,11 +127,12 @@ initListFeature _env = do
tagsf@TagsFeature{..}
versions@VersionsFeature{..}
users@UserFeature{..}
uploads@UploadFeature{..} -> do
uploads@UploadFeature{..}
documentation tar -> do

let (feature, modifyItem, updateDesc) =
listFeature core download votesf tagsf versions users uploads
itemCache itemUpdate
itemCache itemUpdate documentation tar _env

registerHookJust packageChangeHook isPackageChangeAny $ \(pkgid, _) ->
updateDesc (packageName pkgid)
Expand Down Expand Up @@ -180,6 +188,9 @@ listFeature :: CoreFeature
-> UploadFeature
-> MemState (Map PackageName PackageItem)
-> Hook (Set PackageName) ()
-> DocumentationFeature
-> TarIndexCacheFeature
-> ServerEnv
-> (ListFeature,
PackageName -> (PackageItem -> PackageItem) -> IO (),
PackageName -> IO ())
Expand All @@ -188,10 +199,11 @@ listFeature CoreFeature{..}
DownloadFeature{..}
VotesFeature{..}
TagsFeature{..}
VersionsFeature{..}
versions@VersionsFeature{..}
UserFeature{..}
UploadFeature{..}
itemCache itemUpdate
documentation tar env
= (ListFeature{..}, modifyItem, updateDesc)
where
listFeatureInterface = (emptyHackageFeature "list") {
Expand Down Expand Up @@ -222,7 +234,7 @@ listFeature CoreFeature{..}
let pkgs = PackageIndex.lookupPackageName index pkgname
case pkgs of
Copy link
Member

@ysangkok ysangkok Aug 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can case on Data.NonEmpty.nonEmpty pkgs instead. Then the Just nonEmptyList case can pass that list on to constructItem

[] -> return () --this shouldn't happen
_ -> modifyMemState itemCache . uncurry Map.insert =<< constructItem (last pkgs)
_ -> modifyMemState itemCache . uncurry Map.insert =<< constructItem pkgs

updateDesc pkgname = do
index <- queryGetPackageIndex
Expand All @@ -243,19 +255,22 @@ listFeature CoreFeature{..}
constructItemIndex :: IO (Map PackageName PackageItem)
constructItemIndex = do
index <- queryGetPackageIndex
items <- mapM (constructItem . last) $ PackageIndex.allPackagesByName index
items <- mapM constructItem $ PackageIndex.allPackagesByName index
return $ Map.fromList items

constructItem :: PkgInfo -> IO (PackageName, PackageItem)
constructItem pkg = do
constructItem :: [PkgInfo] -> IO (PackageName, PackageItem)
constructItem pkgs = do
let pkgname = packageName pkg
pkg = last pkgs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoidable partial function

-- [reverse index disabled] revCount <- query . GetReverseCount $ pkgname
users <- queryGetUserDb
tags <- queryTagsForPackage pkgname
downs <- recentPackageDownloads
votes <- pkgNumScore pkgname
deprs <- queryGetDeprecatedFor pkgname
maintainers <- queryUserGroup (maintainersGroup pkgname)
packageR <- rankPackage versions (cmFind pkgname downs)
(UserIdSet.size maintainers) documentation tar env pkgs

return $ (,) pkgname $ (updateDescriptionItem (pkgDesc pkg) $ emptyPackageItem pkgname) {
itemTags = tags
Expand All @@ -265,6 +280,7 @@ listFeature CoreFeature{..}
-- [reverse index disabled] , itemRevDepsCount = directReverseCount revCount
, itemVotes = votes
, itemLastUpload = fst (pkgOriginalUploadInfo pkg)
, itemPackageRank = packageR
}

------------------------------
Expand Down
Loading