Add project auction queries.

[?]
Jan 3, 2021, 4:43 PM
JUFBTX45TKSZMB2D4CGNB73UYM5FXAV2QMKIHBSMHEQDAECYP7HQC

Dependencies

  • [2] M4PWY5RU Preliminary work to add support for Zcash payments.
  • [3] GCVQD44V Create amends endpoint, switch to UUID primary keys
  • [4] X3ES7NUA Fine. I'll use ormolu. At least it doesn't break the code.
  • [5] 2J37EVJM Check for an open interval on project switch.
  • [6] UWMGUJOW Autoformat sources.
  • [*] LAROLAYU WIP
  • [*] IZEVQF62 Work in progress replacing sqlite with postgres.
  • [*] 64C6AWH6 Rename Ananke -> Quixotic, project reboot.
  • [*] EFSXYZPO Autoformat everything with brittany.
  • [*] B6HWAPDP Modularize & update to recent haskoin.
  • [*] 5OI44E4E Add authentication to auction search.
  • [*] 2WOOGXDH Use dbmigrations to manage database state.
  • [*] HALRDT2F Added initial auction create route.
  • [*] Z3MK2PJ5 Add GET handler for retrieving auction data.
  • [*] ADMKQQGC Initial empty Snap project.

Change contents

  • edit in lib/Aftok/Auction.hs at line 31
    [3.6138]
    [3.6138]
    _name :: Text,
    _description :: Maybe Text,
  • edit in lib/Aftok/Database/PostgreSQL/Auctions.hs at line 8
    [2.17497]
    [2.17497]
    listAuctions,
  • edit in lib/Aftok/Database/PostgreSQL/Auctions.hs at line 29
    [2.17779]
    [2.17779]
    name,
    description
  • replacement in lib/Aftok/Database/PostgreSQL/Auctions.hs at line 38
    [2.18012][2.18012:18037]()
    import Aftok.Database ()
    [2.18012]
    [2.18037]
    import Aftok.Database (Limit(..))
  • edit in lib/Aftok/Database/PostgreSQL/Auctions.hs at line 47
    [2.18164]
    [2.18164]
    import Aftok.Interval (RangeQuery(..))
  • edit in lib/Aftok/Database/PostgreSQL/Auctions.hs at line 70
    [2.18730]
    [2.18730]
    <*> field
    <*> field
  • replacement in lib/Aftok/Database/PostgreSQL/Auctions.hs at line 84
    [2.19001][2.19001:19083]()
    [sql| INSERT INTO auctions (project_id, initiator_id, raise_amount, end_time)
    [2.19001]
    [2.19083]
    [sql| INSERT INTO auctions (project_id, initiator_id, name, description, raise_amount, end_time)
  • edit in lib/Aftok/Database/PostgreSQL/Auctions.hs at line 88
    [2.19204]
    [2.19204]
    auc ^. name,
    auc ^. description,
  • replacement in lib/Aftok/Database/PostgreSQL/Auctions.hs at line 99
    [2.19406][2.19406:19498]()
    [sql| SELECT project_id, initiator_id, created_at, raise_amount, start_time, end_time
    [2.19406]
    [2.19498]
    [sql| SELECT project_id, initiator_id, created_at, name, description, raise_amount, start_time, end_time
  • edit in lib/Aftok/Database/PostgreSQL/Auctions.hs at line 104
    [2.19584]
    [2.19584]
    listAuctions :: ProjectId -> RangeQuery -> Limit -> DBM [Auction]
    listAuctions pid rq (Limit limit) =
    case rq of
    (Before e) ->
    pquery
    auctionParser
    [sql| SELECT project_id, initiator_id, created_at, name, description, raise_amount, start_time, end_time
    FROM auctions
    WHERE project_id = ?
    AND end_time < ?
    LIMIT ? |]
    (pid ^. _ProjectId, C.fromThyme e, limit)
    (During s e) ->
    pquery
    auctionParser
    [sql| SELECT project_id, initiator_id, created_at, name, description, raise_amount, start_time, end_time
    FROM auctions
    WHERE project_id = ?
    AND end_time >= ? AND end_time < ?
    LIMIT ? |]
    (pid ^. _ProjectId, C.fromThyme s, C.fromThyme e, limit)
    (After s) ->
    pquery
    auctionParser
    [sql| SELECT project_id, initiator_id, created_at, name, description, raise_amount, start_time, end_time
    FROM auctions
    WHERE project_id = ?
    AND end_time >= ?
    LIMIT ? |]
    (pid ^. _ProjectId, C.fromThyme s, limit)
    Always ->
    pquery
    auctionParser
    [sql| SELECT project_id, initiator_id, created_at, name, description, raise_amount, start_time, end_time
    FROM auctions
    WHERE project_id = ?
    LIMIT ? |]
    (pid ^. _ProjectId, limit)
  • edit in lib/Aftok/Database/PostgreSQL/Events.hs at line 26
    [2.34496]
    [2.34496]
    Limit(..),
  • replacement in lib/Aftok/Database/PostgreSQL/Events.hs at line 186
    [2.38949][2.38949:39083]()
    findEvents :: ProjectId -> UserId -> RangeQuery -> Word32 -> DBM [LogEntry]
    findEvents (ProjectId pid) (UserId uid) rquery limit = do
    [2.38949]
    [2.39083]
    findEvents :: ProjectId -> UserId -> RangeQuery -> Limit -> DBM [LogEntry]
    findEvents (ProjectId pid) (UserId uid) rquery (Limit limit) = do
  • edit in lib/Aftok/Database/PostgreSQL.hs at line 52
    [2.61725]
    [2.61725]
    (ListAuctions pid rq l) -> Q.listAuctions pid rq l
  • edit in lib/Aftok/Database.hs at line 59
    [11.26301]
    [12.19101]
    data Limit = Limit Word32
  • replacement in lib/Aftok/Database.hs at line 81
    [2.64742][2.64742:64821]()
    FindEvents :: ProjectId -> UserId -> RangeQuery -> Word32 -> DBOp [LogEntry]
    [2.64742]
    [2.64821]
    FindEvents :: ProjectId -> UserId -> RangeQuery -> Limit -> DBOp [LogEntry]
  • edit in lib/Aftok/Database.hs at line 83
    [2.64868]
    [2.64868]
    ListAuctions :: ProjectId -> RangeQuery -> Limit -> DBOp [A.Auction]
  • replacement in lib/Aftok/Database.hs at line 261
    [3.29976][3.29976:29988]()
    Word32 ->
    [3.29976]
    [2.66607]
    Limit ->
  • edit in lib/Aftok/Database.hs at line 317
    [13.767]
    [2.68172]
    listAuctions :: (MonadDB m) => UserId -> ProjectId -> RangeQuery -> Limit -> m [A.Auction]
    listAuctions uid pid rq l = do
    withProjectAuth pid uid $ ListAuctions pid rq l
  • file addition: 2021-01-03_16-15-52_auction-descriptions.txt (----------)
    [14.1]
    Description: (Describe migration here.)
    Created: 2021-01-03 16:16:17.234201601 UTC
    Depends: 2020-11-25_04-22-24_zcash-support 2016-10-29_20-54-44_auction-timestamps 2016-10-13_05-36-55_user-event-log
    Apply: |
    ALTER TABLE auctions ADD COLUMN name text NOT NULL;
    ALTER TABLE auctions ADD COLUMN description text;
  • edit in server/Aftok/Snaplet/Auctions.hs at line 67
    [3.58597]
    [16.987]
    auctionListHandler :: S.Handler App App [Auction]
    auctionListHandler = do
    uid <- requireUserId
    pid <- requireProjectId
    snapEval $ listAuctions pid uid
  • edit in server/Main.hs at line 99
    [3.78244]
    [3.78244]
    auctionListRoute =
    serveJSON (fmap auctionJSON) $ method GET auctionListHandler