Skip to content

Commit

Permalink
Blocks pagination query fix in the backend
Browse files Browse the repository at this point in the history
Signed-off-by: Udhayakumari <pudhayakumari95@gmail.com>
  • Loading branch information
Udhayakumari authored and ArchanaArige committed Jul 4, 2023
1 parent b5412b2 commit bc56e6f
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions app/persistence/fabric/CRUDService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,14 @@ export class CRUDService {
blocks.channel_genesis_hash =$1 AND blocks.network_name = $2 AND blocknum >= 0 AND blocks.createdt between $3 AND $4
ORDER BY blocks.blocknum desc) a WHERE a.txhash IS NOT NULL LIMIT $6 OFFSET (($5 - 1) * $6)`;
} else {
sqlBlockTxList =`SELECT c.name AS channelname,
b.blocknum, b.txcount, b.datahash, b.blockhash, b.prehash,b.createdt, b.blksize,
array_agg(t.txhash) AS txhash
FROM channel c
INNER JOIN blocks b ON b.channel_genesis_hash = c.channel_genesis_hash AND
b.network_name = c.network_name
INNER JOIN transactions t ON t.blockid = b.blocknum AND t.channel_genesis_hash = c.channel_genesis_hash
AND t.network_name = c.network_name AND t.createdt between $3 and $4 = c.createdt between $3 and $4
AND t.creator_msp_id IS NOT NULL AND t.creator_msp_id != ' ' AND length(t.creator_msp_id) > 0
WHERE c.channel_genesis_hash =$1 AND c.network_name = $2 AND b.blocknum >= 0 ${byOrgs} AND b.createdt between $3 and $4
GROUP BY c.name, b.blocknum, b.txcount, b.datahash, b.blockhash, b.prehash,b.createdt, b.blksize
ORDER BY b.blocknum DESC
LIMIT $6 OFFSET (($5 - 1) * $6)`;
sqlBlockTxList = `SELECT a.* FROM (
SELECT (SELECT c.name FROM channel c WHERE c.channel_genesis_hash =$1 AND c.network_name = $2)
as channelname, blocks.blocknum,blocks.txcount ,blocks.datahash ,blocks.blockhash ,blocks.prehash,blocks.createdt, blocks.blksize, (
SELECT array_agg(txhash) as txhash FROM transactions WHERE blockid = blocks.blocknum ${byOrgs}
AND transactions.creator_msp_id IS NOT NULL
AND channel_genesis_hash = $1 AND network_name = $2 AND createdt between $3 AND $4) FROM blocks WHERE
blocks.channel_genesis_hash =$1 AND blocks.network_name = $2 AND blocknum >= 0 AND blocks.createdt between $3 AND $4
ORDER BY blocks.blocknum desc) a WHERE a.txhash IS NOT NULL LIMIT $6 OFFSET (($5 - 1) * $6)`;
}
if (page == 1) {
let sqlBlockTxCount: string;
Expand Down

0 comments on commit bc56e6f

Please sign in to comment.