Skip to content

Commit 9aed21b

Browse files
committed
aeson fix
1 parent c20269c commit 9aed21b

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

src/Distribution/Server/Features/Browse.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Data.ByteString.Lazy (ByteString)
99
import Data.Time (getCurrentTime)
1010

1111
import Data.Aeson (Value(Array), eitherDecode, object, toJSON, (.=))
12-
import qualified Data.Text as T
12+
import qualified Data.Aeson.Key as Key
1313
import qualified Data.Vector as V
1414

1515
import Distribution.Server.Features.Browse.ApplyFilter (applyFilter)
@@ -115,8 +115,8 @@ getNewPkgList CoreFeature{queryGetPackageIndex, coreResource} UserFeature{userRe
115115
let pageContents = V.slice startIndex numElems (V.fromList listOfPkgs)
116116
pure . toResponse $
117117
object
118-
[ T.pack "pageContents" .= Array pageContents
119-
, T.pack "numberOfResults" .= toJSON (length listOfPkgs)
118+
[ Key.fromString "pageContents" .= Array pageContents
119+
, Key.fromString "numberOfResults" .= toJSON (length listOfPkgs)
120120
]
121121

122122
parseBrowseOptions :: ByteString -> ExceptT ErrorResponse IO BrowseOptions

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import Data.Time.Clock (UTCTime(utctDay), diffUTCTime)
88
import Data.Time.Format.ISO8601 (iso8601Show)
99

1010
import Data.Aeson (Value, (.=), object)
11-
import qualified Data.Text as T
11+
import qualified Data.Aeson.Key as Key
12+
1213
import qualified Data.Set as S
1314

1415
import Distribution.Server.Features.Browse.Options (BrowseOptions(..), Direction(..), Column(..), Sort(..), NormalColumn(..), IsSearch(..))
@@ -33,30 +34,30 @@ applyFilter now isSearch coreResource userResource tagsResource DistroFeature{qu
3334
packageIndexInfoToValue :: PackageItem -> Value
3435
packageIndexInfoToValue PackageItem{..} =
3536
object
36-
[ T.pack "name" .= renderPackage itemName
37-
, T.pack "downloads" .= itemDownloads
38-
, T.pack "votes" .= itemVotes
39-
, T.pack "description" .= itemDesc
40-
, T.pack "tags" .= map renderTag (S.toAscList itemTags)
41-
, T.pack "lastUpload" .= iso8601Show itemLastUpload
42-
, T.pack "maintainers" .= map renderUser itemMaintainer
37+
[ Key.fromString "name" .= renderPackage itemName
38+
, Key.fromString "downloads" .= itemDownloads
39+
, Key.fromString "votes" .= itemVotes
40+
, Key.fromString "description" .= itemDesc
41+
, Key.fromString "tags" .= map renderTag (S.toAscList itemTags)
42+
, Key.fromString "lastUpload" .= iso8601Show itemLastUpload
43+
, Key.fromString "maintainers" .= map renderUser itemMaintainer
4344
]
4445
renderTag :: Tag -> Value
4546
renderTag tag =
4647
object
47-
[ T.pack "uri" .= tagUri tagsResource "" tag
48-
, T.pack "display" .= display tag
48+
[ Key.fromString "uri" .= tagUri tagsResource "" tag
49+
, Key.fromString "display" .= display tag
4950
]
5051
renderUser :: UserName -> Value
5152
renderUser user =
5253
object
53-
[ T.pack "uri" .= userPageUri userResource "" user
54-
, T.pack "display" .= display user
54+
[ Key.fromString "uri" .= userPageUri userResource "" user
55+
, Key.fromString "display" .= display user
5556
]
5657
renderPackage pkg =
5758
object
58-
[ T.pack "uri" .= corePackageNameUri coreResource "" pkg
59-
, T.pack "display" .= display pkg
59+
[ Key.fromString "uri" .= corePackageNameUri coreResource "" pkg
60+
, Key.fromString "display" .= display pkg
6061
]
6162

6263
includeItem :: PackageItem -> Filter -> IO Bool

0 commit comments

Comments
 (0)