add published-at to registry response

This commit is contained in:
Aiden McClelland
2022-07-25 18:27:52 -06:00
parent e42cd787b4
commit 8aa78e9831
2 changed files with 7 additions and 0 deletions

View File

@@ -25,8 +25,10 @@ import Startlude (
(&),
(.),
(<$>),
UTCTime,
)
import Yesod
import Data.Time.Format.ISO8601 (iso8601Show)
dataUrl :: (ContentType, ByteString) -> Text
@@ -48,6 +50,7 @@ data PackageRes = PackageRes
, packageResLicense :: !Text
, packageResVersions :: !(NonEmpty Version)
, packageResDependencies :: !(HashMap PkgId DependencyRes)
, packageResPublishedAt :: !UTCTime
}
deriving (Show, Generic)
@@ -66,6 +69,7 @@ instance ApiResponse PackageRes where
, "categories" .= packageResCategories
, "versions" .= packageResVersions
, "dependency-metadata" .= (apiEncode v <$> packageResDependencies)
, "published-at" .= (iso8601Show packageResPublishedAt)
]

View File

@@ -81,6 +81,7 @@ import Startlude (
(<&>),
(<>),
(=<<),
liftA2,
)
import UnliftIO (Concurrently (..), mapConcurrently)
import Yesod (
@@ -92,6 +93,7 @@ import Yesod (
sendResponseStatus,
)
import Yesod.Core (logWarn)
import Data.List.NonEmpty (head)
data PackageReq = PackageReq
@@ -230,6 +232,7 @@ constructPackageListApiRes PackageMetadata{..} dependencies = do
, packageResLicense = basicRender $ LicenseR V0 pkgId
, packageResVersions = versionRecordNumber <$> pkgVersions
, packageResDependencies = dependencies
, packageResPublishedAt = ((liftA2 fromMaybe) versionRecordCreatedAt versionRecordUpdatedAt) (head pkgVersions)
}