mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
upsert all version platform records
This commit is contained in:
@@ -7,7 +7,7 @@ module Database.Queries where
|
||||
|
||||
import Database.Persist.Sql (
|
||||
PersistStoreRead (get),
|
||||
PersistStoreWrite (insertKey, insert_, insertMany_, repsert),
|
||||
PersistStoreWrite (insertKey, insert_, repsertMany, repsert),
|
||||
SqlBackend,
|
||||
)
|
||||
import Lib.Types.Core (
|
||||
@@ -15,7 +15,7 @@ import Lib.Types.Core (
|
||||
)
|
||||
import Lib.Types.Emver (Version)
|
||||
import Model (
|
||||
Key (PkgRecordKey, VersionRecordKey),
|
||||
Key (PkgRecordKey, VersionRecordKey, VersionPlatformKey),
|
||||
Metric (Metric),
|
||||
PkgDependency (..),
|
||||
PkgRecord (PkgRecord),
|
||||
@@ -324,10 +324,11 @@ upsertPackageVersionPlatform PackageManifest{..} = do
|
||||
let pkgId = PkgRecordKey packageManifestId
|
||||
let arches = [X86_64, AARCH64]
|
||||
let records = createVersionPlatformRecord now pkgId packageManifestVersion <$> arches
|
||||
insertMany_ records
|
||||
repsertMany records
|
||||
where
|
||||
createVersionPlatformRecord time id version = VersionPlatform
|
||||
createVersionPlatformRecord time id version arch = ((VersionPlatformKey id version arch), VersionPlatform
|
||||
time
|
||||
(Just time)
|
||||
id
|
||||
version
|
||||
version
|
||||
arch)
|
||||
@@ -143,6 +143,7 @@ import Yesod (
|
||||
)
|
||||
import Yesod.Auth (YesodAuth (maybeAuthId))
|
||||
import Yesod.Core.Types (JSONResponse (JSONResponse))
|
||||
import Database.Persist.Sql (runSqlPool)
|
||||
|
||||
|
||||
postPkgUploadR :: Handler ()
|
||||
@@ -226,7 +227,7 @@ postPkgIndexR = do
|
||||
[i|Could not locate manifest for #{indexPkgReqId}@#{indexPkgReqVersion}|]
|
||||
pool <- getsYesod appConnPool
|
||||
runSqlPoolNoTransaction (upsertPackageVersion man) pool Nothing
|
||||
runSqlPoolNoTransaction (upsertPackageVersionPlatform man) pool Nothing
|
||||
runSqlPool (upsertPackageVersionPlatform man) pool
|
||||
|
||||
postPkgDeindexR :: Handler ()
|
||||
postPkgDeindexR = do
|
||||
|
||||
@@ -106,6 +106,10 @@ instance PersistField OsArch where
|
||||
fromPersistValue other = Left [i|Invalid OsArch: #{other}|]
|
||||
instance PersistFieldSql OsArch where
|
||||
sqlType _ = SqlString
|
||||
instance FromJSON OsArch where
|
||||
parseJSON = parseJSON
|
||||
instance ToJSON OsArch where
|
||||
toJSON = toJSON
|
||||
|
||||
newtype Extension (a :: Symbol) = Extension String deriving (Eq)
|
||||
type S9PK = Extension "s9pk"
|
||||
|
||||
@@ -70,7 +70,7 @@ VersionPlatform
|
||||
pkgId PkgRecordId
|
||||
versionNumber Version
|
||||
arch OsArch
|
||||
Primary pkgId versionNumber
|
||||
Primary pkgId versionNumber arch
|
||||
deriving Eq
|
||||
deriving Show
|
||||
|
||||
|
||||
Reference in New Issue
Block a user