Skip to content

Commit

Permalink
Fixed the upload error
Browse files Browse the repository at this point in the history
  • Loading branch information
athiruma committed Jan 26, 2024
1 parent 025ff10 commit e3771a1
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,19 @@ def __upload_cro_report_to_es(self, monitor_data: dict):
user_forecast = self.get_user_cost_data(group_by_tag_name=group_by_tag_name, group_by_tag_value=ticket_id, requested_date=datetime.utcnow(), extra_filter_key_values={'Project': user_project}, forecast=True, duration=duration)
cost_estimation = float(instance_data[self.ZERO].get('estimated_cost', self.ZERO))
if self.__cost_over_usage.es_operations.verify_elastic_index_doc_id(index=self.__cost_over_usage.es_index_cro, doc_id=ticket_id):
es_data = self.__cost_over_usage.es_operations.get_es_data_by_id(id=ticket_id,index=self.__cost_over_usage.es_index_cro)
es_data['_source']['ticket_opened_date'] = ticket_opened_date.date()
es_data['_source']['forecast'] = user_forecast
es_data['_source']['user'] = user
source = self.__prepare_update_es_data(source=es_data.get('_source'), instance_data=instance_data,cost_estimation=cost_estimation, user_cost=user_cost)
if self.__check_value_in_es(tag_key='ticket_id_state', tag_value='in-progress', ticket_id=ticket_id):
es_data = self.__cost_over_usage.es_operations.get_es_data_by_id(id=ticket_id, index=self.__cost_over_usage.es_index_cro)
es_data['_source']['ticket_opened_date'] = ticket_opened_date.date()
es_data['_source']['forecast'] = user_forecast
es_data['_source']['user'] = user
source = self.__prepare_update_es_data(source=es_data.get('_source'), instance_data=instance_data, cost_estimation=cost_estimation, user_cost=user_cost)
self.__cost_over_usage.es_operations.update_elasticsearch_index(index=self.__es_index_cro, id=ticket_id, metadata=source)
upload_data[ticket_id] = source
else:
if self.__check_value_in_es(tag_key='ticket_id_state', tag_value='manager-approved', ticket_id=ticket_id):
es_data['_source']['ticket_id_state'] = 'in-progress'
self.__cost_over_usage.es_operations.update_elasticsearch_index(index=self.__es_index_cro, id=ticket_id, metadata=source)
upload_data[ticket_id] = source
else:
if ticket_id not in upload_data:
source = self.prepare_instance_data(instance_data=instance_data, ticket_id=ticket_id, cost_estimation=cost_estimation, user=user, user_cost=user_cost, ticket_opened_date=ticket_opened_date)
Expand Down

0 comments on commit e3771a1

Please sign in to comment.