Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/origin_head.py
Show All 26 Lines | class OriginHeadIndexer(OriginIndexer): | ||||
) -> Dict[str, int]: | ) -> Dict[str, int]: | ||||
"""Do nothing. The indexer's results are not persistent, they | """Do nothing. The indexer's results are not persistent, they | ||||
should only be piped to another indexer.""" | should only be piped to another indexer.""" | ||||
return {} | return {} | ||||
# Dispatch | # Dispatch | ||||
def index(self, origin_url): | def index(self, origin_url): | ||||
latest_visit = self.storage.origin_visit_get_latest( | visit = self.storage.origin_visit_get_latest(origin_url) | ||||
origin_url, allowed_statuses=["full"], require_snapshot=True | if visit is None: | ||||
return None | |||||
visit_status = self.storage.origin_visit_status_get_latest( | |||||
origin_url, visit["visit"], allowed_statuses=["full"] | |||||
) | ) | ||||
if latest_visit is None: | if visit_status is None: | ||||
return None | |||||
latest_snapshot = self.storage.snapshot_get(visit_status.snapshot) | |||||
if latest_snapshot is None: | |||||
return None | return None | ||||
latest_snapshot = self.storage.snapshot_get(latest_visit["snapshot"]) | |||||
method = getattr( | method = getattr( | ||||
self, "_try_get_%s_head" % latest_visit["type"], self._try_get_head_generic | self, "_try_get_%s_head" % visit["type"], self._try_get_head_generic | ||||
) | ) | ||||
rev_id = method(latest_snapshot) | rev_id = method(latest_snapshot) | ||||
if rev_id is not None: | if rev_id is not None: | ||||
return { | return { | ||||
"origin_url": origin_url, | "origin_url": origin_url, | ||||
"revision_id": rev_id, | "revision_id": rev_id, | ||||
} | } | ||||
▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines |