##// END OF EJS Templates
helpers: pre-compiled issue tracker patterns early for speedup.
bart -
r4204:d368f200 stable
parent child Browse files
Show More
@@ -1543,6 +1543,9 b' def process_patterns(text_string, repo_n'
1543 1543 log.debug('issue tracker entry: uid: `%s` PAT:%s URL:%s PREFIX:%s',
1544 1544 uid, entry['pat'], entry['url'], entry['pref'])
1545 1545
1546 if entry.get('pat_compiled'):
1547 pattern = entry['pat_compiled']
1548 else:
1546 1549 try:
1547 1550 pattern = re.compile(r'%s' % entry['pat'])
1548 1551 except re.error:
@@ -21,6 +21,7 b''
21 21 import os
22 22 import hashlib
23 23 import logging
24 import re
24 25 from collections import namedtuple
25 26 from functools import wraps
26 27 import bleach
@@ -372,9 +373,15 b' class IssueTrackerSettingsModel(object):'
372 373 for uid in issuetracker_entries:
373 374 url_data = qs.get(self._get_keyname('url', uid, 'rhodecode_'))
374 375
376 pat = qs.get(self._get_keyname('pat', uid, 'rhodecode_'))
377 try:
378 pat_compiled = re.compile(r'%s' % pat)
379 except re.error:
380 pat_compiled = None
381
375 382 issuetracker_entries[uid] = AttributeDict({
376 'pat': qs.get(
377 self._get_keyname('pat', uid, 'rhodecode_')),
383 'pat': pat,
384 'pat_compiled': pat_compiled,
378 385 'url': url_cleaner(
379 386 qs.get(self._get_keyname('url', uid, 'rhodecode_')) or ''),
380 387 'pref': bleach.clean(
@@ -43,6 +43,9 b' class TestIssueTrackerSettingsModel(obje'
43 43 settings_mock.return_value = input_settings
44 44 result = model.get_global_settings(cache=True)
45 45 get_settings.assert_called_once_with(cache=True)
46 for k, v in result.items():
47 v.pop('pat_compiled', None)
48
46 49 assert expected_result == result
47 50
48 51 def test_get_repo_settings_raise_exception_when_repo_is_not_set(self):
@@ -68,6 +71,8 b' class TestIssueTrackerSettingsModel(obje'
68 71 settings_mock.return_value = input_settings
69 72 result = model.get_repo_settings(cache=True)
70 73 get_settings.assert_called_once_with(cache=True)
74 for k, v in result.items():
75 v.pop('pat_compiled', None)
71 76 assert expected_result == result
72 77
73 78 @pytest.mark.parametrize("inherit_settings, method", [
General Comments 0
You need to be logged in to leave comments. Login now