Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADP-2788] add max-count to listTransactions API call #3772

Merged
merged 8 commits into from
Mar 9, 2023

Conversation

paolino
Copy link
Collaborator

@paolino paolino commented Mar 6, 2023

-- add an optional max_count parameter to the listTransactions API call

ADP-2788

@paolino paolino force-pushed the paolino/ADP-2788/add-max-count-to-get-txs branch 7 times, most recently from b0ccd8e to 94310e4 Compare March 7, 2023 13:57
@@ -1353,6 +1357,14 @@ sortOrderOption = optionT $ mempty
<> help "specifies a sort order, either 'ascending' or 'descending'."
<> showDefaultWith showT

-- | [--order=ORDER]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
-- | [--order=ORDER]
-- | [--max_count=MAX_COUNT]

w <- fixtureWalletWith @n ctx
(replicate 100 $ minUTxOValue (_mainEra ctx))
txs <- listLimitedTransactions @n ctx w 9
length txs `shouldBe` 9
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need more detailed testing, in particular showing how max_count plays with order, start and end query parameters. Expectation would be that max_count respects constraints of other parameters as well. It is also not clear how max_count should behave together with order. Possible scenarios:

  • max_count = n => n most recent txs in descending order
  • max_count = n, order = descending => n most recent txs in descending order
  • max_count = n, order = ascending => n most recent txs in ascending order or n oldest transactions in ascending order (requirements are not percise)
  • max_count = n, start = date => n most recent txs from start date in descending order
  • max_count = n, start = date, order = descending => n most recent txs from start date in descending order
  • max_count = n, start = date, order = ascending => n most recent txs from start date in ascending order or n oldest transactions starting from start date in ascending order (requirements are not percise)
  • max_count = n, end = date => n most recent txs not older than end date in descending order
  • max_count = n, end = date , order = descending => n most recent txs not older than end date in descending order
  • max_count = n, end = date , order = ascending => n most recent txs not older than end date in descending order or n oldest transactions not older than end date in ascending order (requirements are not percise)
  • max_count = n, start = date1, end=date2 => n most recent txs from start date, not older than end date in descending order
  • max_count = n, start = date1, end=date2, order=descending => n most recent txs from start date, not older than end date in descending order
  • max_count = n, start = date1, end=date2, order=ascending => n most recent txs from start date, not older than end date in ascending order or n oldest transactions starting from start date and not older than end date in ascending order (requirements are not percise)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

covered in unit tests

@paolino paolino self-assigned this Mar 7, 2023
-> (Maybe UniformTime, Maybe UniformTime)
-> [(Tx, TxMeta)]
-> Property
walletListTransactionsLimited wallet@(wid, _, _) _order (_mstart, _mend) history =
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
walletListTransactionsLimited wallet@(wid, _, _) _order (_mstart, _mend) history =
walletListTransactionsWithLimit wallet@(wid, _, _) _order (_mstart, _mend) history =

@@ -916,6 +916,7 @@ data TransactionListArgs = TransactionListArgs
, _timeRangeEnd :: Maybe Iso8601Time
, _sortOrder :: Maybe SortOrder
, _schema :: TxMetadataSchema
, _limit :: Maybe Int
Copy link
Member

Choose a reason for hiding this comment

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

Question: is the behaviour defined for negative values?

If there's no reason to support negative values, then perhaps we could use Natural or Word here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No we are not offering a negative number of results, this is just a wallet :-)

specifications/api/swagger.yaml Show resolved Hide resolved
@paolino paolino force-pushed the paolino/ADP-2788/add-max-count-to-get-txs branch 2 times, most recently from a5974e1 to 5da3855 Compare March 8, 2023 14:46
@paolino paolino force-pushed the paolino/ADP-2788/add-max-count-to-get-txs branch from 5da3855 to b981c97 Compare March 8, 2023 15:47
@piotr-iohk
Copy link
Contributor

bors try

iohk-bors bot added a commit that referenced this pull request Mar 9, 2023
Copy link
Contributor

@piotr-iohk piotr-iohk left a comment

Choose a reason for hiding this comment

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

LGTM. I've added a bit more integration tests and benchmark for listTx = 100 to restorationBenchmarks suite such that we can control the expectation that max_count makes it faster.

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Mar 9, 2023

try

Build failed:

@paolino
Copy link
Collaborator Author

paolino commented Mar 9, 2023

bors retry

iohk-bors bot added a commit that referenced this pull request Mar 9, 2023
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Mar 9, 2023

try

Build failed:

@paolino
Copy link
Collaborator Author

paolino commented Mar 9, 2023

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Mar 9, 2023

Build succeeded:

@iohk-bors iohk-bors bot merged commit d4a93d5 into master Mar 9, 2023
@iohk-bors iohk-bors bot deleted the paolino/ADP-2788/add-max-count-to-get-txs branch March 9, 2023 21:29
WilliamKingNoel-Bot pushed a commit that referenced this pull request Mar 9, 2023
…API call r=paolino a=paolino -- add an optional max_count parameter to the listTransactions API call ADP-2788 Co-authored-by: paolino <paolo.veronelli@gmail.com> Co-authored-by: Piotr Stachyra <piotr.stachyra@iohk.io> Source commit: d4a93d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants