mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-15 21:58:29 +01:00
* Moved all extensions into modules that are using them, rather than globally, since they mess up ghci session and introduce conflicts among packages. Removed those from `.ghci` file as well * Redesigned the schema to use Pantry and moved it into it's own module * Switched all of the db and cron related stuff to RIO. Yesod part is still on classy-prelude * Got pantry to update stackage-server database from hackage * Got import of stackage-snapshots implemented * Moved some logic from all-cabal-tool * Switched everything to `PackageNameP`, `VersionP`, etc. from a la Text. * Fixed haddock, so it now does proper redirects and pipes the docs correctly. Also implemented piping of json files from S3 bucket, so index-doc.json is also served by stackage-server thus making Ctrl+S feature work properly on haddock. Fix for commercialhaskell/stackage#4301 * Import of modules is done through cabal file parsing, which slows down the initial import process drastically, but incremental update is not a problem. * Just as with modules, dependencies are also imported from cabal file. * In general improved type safety by introducing a few data types: eg. `ModuleNameP`, `HackageCabalInfo`, and many more. * Implemented pulling of deprecation map from hackages and storing it in db * Implementation of forward/backward dependencies within a snapshot only. * Drastically improved performance of cron import job, by checking which snapshots are not up to date * Implemented pulling haddock list from S3 bucket. Modules that have documentation are marked from the availability of actual haddock. This process happens concurrently with snapshots loading. * Rearranged modules a bit: * github related functions went into it's own module * cron related functions where moved from Database to Cron module * Split up some functions to reduce individual complexity * Parallelized package loading in cron job * Implemented parsed cabal file caching. * All queries where reqritten with esqueleto * Syntactic improvements: * Added stylish-haskell config * Formatted all imports and extensions with stylish-haskell. * Fixed inconsistent indentation across all modules * Many improvements to the package page as well as few others. * Reimplemented hoogledb creation. * Dropped dependency on tar in favor of tar-conduit * Added cli for stackage-server-cron * Add cabal sha and size to the package page * Fixed links in hoogle searches. Improved type safety for a hoogle handler * satckage-server-cron is customizable with cli arguments Final adjustments for the new stackage server release: * Upgrade to lts-13.16. * Stackage server related code has been merged to pantry. Made the code compatible with the newer version pantry * Added cli '--snapshots-repo' * Add readme to package page * Adjust snapshots expected format: * Added `publish-time` * Removed name `field` * `compiler` field is now in the `resolver` field with fallback to the root
65 lines
2.4 KiB
Haskell
65 lines
2.4 KiB
Haskell
{-# LANGUAGE NoImplicitPrelude #-}
|
|
module Handler.OldLinks
|
|
( getOldSnapshotBranchR
|
|
, getOldSnapshotR
|
|
) where
|
|
|
|
import Import
|
|
import Stackage.Database
|
|
import qualified Data.Text.Read as Reader
|
|
import Network.Wai (rawQueryString)
|
|
|
|
data LtsSuffix = LSMajor !Int
|
|
| LSMinor !Int !Int
|
|
|
|
parseLtsSuffix :: Text -> Maybe LtsSuffix
|
|
parseLtsSuffix t0 = do
|
|
Right (x, t1) <- Just $ Reader.decimal t0
|
|
if null t1
|
|
then return $ LSMajor x
|
|
else do
|
|
t2 <- stripPrefix "." t1
|
|
Right (y, "") <- Just $ Reader.decimal t2
|
|
return $ LSMinor x y
|
|
|
|
redirectWithQueryText :: Text -> Handler a
|
|
redirectWithQueryText url = do
|
|
req <- waiRequest
|
|
redirect $ url ++ decodeUtf8 (rawQueryString req)
|
|
|
|
getOldSnapshotBranchR :: SnapshotBranch -> [Text] -> Handler ()
|
|
getOldSnapshotBranchR LtsBranch pieces = track "Handler.OldLinks.getOldSnapshotBranchR@LtsBranch" $ do
|
|
(x, y, pieces') <- case pieces of
|
|
t:ts | Just suffix <- parseLtsSuffix t -> do
|
|
(x, y) <- case suffix of
|
|
LSMajor x -> do
|
|
y <- newestLTSMajor x >>= maybe notFound return
|
|
return (x, y)
|
|
LSMinor x y -> return (x, y)
|
|
return (x, y, ts)
|
|
_ -> do
|
|
(x, y) <- newestLTS >>= maybe notFound return
|
|
return (x, y, pieces)
|
|
let name = concat ["lts-", tshow x, ".", tshow y]
|
|
redirectWithQueryText $ concatMap (cons '/') $ name : pieces'
|
|
|
|
getOldSnapshotBranchR (LtsMajorBranch x) pieces = track "Handler.OldLinks.getOldSnapshotBranchR@LtsMajorBranch" $ do
|
|
y <- newestLTSMajor x >>= maybe notFound return
|
|
let name = concat ["lts-", tshow x, ".", tshow y]
|
|
redirectWithQueryText $ concatMap (cons '/') $ name : pieces
|
|
|
|
getOldSnapshotBranchR NightlyBranch pieces = track "Handler.OldLinks.getOldSnapshotBranchR@NightlyBranch" $ do
|
|
(day, pieces') <- case pieces of
|
|
t:ts | Just day <- fromPathPiece t -> return (day, ts)
|
|
_ -> do
|
|
day <- newestNightly >>= maybe notFound return
|
|
return (day, pieces)
|
|
let name = "nightly-" ++ tshow day
|
|
redirectWithQueryText $ concatMap (cons '/') $ name : pieces'
|
|
|
|
getOldSnapshotR :: Text -> [Text] -> Handler ()
|
|
getOldSnapshotR t ts = track "Handler.OldLinks.getOldSnapshotR" $
|
|
case fromPathPiece t :: Maybe SnapName of
|
|
Just _ -> redirectWithQueryText $ concatMap (cons '/') $ t : ts
|
|
Nothing -> notFound
|