def update_repo_indexes(cls): old_obj_ids = cls.query_repo_objs() old_obj_ids = [id for id, in old_obj_ids] new_obj_ids = CodeDoubanProject.get_project_ids_sortby_sumup() new_objs = CodeDoubanProject.gets(new_obj_ids) to_delete_ids = set(old_obj_ids) - set(new_obj_ids) cls.delete_repo_indexes(to_delete_ids) index_data = [cls.get_repo_index_from_project(project) for project in new_objs] indexes = [(data['id'], data) for data in index_data] IndexEngine.create_index_bulk('repo', indexes)
def update_repo_indexes(cls): old_obj_ids = cls.query_repo_objs() old_obj_ids = [id for id, in old_obj_ids] new_obj_ids = CodeDoubanProject.get_project_ids_sortby_sumup() new_objs = CodeDoubanProject.gets(new_obj_ids) to_delete_ids = set(old_obj_ids) - set(new_obj_ids) cls.delete_repo_indexes(to_delete_ids) index_data = [ cls.get_repo_index_from_project(project) for project in new_objs ] indexes = [(data['id'], data) for data in index_data] IndexEngine.create_index_bulk('repo', indexes)