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

Side by Side Diff: appengine/findit/handlers/list_analyses.py

Issue 1866883002: [Findit] A huge refactoring and some bug fixing. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix nit. 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/findit/handlers/handlers_util.py ('k') | appengine/findit/handlers/monitor_alerts.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import datetime 4 import datetime
5 5
6 from google.appengine.ext import ndb 6 from google.appengine.ext import ndb
7 7
8 from base_handler import BaseHandler 8 from base_handler import BaseHandler
9 from base_handler import Permission 9 from base_handler import Permission
10 from model.wf_analysis import WfAnalysis 10 from model.wf_analysis import WfAnalysis
11 from model import wf_analysis_result_status 11 from model import result_status
12 12
13 13
14 _DEFAULT_DISPLAY_COUNT = 500 14 _DEFAULT_DISPLAY_COUNT = 500
15 15
16 16
17 class ListAnalyses(BaseHandler): 17 class ListAnalyses(BaseHandler):
18 PERMISSION_LEVEL = Permission.ANYONE 18 PERMISSION_LEVEL = Permission.ANYONE
19 19
20 def HandleGet(self): 20 def HandleGet(self):
21 """Shows a list of Findit analysis results in HTML page. 21 """Shows a list of Findit analysis results in HTML page.
22 22
23 By default the page will display all the results under status FOUND_CORRECT, 23 By default the page will display all the results under status FOUND_CORRECT,
24 FOUND_INCORRECT and NOT_FOUND_INCORRECT. 24 FOUND_INCORRECT and NOT_FOUND_INCORRECT.
25 25
26 Available parameters: 26 Available parameters:
27 count: Parameter for number of analysis result to be displayed. 27 count: Parameter for number of analysis result to be displayed.
28 result_status: Parameter to specify the result_status of the results. 28 result_status: Parameter to specify the result_status of the results.
29 triage: Parameter for internal use. The page will display analysis results 29 triage: Parameter for internal use. The page will display analysis results
30 under status FOUND_INCORRECT, NOT_FOUND_INCORRECT, FOUND_UNTRIAGED and 30 under status FOUND_INCORRECT, NOT_FOUND_INCORRECT, FOUND_UNTRIAGED and
31 NOT_FOUND_UNTRIAGED. 31 NOT_FOUND_UNTRIAGED.
32 days: Parameter to decide only display results within a fixed amount of 32 days: Parameter to decide only display results within a fixed amount of
33 days. This parameter will turn off triage parameter and display all the 33 days. This parameter will turn off triage parameter and display all the
34 results regardless of result_status. 34 results regardless of result_status.
35 """ 35 """
36 status_code = int(self.request.get('result_status', '-1')) 36 status_code = int(self.request.get('result_status', '-1'))
37 if status_code >= 0: 37 if status_code >= 0:
38 analysis_query = WfAnalysis.query(WfAnalysis.result_status == status_code) 38 analysis_query = WfAnalysis.query(WfAnalysis.result_status == status_code)
39 elif self.request.get('triage') == '1': 39 elif self.request.get('triage') == '1':
40 analysis_query = WfAnalysis.query(ndb.AND( 40 analysis_query = WfAnalysis.query(ndb.AND(
41 WfAnalysis.result_status > wf_analysis_result_status.FOUND_CORRECT, 41 WfAnalysis.result_status > result_status.FOUND_CORRECT,
42 WfAnalysis.result_status < 42 WfAnalysis.result_status <
43 wf_analysis_result_status.NOT_FOUND_CORRECT)) 43 result_status.NOT_FOUND_CORRECT))
44 else: 44 else:
45 analysis_query = WfAnalysis.query(ndb.AND( 45 analysis_query = WfAnalysis.query(ndb.AND(
46 WfAnalysis.result_status >= wf_analysis_result_status.FOUND_CORRECT, 46 WfAnalysis.result_status >= result_status.FOUND_CORRECT,
47 WfAnalysis.result_status < wf_analysis_result_status.FOUND_UNTRIAGED)) 47 WfAnalysis.result_status < result_status.FOUND_UNTRIAGED))
48 48
49 if self.request.get('count'): 49 if self.request.get('count'):
50 count = int(self.request.get('count')) 50 count = int(self.request.get('count'))
51 else: 51 else:
52 count = _DEFAULT_DISPLAY_COUNT 52 count = _DEFAULT_DISPLAY_COUNT
53 53
54 if self.request.get('days'): # pragma: no cover 54 if self.request.get('days'): # pragma: no cover
55 start_date = datetime.datetime.utcnow() - datetime.timedelta( 55 start_date = datetime.datetime.utcnow() - datetime.timedelta(
56 int(self.request.get('days'))) 56 int(self.request.get('days')))
57 start_date = start_date.replace( 57 start_date = start_date.replace(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 'analyses': analyses, 94 'analyses': analyses,
95 'triage': self.request.get('triage', '-1'), 95 'triage': self.request.get('triage', '-1'),
96 'days': self.request.get('days', '-1'), 96 'days': self.request.get('days', '-1'),
97 'count': self.request.get('count', '-1'), 97 'count': self.request.get('count', '-1'),
98 'result_status': self.request.get('result_status', '-1') 98 'result_status': self.request.get('result_status', '-1')
99 } 99 }
100 return {'template': 'list_analyses.html', 'data': data} 100 return {'template': 'list_analyses.html', 'data': data}
101 101
102 def HandlePost(self): # pragma: no cover 102 def HandlePost(self): # pragma: no cover
103 return self.HandleGet() 103 return self.HandleGet()
OLDNEW
« no previous file with comments | « appengine/findit/handlers/handlers_util.py ('k') | appengine/findit/handlers/monitor_alerts.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698