Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/metadata.py
Show First 20 Lines • Show All 280 Lines • ▼ Show 20 Lines | def index_list(self, origin_urls): | ||||
head_rev_ids = [] | head_rev_ids = [] | ||||
origins_with_head = [] | origins_with_head = [] | ||||
origins = list(call_with_batches( | origins = list(call_with_batches( | ||||
self.storage.origin_get, | self.storage.origin_get, | ||||
[{'url': url} for url in origin_urls], ORIGIN_GET_BATCH_SIZE)) | [{'url': url} for url in origin_urls], ORIGIN_GET_BATCH_SIZE)) | ||||
for origin in origins: | for origin in origins: | ||||
head_result = self.origin_head_indexer.index(origin['url']) | head_result = self.origin_head_indexer.index(origin['url']) | ||||
if head_result: | if head_result: | ||||
head_result['origin_id'] = origin['id'] | |||||
origins_with_head.append(origin) | origins_with_head.append(origin) | ||||
head_rev_ids.append(head_result['revision_id']) | head_rev_ids.append(head_result['revision_id']) | ||||
head_revs = list(call_with_batches( | head_revs = list(call_with_batches( | ||||
self.storage.revision_get, | self.storage.revision_get, | ||||
head_rev_ids, REVISION_GET_BATCH_SIZE)) | head_rev_ids, REVISION_GET_BATCH_SIZE)) | ||||
assert len(head_revs) == len(head_rev_ids) | assert len(head_revs) == len(head_rev_ids) | ||||
results = [] | results = [] | ||||
for (origin, rev) in zip(origins_with_head, head_revs): | for (origin, rev) in zip(origins_with_head, head_revs): | ||||
if not rev: | if not rev: | ||||
self.log.warning('Missing head revision of origin %r', | self.log.warning('Missing head revision of origin %r', | ||||
origin['url']) | origin['url']) | ||||
continue | continue | ||||
rev_metadata = self.revision_metadata_indexer.index(rev) | rev_metadata = self.revision_metadata_indexer.index(rev) | ||||
orig_metadata = { | orig_metadata = { | ||||
'from_revision': rev_metadata['id'], | 'from_revision': rev_metadata['id'], | ||||
'id': origin['id'], | 'id': origin['url'], | ||||
'origin_url': origin['url'], | |||||
'metadata': rev_metadata['metadata'], | 'metadata': rev_metadata['metadata'], | ||||
'mappings': rev_metadata['mappings'], | 'mappings': rev_metadata['mappings'], | ||||
'indexer_configuration_id': | 'indexer_configuration_id': | ||||
rev_metadata['indexer_configuration_id'], | rev_metadata['indexer_configuration_id'], | ||||
} | } | ||||
results.append((orig_metadata, rev_metadata)) | results.append((orig_metadata, rev_metadata)) | ||||
return results | return results | ||||
Show All 39 Lines |