##// END OF EJS Templates
issue-trackers: cache the fetched issue tracker patterns in changelog page before loop iteration
marcink -
r2445:a90945a8 default
parent child Browse files
Show More
@@ -482,7 +482,8 b' class AdminSettingsView(BaseAppView):'
482 482 settings_model = IssueTrackerSettingsModel()
483 483
484 484 try:
485 form = IssueTrackerPatternsForm(self.request.translate)().to_python(self.request.POST)
485 form = IssueTrackerPatternsForm(self.request.translate)()
486 data = form.to_python(self.request.POST)
486 487 except formencode.Invalid as errors:
487 488 log.exception('Failed to add new pattern')
488 489 error = errors
@@ -490,11 +491,11 b' class AdminSettingsView(BaseAppView):'
490 491 category='error')
491 492 raise HTTPFound(h.route_path('admin_settings_issuetracker'))
492 493
493 if form:
494 for uid in form.get('delete_patterns', []):
494 if data:
495 for uid in data.get('delete_patterns', []):
495 496 settings_model.delete_entries(uid)
496 497
497 for pattern in form.get('patterns', []):
498 for pattern in data.get('patterns', []):
498 499 for setting, value, type_ in pattern:
499 500 sett = settings_model.create_or_update_setting(
500 501 setting, value, type_)
@@ -1672,12 +1672,7 b' def _process_url_func(match_obj, repo_na'
1672 1672 return tmpl % data
1673 1673
1674 1674
1675 def process_patterns(text_string, repo_name, link_format='html'):
1676 allowed_formats = ['html', 'rst', 'markdown']
1677 if link_format not in allowed_formats:
1678 raise ValueError('Link format can be only one of:{} got {}'.format(
1679 allowed_formats, link_format))
1680
1675 def get_active_pattern_entries(repo_name):
1681 1676 repo = None
1682 1677 if repo_name:
1683 1678 # Retrieving repo_name to avoid invalid repo_name to explode on
@@ -1686,7 +1681,18 b' def process_patterns(text_string, repo_n'
1686 1681
1687 1682 settings_model = IssueTrackerSettingsModel(repo=repo)
1688 1683 active_entries = settings_model.get_settings(cache=True)
1684 return active_entries
1689 1685
1686
1687 def process_patterns(text_string, repo_name, link_format='html',
1688 active_entries=None):
1689
1690 allowed_formats = ['html', 'rst', 'markdown']
1691 if link_format not in allowed_formats:
1692 raise ValueError('Link format can be only one of:{} got {}'.format(
1693 allowed_formats, link_format))
1694
1695 active_entries = active_entries or get_active_pattern_entries(repo_name)
1690 1696 issues_data = []
1691 1697 newtext = text_string
1692 1698
@@ -1725,7 +1731,8 b' def process_patterns(text_string, repo_n'
1725 1731 return newtext, issues_data
1726 1732
1727 1733
1728 def urlify_commit_message(commit_text, repository=None):
1734 def urlify_commit_message(commit_text, repository=None,
1735 active_pattern_entries=None):
1729 1736 """
1730 1737 Parses given text message and makes proper links.
1731 1738 issues are linked to given issue-server, and rest is a commit link
@@ -1747,7 +1754,8 b' def urlify_commit_message(commit_text, r'
1747 1754 newtext = urlify_commits(newtext, repository)
1748 1755
1749 1756 # process issue tracker patterns
1750 newtext, issues = process_patterns(newtext, repository or '')
1757 newtext, issues = process_patterns(newtext, repository or '',
1758 active_entries=active_pattern_entries)
1751 1759
1752 1760 return literal(newtext)
1753 1761
@@ -12,6 +12,12 b''
12 12 </tr>
13 13 % endif
14 14
15 ## to speed up lookups cache some functions before the loop
16 <%
17 active_patterns = h.get_active_pattern_entries(c.repo_name)
18 urlify_commit_message = h.partial(h.urlify_commit_message, active_pattern_entries=active_patterns)
19 %>
20
15 21 % for cnt,commit in enumerate(c.pagination):
16 22 <tr id="sha_${commit.raw_id}" class="changelogRow container ${'tablerow%s' % (cnt%2)}">
17 23
@@ -81,7 +87,7 b''
81 87 </td>
82 88 <td class="td-description mid">
83 89 <div class="log-container truncate-wrap">
84 <div class="message truncate" id="c-${commit.raw_id}">${h.urlify_commit_message(commit.message, c.repo_name)}</div>
90 <div class="message truncate" id="c-${commit.raw_id}">${urlify_commit_message(commit.message, c.repo_name)}</div>
85 91 </div>
86 92 </td>
87 93
General Comments 0
You need to be logged in to leave comments. Login now