Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: appengine/monorail/tracker/issuereindex.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/monorail/tracker/issuepeek.py ('k') | appengine/monorail/tracker/issuetips.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is govered by a BSD-style
3 # license that can be found in the LICENSE file or at
4 # https://developers.google.com/open-source/licenses/bsd
5
6 """Classes that implement an admin utility to re-index issues in bulk."""
7
8 import logging
9 import urllib
10
11 import settings
12 from framework import permissions
13 from framework import servlet
14 from framework import urls
15 from services import tracker_fulltext
16
17
18 class IssueReindex(servlet.Servlet):
19 """IssueReindex shows a form to request that issues be indexed."""
20
21 _PAGE_TEMPLATE = 'tracker/issue-reindex-page.ezt'
22 _MAIN_TAB_MODE = servlet.Servlet.MAIN_TAB_ISSUES
23
24 def AssertBasePermission(self, mr):
25 """Check whether the user has any permission to visit this page.
26
27 Args:
28 mr: commonly used info parsed from the request.
29 """
30 super(IssueReindex, self).AssertBasePermission(mr)
31 if not self.CheckPerm(mr, permissions.EDIT_PROJECT):
32 raise permissions.PermissionException(
33 'You are not allowed to administer this project')
34
35 def GatherPageData(self, mr):
36 """Build up a dictionary of data values to use when rendering the page.
37
38 Args:
39 mr: commonly used info parsed from the request.
40
41 Returns:
42 Dict of values used by EZT for rendering the page.
43 """
44 return {
45 # start and num are already passed to the template.
46 'issue_tab_mode': None,
47 'auto_submit': mr.auto_submit,
48 'page_perms': self.MakePagePerms(mr, None, permissions.CREATE_ISSUE),
49 }
50
51 def ProcessFormData(self, mr, post_data):
52 """Process a posted issue reindex form.
53
54 Args:
55 mr: commonly used info parsed from the request.
56 post_data: HTML form data from the request.
57
58 Returns:
59 String URL to redirect the user to after processing. The URL will contain
60 a new start that is auto-incremented using the specified num value.
61 """
62 start = max(0, int(post_data['start']))
63 num = max(0, min(settings.max_artifact_search_results_per_page,
64 int(post_data['num'])))
65
66 issues = self.services.issue.GetIssuesByLocalIDs(
67 mr.cnxn, mr.project_id, range(start, start + num))
68 logging.info('got %d issues to index', len(issues))
69 if issues:
70 tracker_fulltext.IndexIssues(
71 mr.cnxn, issues, self.services.user, self.services.issue,
72 self.services.config)
73
74 # Make the browser keep submitting the form, if the user wants that,
75 # and we have not run out of issues to process.
76 auto_submit = issues and ('auto_submit' in post_data)
77
78 query_map = {
79 'start': start + num, # auto-increment start.
80 'num': num,
81 'auto_submit': bool(auto_submit),
82 }
83 return '/p/%s%s?%s' % (mr.project_name, urls.ISSUE_REINDEX,
84 urllib.urlencode(query_map))
OLDNEW
« no previous file with comments | « appengine/monorail/tracker/issuepeek.py ('k') | appengine/monorail/tracker/issuetips.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698