From 96b506f9fad7fa2bf2b6499c155aa85bc239d394 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 11 Dec 2020 19:31:39 -0300 Subject: [PATCH] fixes for old keys --- lbry/db/queries/search.py | 11 ++++++++--- lbry/service/api.py | 2 +- tests/integration/blockchain/test_blockchain.py | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lbry/db/queries/search.py b/lbry/db/queries/search.py index 25cde4a73..19dac918e 100644 --- a/lbry/db/queries/search.py +++ b/lbry/db/queries/search.py @@ -34,7 +34,12 @@ BASE_SELECT_SUPPORT_COLUMNS = BASE_SELECT_TXO_COLUMNS + [ def compat_layer(**constraints): # for old sdk, to be removed later - replacements = {"effective_amount": "staked_amount"} + replacements = { + "effective_amount": "staked_amount", + "trending_mixed": "trend_mixed", + "trending_group": "trend_group", + "trending_local": "trend_local" + } for old_key, new_key in replacements.items(): if old_key in constraints: constraints[new_key] = constraints.pop(old_key) @@ -150,8 +155,8 @@ def select_claims(cols: List = None, for_count=False, **constraints) -> Select: column = 'claim_name' table = "trend" if column.startswith('trend') else "claim" column = f"{table}.{column}" - if column in ('trend_group', 'trend_mixed', 'release_time'): - column = f"COALESCE({column}, {1<<32})" + if column in ('trend.trend_group', 'trend.trend_mixed', 'claim.release_time'): + column = f"COALESCE({column}, {-1 * (1<<32)})" sql_order_by.append( f"{column} {'ASC' if is_asc else 'DESC'}" ) diff --git a/lbry/service/api.py b/lbry/service/api.py index 9b0b6b78f..9766c44ec 100644 --- a/lbry/service/api.py +++ b/lbry/service/api.py @@ -1603,7 +1603,7 @@ class API: 'include_total': pagination['include_total'], 'order_by': order_by }) - _, kwargs = pop_kwargs("no_totals", kwargs) # deprecated, ignoring + kwargs.pop("no_totals", None) # deprecated, ignoring claim_filter_dict.update(kwargs) if protobuf: return await self.service.protobuf_search_claims(**remove_nulls(claim_filter_dict)) diff --git a/tests/integration/blockchain/test_blockchain.py b/tests/integration/blockchain/test_blockchain.py index 1fd1e65a5..3add108d3 100644 --- a/tests/integration/blockchain/test_blockchain.py +++ b/tests/integration/blockchain/test_blockchain.py @@ -1149,7 +1149,7 @@ class TestGeneralBlockchainSync(SyncingBlockchainTestCase): claim1 = await self.get_claim(await self.create_claim(name="one")) claim2 = await self.get_claim(await self.create_claim(name="two")) await self.generate(1) - results = await self.db.search_claims(order_by=["trend_group", "trend_mixed"]) + results = await self.db.search_claims(order_by=["trending_group", "trending_mixed"]) # test compat layer self.assertEqual(0, results.rows[0].meta['trend_mixed']) self.assertEqual(0, results.rows[1].meta['trend_mixed']) self.assertEqual(0, results.rows[0].meta['trend_group'])