forked from LBRYCommunity/lbry-sdk
fixes for old keys
This commit is contained in:
parent
b31368a3a7
commit
96b506f9fa
3 changed files with 10 additions and 5 deletions
|
@ -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'}"
|
||||
)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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'])
|
||||
|
|
Loading…
Reference in a new issue