From 8e68ba4751ce32c298cce735b6e324bb7deba257 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Sun, 31 Jan 2021 01:25:12 -0300 Subject: [PATCH] fix join, refresh before update --- lbry/wallet/server/db/elastic_search.py | 1 + lbry/wallet/server/db/writer.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lbry/wallet/server/db/elastic_search.py b/lbry/wallet/server/db/elastic_search.py index 10b2183ec..d51cf5949 100644 --- a/lbry/wallet/server/db/elastic_search.py +++ b/lbry/wallet/server/db/elastic_search.py @@ -135,6 +135,7 @@ class SearchIndex: "source": "ctx._source.signature_valid=false", "lang": "painless" } + await self.client.indices.refresh(self.index) await self.client.update_by_query(self.index, body=update) async def session_query(self, query_name, function, kwargs): diff --git a/lbry/wallet/server/db/writer.py b/lbry/wallet/server/db/writer.py index fe3292b0f..8ffd3216c 100644 --- a/lbry/wallet/server/db/writer.py +++ b/lbry/wallet/server/db/writer.py @@ -813,8 +813,8 @@ class SQLDB: (select group_concat(tag, ',,') from tag where tag.claim_hash in (claim.claim_hash, claim.reposted_claim_hash)) as tags, (select group_concat(language, ' ') from language where language.claim_hash in (claim.claim_hash, claim.reposted_claim_hash)) as languages, claim.* - FROM claim LEFT JOIN claimtrie USING (claim_hash) LEFT JOIN support USING (claim_hash) - WHERE support.height = {height} OR claim.height = {height} + FROM claim LEFT JOIN claimtrie USING (claim_hash) + WHERE claim.height = {height} OR claim.claim_hash in (SELECT claim_hash FROM support WHERE height = {height}) """): claim = claim._asdict() id_set = set(filter(None, (claim['claim_hash'], claim['channel_hash'], claim['reposted_claim_hash'])))