Skip to content

Commit

Permalink
fix repofilename index
Browse files Browse the repository at this point in the history
  • Loading branch information
cir9no committed Oct 14, 2024
1 parent a684189 commit 08447c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions seasearch/index_store/index_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def update_library_filename_index(self, repo_id, commit_id, repo_filename_index,
commit_id = to_commit
time.sleep(1)

repo_status_filename_index.begin_update_repo(repo_id, commit_id, new_commit_id, metadata_last_updated_time)
repo_status_filename_index.begin_update_repo(repo_id, commit_id, new_commit_id, metadata_last_updated_time=metadata_last_updated_time)
repo_filename_index.update(index_name, repo_id, commit_id, new_commit_id, rows, self.metadata_server_api, need_index_metadata)
repo_status_filename_index.finish_update_repo(repo_id, new_commit_id, metadata_query_time)
repo_status_filename_index.finish_update_repo(repo_id, new_commit_id, metadata_query_time=metadata_query_time)

logger.info('repo: %s, update repo filename index success', repo_id)

Expand Down
20 changes: 12 additions & 8 deletions seasearch/index_store/repo_status_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def __init__(self, repo_id, from_commit, to_commit, **kwargs):
self.repo_id = repo_id
self.from_commit = from_commit
self.to_commit = to_commit
if metadata_updated_time := kwargs.get('metadata_updated_time'):
self.metadata_updated_time = metadata_updated_time
if 'metadata_updated_time' in kwargs:
self.metadata_updated_time = kwargs['metadata_updated_time']

def need_recovery(self):
return self.to_commit is not None
Expand Down Expand Up @@ -71,8 +71,8 @@ def add_repo_status(self, repo_id, commit_id, updatingto, **kwargs):
'updatingto': updatingto,
}

if metadata_updated_time := kwargs.get('metadata_updated_time'):
data.update(metadata_updated_time=metadata_updated_time)
if 'metadata_updated_time' in kwargs:
data.update(metadata_updated_time=kwargs['metadata_updated_time'])

doc_id = repo_id
self.seasearch_api.create_document_by_id(self.index_name, doc_id, data)
Expand All @@ -89,14 +89,18 @@ def delete_documents_by_repo(self, repo_id):
def get_repo_status_by_id(self, repo_id):
doc = self.seasearch_api.get_document_by_id(self.index_name, repo_id)
if doc.get('error'):
return RepoStatus(repo_id, None, None, None)
if self.is_status_filename_index():
return RepoStatus(repo_id, None, None, metadata_updated_time=None)
else:
return RepoStatus(repo_id, None, None)

commit_id = doc['_source']['commit_id']
updatingto = doc['_source']['updatingto']
repo_id = doc['_source']['repo_id']

if self.is_status_filename_index():
metadata_updated_time = doc['_source']['metadata_updated_time']
return RepoStatus(repo_id, commit_id, updatingto, metadata_updated_time)
return RepoStatus(repo_id, commit_id, updatingto, metadata_updated_time=metadata_updated_time)

return RepoStatus(repo_id, commit_id, updatingto)

Expand Down Expand Up @@ -171,8 +175,8 @@ def _repo_head_search(self, query_params):
'commit_id': commit_id,
'updatingto': updatingto,
}
if metadata_updated_time := hit.get('_source').get('metadata_updated_time'):
repo_head['metadata_updated_time'] = metadata_updated_time
if 'metadata_updated_time' in hit.get('_source', {}):
repo_head['metadata_updated_time'] = hit.get('_source').get('metadata_updated_time')
repo_heads.append(repo_head)
return repo_heads, total

Expand Down

0 comments on commit 08447c9

Please sign in to comment.