Skip to content

Commit

Permalink
review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaigh0 committed May 8, 2024
1 parent 73be5cb commit a1352db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
15 changes: 6 additions & 9 deletions web/services/github_issue_manager/github_issue_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
logger = logging.getLogger()
line_exp = re.compile(r"\s*File \".*(mantidqt|mantidqtinterfaces|"
r"workbench|scripts)(\/|\\)(.*)(\", line \d+, in \S+)")
issue_text_template = Template("""
ISSUE_TEXT = Template("""
Name: $name
Email: $email
Expand All @@ -23,7 +23,7 @@
**Stack trace**
```$stacktrace```
""")
comment_text_template = Template("""
COMMENT_TEXT = Template("""
Name: $name
Email: $email
Expand Down Expand Up @@ -77,7 +77,7 @@ def get_or_create_github_issue(report) -> GithubIssue | None:
not report['textBox']):
return github_issue

comment_text = comment_text_template.substitute(
comment_text = COMMENT_TEXT.substitute(
name=report['name'],
email=report['email'],
os=report['osReadable'],
Expand All @@ -89,7 +89,7 @@ def get_or_create_github_issue(report) -> GithubIssue | None:
logger.info(f'Added comment to issue {issue.url})')
return github_issue
else:
issue_text = issue_text_template.substitute(
issue_text = ISSUE_TEXT.substitute(
name=report['name'],
email=report['email'],
os=report['osReadable'],
Expand Down Expand Up @@ -152,8 +152,5 @@ def _search_for_repeat_user(uid: str, github_issue: GithubIssue) -> bool:
"""
Return true if the user id has already submitted the same error
"""
for entry_uid in ErrorReport.objects.filter(
githubIssue=github_issue).values_list('uid'):
if uid == entry_uid:
return True
return False
return any([uid == entry_uid for entry_uid in ErrorReport.objects.filter(
githubIssue=github_issue).values_list('uid')])
3 changes: 0 additions & 3 deletions web/services/github_issue_manager/test_trim_stacktrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ def test_user_specific_dirs_are_removed(self):
'KeyboardInterrupt'
self.assertNotIn(username, _trim_stacktrace(test_trace))

def test_result_is_independant_of_path_style(self):
pass

def test_line_trimmer_file_lines(self):
examples = {
r'File "C:\MantidInstall\bin\lib\site-packages\mantidqtinterfaces\Muon\GUI\Common\thread_model.py", line 98, in warning':
Expand Down
4 changes: 2 additions & 2 deletions web/services/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from string import Template

logger = logging.getLogger('NotificationLogger')
slack_message = Template("""
SLACK_MESSAGE = Template("""
Name: $name Email: $email
Additional text:
$add_text
Expand Down Expand Up @@ -35,7 +35,7 @@ def send_notification_to_slack(name,
slack_webhook_url = settings.SLACK_WEBHOOK_URL
if not slack_webhook_url:
return
text = slack_message.substitute(
text = SLACK_MESSAGE.substitute(
name=_string_or_empty_field(name),
email=_string_or_empty_field(name),
add_text=_string_or_empty_field(additional_text),
Expand Down

0 comments on commit a1352db

Please sign in to comment.