forked from LBRYCommunity/lbry-sdk
fast search
use cost from lighthouse
This commit is contained in:
parent
69139b1987
commit
bcfabba038
1 changed files with 5 additions and 20 deletions
|
@ -1925,31 +1925,16 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
def _clean(n):
|
def _clean(n):
|
||||||
t = []
|
t = []
|
||||||
for i in n:
|
for i in n:
|
||||||
if i[0]:
|
td = {k: i['value'][k] for k in i['value']}
|
||||||
tr = {}
|
td['cost_est'] = float(i['cost'])
|
||||||
tr.update(i[1][0]['value'])
|
td['thumbnail'] = i['value'].get('thumbnail', "img/Free-speech-flag.svg")
|
||||||
thumb = tr.get('thumbnail', None)
|
td['name'] = i['name']
|
||||||
if thumb is None:
|
t.append(td)
|
||||||
tr['thumbnail'] = "img/Free-speech-flag.svg"
|
|
||||||
tr['name'] = i[1][0]['name']
|
|
||||||
tr['cost_est'] = i[1][1]
|
|
||||||
t.append(tr)
|
|
||||||
return t
|
return t
|
||||||
|
|
||||||
def get_est_costs(results):
|
|
||||||
def _save_cost(search_result):
|
|
||||||
d = self._get_est_cost(search_result['name'])
|
|
||||||
d.addCallback(lambda p: [search_result, p])
|
|
||||||
return d
|
|
||||||
|
|
||||||
dl = defer.DeferredList([_save_cost(r) for r in results], consumeErrors=True)
|
|
||||||
return dl
|
|
||||||
|
|
||||||
log.info('Search: %s' % search)
|
log.info('Search: %s' % search)
|
||||||
|
|
||||||
d = self._search(search)
|
d = self._search(search)
|
||||||
d.addCallback(lambda claims: claims[:self.max_search_results])
|
|
||||||
d.addCallback(get_est_costs)
|
|
||||||
d.addCallback(_clean)
|
d.addCallback(_clean)
|
||||||
d.addCallback(lambda results: self._render_response(results, OK_CODE))
|
d.addCallback(lambda results: self._render_response(results, OK_CODE))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue