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

Side by Side Diff: appengine/monorail/search/backendsearch.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
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 """A servlet that implements the backend of issues search.
7
8 The GET request to a backend search has the same query string
9 parameters as the issue list servlet. But, instead of rendering a
10 HTML page, the backend search handler returns a JSON response with a
11 list of matching, sorted issue IID numbers from this shard that are
12 viewable by the requesting user.
13
14 Each backend search request works within a single shard. Each
15 besearch backend job can access any single shard while processing a request.
16
17 The current user ID must be passed in from the frontend for permission
18 checking. The user ID for the special "me" term can also be passed in
19 (so that you can view another user's dashboard and "me" will refer to
20 them).
21 """
22
23 import logging
24 import time
25
26 from framework import jsonfeed
27 from search import backendsearchpipeline
28 from tracker import tracker_constants
29
30
31 class BackendSearch(jsonfeed.InternalTask):
32 """JSON servlet for issue search in a GAE backend."""
33
34 CHECK_SAME_APP = True
35 _DEFAULT_RESULTS_PER_PAGE = tracker_constants.DEFAULT_RESULTS_PER_PAGE
36
37 def HandleRequest(self, mr):
38 """Search for issues and respond with the IIDs of matching issues.
39
40 Args:
41 mr: common information parsed from the HTTP request.
42
43 Returns:
44 Results dictionary in JSON format.
45 """
46 # Users are never logged into backends, so the frontends tell us.
47 logging.info('query_project_names is %r', mr.query_project_names)
48 pipeline = backendsearchpipeline.BackendSearchPipeline(
49 mr, self.services, self.profiler, self._DEFAULT_RESULTS_PER_PAGE,
50 mr.query_project_names, mr.specified_logged_in_user_id,
51 mr.specified_me_user_id)
52 pipeline.SearchForIIDs()
53
54 start = time.time()
55 # Backends work in parallel to precache issues that the
56 # frontend is very likely to need.
57 _prefetched_issues = self.services.issue.GetIssues(
58 mr.cnxn, pipeline.result_iids[:mr.start + mr.num],
59 shard_id=mr.shard_id)
60 logging.info('prefetched and memcached %d issues in %d ms',
61 len(pipeline.result_iids[:mr.start + mr.num]),
62 int(1000 * (time.time() - start)))
63
64 return {
65 'unfiltered_iids': pipeline.result_iids,
66 'search_limit_reached': pipeline.search_limit_reached,
67 }
OLDNEW
« no previous file with comments | « appengine/monorail/search/backendnonviewable.py ('k') | appengine/monorail/search/backendsearchpipeline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698