get claim info and channel name using a single query
This commit is contained in:
parent
df735252e5
commit
acd330aa2a
1 changed files with 9 additions and 10 deletions
|
@ -718,16 +718,15 @@ class SQLiteStorage(object):
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def _get_claim(transaction):
|
def _get_claim(transaction):
|
||||||
claim_info = transaction.execute(
|
claim_info = transaction.execute("select c.*, "
|
||||||
"select * from claim where claim_outpoint=?", (claim_outpoint, )
|
"case when c.channel_claim_id is not null then "
|
||||||
).fetchone()
|
"(select claim_name from claim where claim_id==c.channel_claim_id) "
|
||||||
result = _claim_response(*claim_info)
|
"else null end as channel_name from claim c where claim_outpoint = ?",
|
||||||
if result['channel_claim_id']:
|
(claim_outpoint,)).fetchone()
|
||||||
channel_name_result = transaction.execute(
|
channel_name = claim_info[-1]
|
||||||
"select claim_name from claim where claim_id=?", (result['channel_claim_id'], )
|
result = _claim_response(*claim_info[:-1])
|
||||||
).fetchone()
|
if channel_name:
|
||||||
if channel_name_result:
|
result['channel_name'] = channel_name
|
||||||
result['channel_name'] = channel_name_result[0]
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
result = yield self.db.runInteraction(_get_claim)
|
result = yield self.db.runInteraction(_get_claim)
|
||||||
|
|
Loading…
Reference in a new issue