Skip to content

Commit 306b68d

Browse files
committed
fix for when same message is displayed multiple times
1 parent 36dfbd5 commit 306b68d

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

nodescraper/models/taskresult.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,33 @@ def _get_event_summary(self) -> str:
108108
Returns:
109109
str: event summary with counts and descriptions
110110
"""
111-
error_msgs = []
112-
warning_msgs = []
111+
error_msg_counts: dict[str, int] = {}
112+
warning_msg_counts: dict[str, int] = {}
113113

114114
for event in self.events:
115115
if event.priority == EventPriority.WARNING:
116-
warning_msgs.append(event.description)
116+
warning_msg_counts[event.description] = (
117+
warning_msg_counts.get(event.description, 0) + 1
118+
)
117119
elif event.priority >= EventPriority.ERROR:
118-
error_msgs.append(event.description)
120+
error_msg_counts[event.description] = error_msg_counts.get(event.description, 0) + 1
119121

120122
summary_parts = []
121123

122-
if warning_msgs:
123-
summary_parts.append(f"{len(warning_msgs)} warnings: {', '.join(warning_msgs)}")
124-
if error_msgs:
125-
summary_parts.append(f"{len(error_msgs)} errors: {', '.join(error_msgs)}")
124+
if warning_msg_counts:
125+
total_warnings = sum(warning_msg_counts.values())
126+
warning_details = [
127+
f"{msg} (x{count})" if count > 1 else msg
128+
for msg, count in warning_msg_counts.items()
129+
]
130+
summary_parts.append(f"{total_warnings} warnings: {', '.join(warning_details)}")
131+
132+
if error_msg_counts:
133+
total_errors = sum(error_msg_counts.values())
134+
error_details = [
135+
f"{msg} (x{count})" if count > 1 else msg for msg, count in error_msg_counts.items()
136+
]
137+
summary_parts.append(f"{total_errors} errors: {', '.join(error_details)}")
126138

127139
return "; ".join(summary_parts)
128140

0 commit comments

Comments
 (0)