Skip to content

Conversation

ArchanaArige
Copy link
Contributor

What this PR does / why we need it:

This feature implements the pagination for list of transactions to be fetched from PostgreSQL. As of now the pagination is being handled from UI. Implementing pagination from backend addresses an issue when dealing with retrieval of huge data sets.

Which issue(s) this PR fixes:

Fixes #346

Special notes for your reviewer:

This enhancement is tied up with UI-changes: ref Issue#347

Does this PR introduce a user-facing change?


Additional documentation, usage docs, etc.:


@ArchanaArige ArchanaArige added this to the Experimental Sprint milestone Feb 14, 2023
@ArchanaArige ArchanaArige requested a review from a team as a code owner February 14, 2023 04:38
@ArchanaArige ArchanaArige self-assigned this Feb 14, 2023
@ArchanaArige ArchanaArige changed the title Be 346 BE-346-Added Pagination for Transaction view - Backend Feb 14, 2023
Comment on lines 99 to 100
page: any,
size: any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick]: type will be number.

Copy link
Contributor Author

@ArchanaArige ArchanaArige Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the code as suggested.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please define the types for all the parameters.

) {
var countOfTxns: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick]: type will be number.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sqlQuery is expected to return the count of transactions and incase if it fails to do so, it returns "null". The second thing is if page=1 then we would be sending the "noOfPages" in response and for the remaining pages we would send it as "null". So considering these cases assigned the type as "any" to countOfTxns.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pipes can be used something like this let countOfTxns : number | Error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried with these combinations: var countOfTxns: number | null = null; Error is not a type and can't be defined. since we are applying arithmetic operation on countOfTransactions to derive noOfpages, the allowed types are number, any, bigInt, enum. I cant define type to be only "number" since there is a case of countOfTransactions to be null.
Below are the errors with wrong type definition:
error TS2322: Type 'unknown' is not assignable to type 'number'.
error Type 'unknown' is not assignable to type 'number | Error'.
error The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
So, I can define type to be "any" (or) number | unknown.

@ArchanaArige ArchanaArige merged commit e3b0197 into hyperledger-labs:main Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backend - Pagination implementation for the Transactions tab
2 participants