Skip to content

Commit

Permalink
Bypass launchNumber to suggest_info index
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Nov 10, 2023
1 parent f07676d commit 3428238
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
3 changes: 3 additions & 0 deletions app/commons/launch_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class SuggestAnalysisResult(BaseModel):
testItemLogId: int
launchId: int
launchName: str
launchNumber: int
issueType: str
relevantItem: int
relevantLogId: int
Expand Down Expand Up @@ -209,6 +210,7 @@ class BatchLogInfo(BaseModel):
project: int
launchId: int
launchName: str
launchNumber: int = 0


class AnalysisCandidate(BaseModel):
Expand All @@ -220,3 +222,4 @@ class AnalysisCandidate(BaseModel):
project: int
launchId: int
launchName: str
launchNumber: int = 0
38 changes: 22 additions & 16 deletions app/service/auto_analyzer_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,25 +263,28 @@ def _send_result_to_queue(self, test_item_dict, batches, batch_logs):
candidates = []
candidates_with_no_defect = []
time_processed = 0.0
for ind in test_item_dict[test_item_id]:
batch_log_info = batch_logs[ind]
batch_log_info = None
for idx in test_item_dict[test_item_id]:
batch_log_info = batch_logs[idx]
if batch_log_info.query_type == "without no defect":
candidates.append(
(batch_log_info.log_info, partial_res[ind]))
(batch_log_info.log_info, partial_res[idx]))
if batch_log_info.query_type == "with no defect":
candidates_with_no_defect.append(
(batch_log_info.log_info, partial_res[ind]))
(batch_log_info.log_info, partial_res[idx]))
time_processed += avg_time_processed
self.queue.put(AnalysisCandidate(
analyzerConfig=batch_log_info.analyzerConfig,
testItemId=batch_log_info.testItemId,
project=batch_log_info.project,
launchId=batch_log_info.launchId,
launchName=batch_log_info.launchName,
timeProcessed=time_processed,
candidates=candidates,
candidatesWithNoDefect=candidates_with_no_defect
))
if batch_log_info:
self.queue.put(AnalysisCandidate(
analyzerConfig=batch_log_info.analyzerConfig,
testItemId=batch_log_info.testItemId,
project=batch_log_info.project,
launchId=batch_log_info.launchId,
launchName=batch_log_info.launchName,
launchNumber=batch_log_info.launchNumber,
timeProcessed=time_processed,
candidates=candidates,
candidatesWithNoDefect=candidates_with_no_defect
))

def _query_elasticsearch(self, launches, max_batch_size=30):
t_start = time()
Expand Down Expand Up @@ -337,7 +340,8 @@ def _query_elasticsearch(self, launches, max_batch_size=30):
query_type=query_type,
project=launch.project,
launchId=launch.launchId,
launchName=launch.launchName
launchName=launch.launchName,
launchNumber=launch.launchNumber
))
if test_item.testItemId not in test_item_dict:
test_item_dict[test_item.testItemId] = []
Expand Down Expand Up @@ -493,6 +497,7 @@ def analyze_logs(self, launches):
testItemLogId=test_item_log_id,
launchId=analyzer_candidates.launchId,
launchName=analyzer_candidates.launchName,
launchNumber=analyzer_candidates.launchNumber,
issueType=predicted_issue_type,
relevantItem=relevant_item,
relevantLogId=relevant_log_id,
Expand Down Expand Up @@ -534,7 +539,8 @@ def analyze_logs(self, launches):
results_to_share[launch_id]["errors"].append(
utils.extract_exception(err))
results_to_share[launch_id]["errors_count"] += 1
if "amqpUrl" in self.app_config and self.app_config["amqpUrl"].strip():
if "amqpUrl" in self.app_config and self.app_config["amqpUrl"].strip() and len(
analyzed_results_for_index) > 0:
AmqpClient(self.app_config["amqpUrl"]).send_to_inner_queue(
self.app_config["exchangeName"], "index_suggest_info",
json.dumps([_info.dict() for _info in analyzed_results_for_index]))
Expand Down

0 comments on commit 3428238

Please sign in to comment.