##// 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 settings_model = IssueTrackerSettingsModel()
482 settings_model = IssueTrackerSettingsModel()
483
483
484 try:
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 except formencode.Invalid as errors:
487 except formencode.Invalid as errors:
487 log.exception('Failed to add new pattern')
488 log.exception('Failed to add new pattern')
488 error = errors
489 error = errors
@@ -490,11 +491,11 b' class AdminSettingsView(BaseAppView):'
490 category='error')
491 category='error')
491 raise HTTPFound(h.route_path('admin_settings_issuetracker'))
492 raise HTTPFound(h.route_path('admin_settings_issuetracker'))
492
493
493 if form:
494 if data:
494 for uid in form.get('delete_patterns', []):
495 for uid in data.get('delete_patterns', []):
495 settings_model.delete_entries(uid)
496 settings_model.delete_entries(uid)
496
497
497 for pattern in form.get('patterns', []):
498 for pattern in data.get('patterns', []):
498 for setting, value, type_ in pattern:
499 for setting, value, type_ in pattern:
499 sett = settings_model.create_or_update_setting(
500 sett = settings_model.create_or_update_setting(
500 setting, value, type_)
501 setting, value, type_)
@@ -1672,12 +1672,7 b' def _process_url_func(match_obj, repo_na'
1672 return tmpl % data
1672 return tmpl % data
1673
1673
1674
1674
1675 def process_patterns(text_string, repo_name, link_format='html'):
1675 def get_active_pattern_entries(repo_name):
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
1681 repo = None
1676 repo = None
1682 if repo_name:
1677 if repo_name:
1683 # Retrieving repo_name to avoid invalid repo_name to explode on
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 settings_model = IssueTrackerSettingsModel(repo=repo)
1682 settings_model = IssueTrackerSettingsModel(repo=repo)
1688 active_entries = settings_model.get_settings(cache=True)
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 issues_data = []
1696 issues_data = []
1691 newtext = text_string
1697 newtext = text_string
1692
1698
@@ -1725,7 +1731,8 b' def process_patterns(text_string, repo_n'
1725 return newtext, issues_data
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 Parses given text message and makes proper links.
1737 Parses given text message and makes proper links.
1731 issues are linked to given issue-server, and rest is a commit link
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 newtext = urlify_commits(newtext, repository)
1754 newtext = urlify_commits(newtext, repository)
1748
1755
1749 # process issue tracker patterns
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 return literal(newtext)
1760 return literal(newtext)
1753
1761
@@ -12,6 +12,12 b''
12 </tr>
12 </tr>
13 % endif
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 % for cnt,commit in enumerate(c.pagination):
21 % for cnt,commit in enumerate(c.pagination):
16 <tr id="sha_${commit.raw_id}" class="changelogRow container ${'tablerow%s' % (cnt%2)}">
22 <tr id="sha_${commit.raw_id}" class="changelogRow container ${'tablerow%s' % (cnt%2)}">
17
23
@@ -81,7 +87,7 b''
81 </td>
87 </td>
82 <td class="td-description mid">
88 <td class="td-description mid">
83 <div class="log-container truncate-wrap">
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 </div>
91 </div>
86 </td>
92 </td>
87
93
General Comments 0
You need to be logged in to leave comments. Login now