Merge branch 'faster-channel-id-file-startup'
This commit is contained in:
commit
07292363f9
2 changed files with 16 additions and 8 deletions
|
@ -15,6 +15,7 @@ at anytime.
|
|||
### Fixed
|
||||
* `blob_list` raising an error when blobs in a stream haven't yet been created
|
||||
* stopping a download from raising `NoneType object has no attribute finished_deferred`
|
||||
* file manager startup locking up when there are many files for some channels
|
||||
|
||||
### Deprecated
|
||||
*
|
||||
|
|
|
@ -718,21 +718,28 @@ class SQLiteStorage(object):
|
|||
results = {}
|
||||
bind = "({})".format(','.join('?' for _ in range(len(stream_hashes))))
|
||||
claim_infos = transaction.execute(
|
||||
"select content_claim.stream_hash, c.*, "
|
||||
"case when c.channel_claim_id is not null then "
|
||||
"(select claim_name from claim where claim_id==c.channel_claim_id) "
|
||||
"else null end as channel_name from content_claim "
|
||||
"select content_claim.stream_hash, c.* from content_claim "
|
||||
"inner join claim c on c.claim_outpoint=content_claim.claim_outpoint "
|
||||
"and content_claim.stream_hash in {} order by c.rowid desc".format(bind),
|
||||
tuple(stream_hashes)
|
||||
).fetchall()
|
||||
channel_id_infos = {}
|
||||
for claim_info in claim_infos:
|
||||
if claim_info[7]:
|
||||
streams = channel_id_infos.get(claim_info[7], [])
|
||||
streams.append(claim_info[0])
|
||||
channel_id_infos[claim_info[7]] = streams
|
||||
for claim_info in claim_infos:
|
||||
channel_name = claim_info[-1]
|
||||
stream_hash = claim_info[0]
|
||||
result = _format_claim_response(*claim_info[1:-1])
|
||||
if channel_name:
|
||||
result['channel_name'] = channel_name
|
||||
result = _format_claim_response(*claim_info[1:])
|
||||
results[stream_hash] = result
|
||||
bind = "({})".format(','.join('?' for _ in range(len(channel_id_infos))))
|
||||
for claim_id, channel_name in transaction.execute(
|
||||
"select claim_id, claim_name from claim where claim_id in {}".format(bind),
|
||||
tuple(channel_id_infos.keys())
|
||||
).fetchall():
|
||||
for stream_hash in channel_id_infos[claim_id]:
|
||||
results[stream_hash]['channel_name'] = channel_name
|
||||
return results
|
||||
|
||||
claims = yield self.db.runInteraction(_batch_get_claim)
|
||||
|
|
Loading…
Reference in a new issue