Skip to content

Commit f624f6f

Browse files
authored
Add lastVersion in listings (#749) (#1140)
* Add lastVersion in listings (#749)
1 parent 10e4b9b commit f624f6f

File tree

8 files changed

+20
-7
lines changed

8 files changed

+20
-7
lines changed

datafiles/static/browse.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ const replaceRows = (response) => {
133133
tr.appendChild(createSimpleText(row.description));
134134
tr.appendChild(createTags(row.tags));
135135
tr.appendChild(createLastUpload(row.lastUpload));
136+
tr.appendChild(createSimpleText(row.lastVersion));
136137
tr.appendChild(createMaintainers(row.maintainers));
137138
l.appendChild(tr);
138139
}

datafiles/templates/Html/browse.html.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249
<th id=arrow-description><a href="javascript: sort('description')">Description</a></th>
250250
<th id=arrow-tags><a href="javascript: sort('tags')">Tags</a></th>
251251
<th id=arrow-lastUpload><a href="javascript: sort('lastUpload')">Last U/L</a></th>
252+
<th id=arrow-lastVersion><a href="javascript: sort('lastVersion')">Last Version</a></th>
252253
<th id=arrow-maintainers><a href="javascript: sort('maintainers')">Maintainers</a></th>
253254
</tr>
254255
</thead>

datafiles/templates/Html/table-interface.html.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
<th><div style="min-width:160px">Description</div></th>
2828
<th><div style="width:140px">Tags</div></th>
2929
<th><div style="width:80px">Last U/L</div></th>
30-
<th><div style="width:100px">Maintainer</div></th>
30+
<th><div style="width:80px">Last Version</div></th>
31+
<th><div style="width:100px">Maintainers</div></th>
3132
</tr>
3233
</thead>
3334
<tbody>

src/Distribution/Server/Features/Browse.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,15 @@ packageIndexInfoToValue :: CoreResource -> TagsResource -> UserResource -> Packa
139139
packageIndexInfoToValue
140140
coreResource tagsResource userResource
141141
PackageItem{itemName, itemDownloads, itemVotes,
142-
itemDesc, itemTags, itemLastUpload, itemMaintainer} =
142+
itemDesc, itemTags, itemLastUpload, itemLastVersion, itemMaintainer} =
143143
object
144144
[ Key.fromString "name" .= renderPackage itemName
145145
, Key.fromString "downloads" .= itemDownloads
146146
, Key.fromString "votes" .= itemVotes
147147
, Key.fromString "description" .= itemDesc
148148
, Key.fromString "tags" .= map renderTag (S.toAscList itemTags)
149149
, Key.fromString "lastUpload" .= iso8601Show itemLastUpload
150+
, Key.fromString "lastVersion" .= itemLastVersion
150151
, Key.fromString "maintainers" .= map renderUser itemMaintainer
151152
]
152153
where

src/Distribution/Server/Features/Browse/ApplyFilter.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ sort isSearch sortColumn sortDirection =
6363
Description -> comparing itemDesc
6464
Tags -> comparing (S.toAscList . itemTags)
6565
LastUpload -> comparing itemLastUpload
66+
LastVersion -> comparing itemLastVersion
6667
Maintainers -> comparing itemMaintainer
6768
in sortBy (maybeReverse comparer)
6869
where

src/Distribution/Server/Features/Browse/Options.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Distribution.Server.Features.Browse.Parsers (Filter, conditions, condsToF
99

1010
data IsSearch = IsSearch | IsNotSearch
1111

12-
data NormalColumn = Name | Downloads | Rating | Description | Tags | LastUpload | Maintainers
12+
data NormalColumn = Name | Downloads | Rating | Description | Tags | LastUpload | LastVersion | Maintainers
1313
deriving (Show, Eq)
1414

1515
data Column = DefaultColumn | NormalColumn NormalColumn
@@ -36,6 +36,7 @@ instance FromJSON Column where
3636
"description" -> pure $ NormalColumn Description
3737
"tags" -> pure $ NormalColumn Tags
3838
"lastUpload" -> pure $ NormalColumn LastUpload
39+
"lastVersion" -> pure $ NormalColumn LastVersion
3940
"maintainers" -> pure $ NormalColumn Maintainers
4041
t -> fail $ "Column invalid: " ++ T.unpack t
4142

@@ -48,6 +49,7 @@ columnToTemplateName = \case
4849
NormalColumn Description -> "description"
4950
NormalColumn Tags -> "tags"
5051
NormalColumn LastUpload -> "lastUpload"
52+
NormalColumn LastVersion -> "lastVersion"
5153
NormalColumn Maintainers -> "maintainers"
5254

5355
instance FromJSON Direction where

src/Distribution/Server/Features/Html/HtmlUtilities.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ htmlUtilities CoreFeature{coreResource}
4949
, td $ toHtml $ itemDesc item
5050
, td $ " (" +++ renderTags (itemTags item) +++ ")"
5151
, td $ toHtml $ formatTime defaultTimeLocale "%F" (itemLastUpload item)
52+
, td $ toHtml $ itemLastVersion item
5253
, td $ "" +++ intersperse (toHtml ", ") (map renderUser (itemMaintainer item))
5354
]
5455
where

src/Distribution/Server/Features/PackageList.hs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import Distribution.Server.Users.Types
2929
import Distribution.Package
3030
import Distribution.PackageDescription
3131
import Distribution.PackageDescription.Configuration
32+
import Distribution.Pretty (prettyShow)
3233
import Distribution.Utils.ShortText (fromShortText)
3334

3435
import Control.Concurrent
@@ -85,18 +86,20 @@ data PackageItem = PackageItem {
8586
-- How many benchmarks (>=0) this package has.
8687
itemNumBenchmarks :: !Int,
8788
-- Last upload date
88-
itemLastUpload :: !UTCTime
89+
itemLastUpload :: !UTCTime,
90+
-- Last version
91+
itemLastVersion :: !String
8992
-- Hotness: a more heuristic way to sort packages. presently non-existent.
9093
--itemHotness :: Int
9194
}
9295

9396
instance MemSize PackageItem where
94-
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
97+
memSize (PackageItem a b c d e f g h i j k l o) = memSize13 a b c d e f g h i j k l o
9598

9699

97100
emptyPackageItem :: PackageName -> PackageItem
98101
emptyPackageItem pkg = PackageItem pkg Set.empty Nothing "" []
99-
0 0 False 0 0 0 (UTCTime (toEnum 0) 0)
102+
0 0 False 0 0 0 (UTCTime (toEnum 0) 0) ""
100103

101104

102105
initListFeature :: ServerEnv
@@ -249,6 +252,7 @@ listFeature CoreFeature{..}
249252
constructItem :: PkgInfo -> IO (PackageName, PackageItem)
250253
constructItem pkg = do
251254
let pkgname = packageName pkg
255+
desc = pkgDesc pkg
252256
-- [reverse index disabled] revCount <- query . GetReverseCount $ pkgname
253257
users <- queryGetUserDb
254258
tags <- queryTagsForPackage pkgname
@@ -257,14 +261,15 @@ listFeature CoreFeature{..}
257261
deprs <- queryGetDeprecatedFor pkgname
258262
maintainers <- queryUserGroup (maintainersGroup pkgname)
259263

260-
return $ (,) pkgname $ (updateDescriptionItem (pkgDesc pkg) $ emptyPackageItem pkgname) {
264+
return $ (,) pkgname $ (updateDescriptionItem desc $ emptyPackageItem pkgname) {
261265
itemTags = tags
262266
, itemMaintainer = map (userIdToName users) (UserIdSet.toList maintainers)
263267
, itemDeprecated = deprs
264268
, itemDownloads = cmFind pkgname downs
265269
-- [reverse index disabled] , itemRevDepsCount = directReverseCount revCount
266270
, itemVotes = votes
267271
, itemLastUpload = fst (pkgOriginalUploadInfo pkg)
272+
, itemLastVersion = prettyShow $ pkgVersion $ pkgInfoId pkg
268273
}
269274

270275
------------------------------

0 commit comments

Comments
 (0)