Skip to content

Commit

Permalink
fixup! Add MintBurn indexer
Browse files Browse the repository at this point in the history
Don't add a where clause when there are no condition.
  • Loading branch information
eyeinsky committed Feb 8, 2023
1 parent 8e91afc commit efb8e49
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions marconi/src/Marconi/Index/MintBurn.hs
Expand Up @@ -187,23 +187,25 @@ fromRows rows = do
rowToMintAsset row = MintAsset (row^.L._4) (row^.L._5) (row^.L._6) (row^.L._7) (row^.L._8)

sqliteSelectByTxIdPolicyId :: SQL.Connection -> (SQL.Query, [NamedParam]) -> C.TxId -> C.PolicyId -> IO [TxMintEvent]
sqliteSelectByTxIdPolicyId sqlCon (where_, params) txId policyId =
sqliteSelectByTxIdPolicyId sqlCon (conditions, params) txId policyId =
fromRows <$> SQL.queryNamed sqlCon query ([":txId" := txId, ":policyId" := policyId] <> params)
where query =
" SELECT slotNo, blockHeaderHash, txId, policyId \
\ , assetName, quantity, redeemerIx, redeemerData \
\ FROM minting_policy_events \
\ WHERE txId = :txId AND policyId = :policyId " <> where_ <> " \
\ ORDER BY slotNo, txId "
" SELECT slotNo, blockHeaderHash, txId, policyId \
\ , assetName, quantity, redeemerIx, redeemerData \
\ FROM minting_policy_events \
\ WHERE txId = :txId AND policyId = :policyId " <> conditions <> " \
\ ORDER BY slotNo, txId "

sqliteSelectAll :: SQL.Connection -> (SQL.Query, [NamedParam]) -> IO [TxMintEvent]
sqliteSelectAll sqlCon (where_, params) = fromRows <$> SQL.queryNamed sqlCon query params
where query =
" SELECT slotNo, blockHeaderHash, txId, policyId \
\ , assetName, quantity, redeemerIx, redeemerData \
\ FROM minting_policy_events \
\ WHERE " <> where_ <> " \
\ ORDER BY slotNo, txId "
sqliteSelectAll sqlCon (conditions, params) = fromRows <$> SQL.queryNamed sqlCon query params
where
whereClause = if conditions == "" then "" else " WHERE " <> conditions <> " "
query =
" SELECT slotNo, blockHeaderHash, txId, policyId \
\ , assetName, quantity, redeemerIx, redeemerData \
\ FROM minting_policy_events \
\ " <> whereClause <> " \
\ ORDER BY slotNo, txId "

intervalToWhereClause :: RI.QueryInterval C.ChainPoint -> (SQL.Query, [NamedParam])
intervalToWhereClause qi = case qi of
Expand Down

0 comments on commit efb8e49

Please sign in to comment.