From ecab123a3a6edd30be86bdc11ca84932c7ba2123 Mon Sep 17 00:00:00 2001 From: "Brendon J. Brewer" Date: Tue, 17 Aug 2021 13:41:54 +1200 Subject: [PATCH] Put trending score into ES --- lbry/wallet/server/leveldb.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lbry/wallet/server/leveldb.py b/lbry/wallet/server/leveldb.py index 9c4280e72..08b5d237b 100644 --- a/lbry/wallet/server/leveldb.py +++ b/lbry/wallet/server/leveldb.py @@ -38,6 +38,7 @@ from lbry.wallet.server.db.revertable import RevertableOpStack from lbry.wallet.server.db.prefixes import Prefixes, PendingActivationValue, ClaimTakeoverValue, ClaimToTXOValue, PrefixDB from lbry.wallet.server.db.prefixes import ACTIVATED_CLAIM_TXO_TYPE, ACTIVATED_SUPPORT_TXO_TYPE from lbry.wallet.server.db.prefixes import PendingActivationKey, TXOToClaimValue +from lbry.wallet.server.db.trending import TrendingDB from lbry.wallet.transaction import OutputScript from lbry.schema.claim import Claim, guess_stream_type from lbry.wallet.ledger import Ledger, RegTestLedger, TestNetLedger @@ -167,6 +168,8 @@ class LevelDB: else: self.ledger = RegTestLedger + self.trending_db = TrendingDB(self.env.db_dir) + def get_claim_from_txo(self, tx_num: int, tx_idx: int) -> Optional[TXOToClaimValue]: claim_hash_and_name = self.db.get(Prefixes.txo_to_claim.pack_key(tx_num, tx_idx)) if not claim_hash_and_name: @@ -700,7 +703,8 @@ class LevelDB: 'languages': languages, 'censor_type': Censor.RESOLVE if blocked_hash else Censor.SEARCH if filtered_hash else Censor.NOT_CENSORED, 'censoring_channel_id': (blocked_hash or filtered_hash or b'').hex() or None, - 'claims_in_channel': None if not metadata.is_channel else self.get_claims_in_channel_count(claim_hash) + 'claims_in_channel': None if not metadata.is_channel else self.get_claims_in_channel_count(claim_hash), + 'trending_score': self.trending_db.get_trending_score(claim_hash) # 'trending_group': 0, # 'trending_mixed': 0, # 'trending_local': 0,