Merge branch 'faster-channel-id-file-startup'

This commit is contained in:
Jack Robison 2018-07-02 10:49:13 -04:00
commit 07292363f9
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 16 additions and 8 deletions

View file

@ -15,6 +15,7 @@ at anytime.
### Fixed ### Fixed
* `blob_list` raising an error when blobs in a stream haven't yet been created * `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` * 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 ### Deprecated
* *

View file

@ -718,21 +718,28 @@ class SQLiteStorage(object):
results = {} results = {}
bind = "({})".format(','.join('?' for _ in range(len(stream_hashes)))) bind = "({})".format(','.join('?' for _ in range(len(stream_hashes))))
claim_infos = transaction.execute( claim_infos = transaction.execute(
"select content_claim.stream_hash, c.*, " "select content_claim.stream_hash, c.* from content_claim "
"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 "
"inner join claim c on c.claim_outpoint=content_claim.claim_outpoint " "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), "and content_claim.stream_hash in {} order by c.rowid desc".format(bind),
tuple(stream_hashes) tuple(stream_hashes)
).fetchall() ).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: for claim_info in claim_infos:
channel_name = claim_info[-1]
stream_hash = claim_info[0] stream_hash = claim_info[0]
result = _format_claim_response(*claim_info[1:-1]) result = _format_claim_response(*claim_info[1:])
if channel_name:
result['channel_name'] = channel_name
results[stream_hash] = result 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 return results
claims = yield self.db.runInteraction(_batch_get_claim) claims = yield self.db.runInteraction(_batch_get_claim)