diff --git a/rhodecode/apps/admin/views/settings.py b/rhodecode/apps/admin/views/settings.py --- a/rhodecode/apps/admin/views/settings.py +++ b/rhodecode/apps/admin/views/settings.py @@ -482,7 +482,8 @@ class AdminSettingsView(BaseAppView): settings_model = IssueTrackerSettingsModel() try: - form = IssueTrackerPatternsForm(self.request.translate)().to_python(self.request.POST) + form = IssueTrackerPatternsForm(self.request.translate)() + data = form.to_python(self.request.POST) except formencode.Invalid as errors: log.exception('Failed to add new pattern') error = errors @@ -490,11 +491,11 @@ class AdminSettingsView(BaseAppView): category='error') raise HTTPFound(h.route_path('admin_settings_issuetracker')) - if form: - for uid in form.get('delete_patterns', []): + if data: + for uid in data.get('delete_patterns', []): settings_model.delete_entries(uid) - for pattern in form.get('patterns', []): + for pattern in data.get('patterns', []): for setting, value, type_ in pattern: sett = settings_model.create_or_update_setting( setting, value, type_) diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -1672,12 +1672,7 @@ def _process_url_func(match_obj, repo_na return tmpl % data -def process_patterns(text_string, repo_name, link_format='html'): - allowed_formats = ['html', 'rst', 'markdown'] - if link_format not in allowed_formats: - raise ValueError('Link format can be only one of:{} got {}'.format( - allowed_formats, link_format)) - +def get_active_pattern_entries(repo_name): repo = None if repo_name: # Retrieving repo_name to avoid invalid repo_name to explode on @@ -1686,7 +1681,18 @@ def process_patterns(text_string, repo_n settings_model = IssueTrackerSettingsModel(repo=repo) active_entries = settings_model.get_settings(cache=True) + return active_entries + +def process_patterns(text_string, repo_name, link_format='html', + active_entries=None): + + allowed_formats = ['html', 'rst', 'markdown'] + if link_format not in allowed_formats: + raise ValueError('Link format can be only one of:{} got {}'.format( + allowed_formats, link_format)) + + active_entries = active_entries or get_active_pattern_entries(repo_name) issues_data = [] newtext = text_string @@ -1725,7 +1731,8 @@ def process_patterns(text_string, repo_n return newtext, issues_data -def urlify_commit_message(commit_text, repository=None): +def urlify_commit_message(commit_text, repository=None, + active_pattern_entries=None): """ Parses given text message and makes proper links. issues are linked to given issue-server, and rest is a commit link @@ -1747,7 +1754,8 @@ def urlify_commit_message(commit_text, r newtext = urlify_commits(newtext, repository) # process issue tracker patterns - newtext, issues = process_patterns(newtext, repository or '') + newtext, issues = process_patterns(newtext, repository or '', + active_entries=active_pattern_entries) return literal(newtext) diff --git a/rhodecode/templates/changelog/changelog_elements.mako b/rhodecode/templates/changelog/changelog_elements.mako --- a/rhodecode/templates/changelog/changelog_elements.mako +++ b/rhodecode/templates/changelog/changelog_elements.mako @@ -12,6 +12,12 @@ % endif +## to speed up lookups cache some functions before the loop +<% + active_patterns = h.get_active_pattern_entries(c.repo_name) + urlify_commit_message = h.partial(h.urlify_commit_message, active_pattern_entries=active_patterns) +%> + % for cnt,commit in enumerate(c.pagination): @@ -81,7 +87,7 @@
-
${h.urlify_commit_message(commit.message, c.repo_name)}
+
${urlify_commit_message(commit.message, c.repo_name)}