From 25b63c988f81ef1e4f7a96d04e0c4adc35038df4 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 18 Sep 2020 20:16:37 -0300 Subject: [PATCH] further fixes to effective amount --- lbry/db/constants.py | 2 +- lbry/db/queries/search.py | 5 ++++- tests/integration/blockchain/test_blockchain.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lbry/db/constants.py b/lbry/db/constants.py index 0f901b13f..88ba55ab4 100644 --- a/lbry/db/constants.py +++ b/lbry/db/constants.py @@ -53,7 +53,7 @@ SEARCH_INTEGER_PARAMS = { 'height', 'creation_height', 'activation_height', 'expiration_height', 'timestamp', 'creation_timestamp', 'duration', 'release_time', 'fee_amount', 'tx_position', 'channel_join', 'reposted', - 'amount', 'effective_amount', 'support_amount', + 'amount', 'staked_amount', 'support_amount', 'trending_group', 'trending_mixed', 'trending_local', 'trending_global', } diff --git a/lbry/db/queries/search.py b/lbry/db/queries/search.py index 2d0ef2604..8b16efce1 100644 --- a/lbry/db/queries/search.py +++ b/lbry/db/queries/search.py @@ -38,6 +38,9 @@ def compat_layer(**constraints): for old_key, new_key in replacements.items(): if old_key in constraints: constraints[new_key] = constraints.pop(old_key) + order_by = constraints.get("order_by", []) + if old_key in order_by: + constraints["order_by"] = [order_key if order_key != old_key else new_key for order_key in order_by] return constraints @@ -133,7 +136,7 @@ def select_claims(cols: List = None, for_count=False, **constraints) -> Select: constraints['offset'] = int(constraints.pop('sequence')) - 1 constraints['limit'] = 1 if 'amount_order' in constraints: - constraints['order_by'] = 'effective_amount DESC' + constraints['order_by'] = 'staked_amount DESC' constraints['offset'] = int(constraints.pop('amount_order')) - 1 constraints['limit'] = 1 diff --git a/tests/integration/blockchain/test_blockchain.py b/tests/integration/blockchain/test_blockchain.py index 9914be686..a24c9b3bb 100644 --- a/tests/integration/blockchain/test_blockchain.py +++ b/tests/integration/blockchain/test_blockchain.py @@ -921,7 +921,7 @@ class TestGeneralBlockchainSync(SyncingBlockchainTestCase): results = await self.db.search_claims(staked_amount=42000000) self.assertEqual(claim.claim_id, results[0].claim_id) # compat layer - results = await self.db.search_claims(effective_amount=42000000) + results = await self.db.search_claims(effective_amount=42000000, amount_order=1, order_by=["effective_amount"]) self.assertEqual(claim.claim_id, results[0].claim_id)