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

Unified Diff: appengine/monorail/tracker/spam_helpers.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/monorail/tracker/spam.py ('k') | appengine/monorail/tracker/tablecell.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/monorail/tracker/spam_helpers.py
diff --git a/appengine/monorail/tracker/spam_helpers.py b/appengine/monorail/tracker/spam_helpers.py
new file mode 100644
index 0000000000000000000000000000000000000000..e6dfffd8904bac45f1e03abac8d2492115ab53f3
--- /dev/null
+++ b/appengine/monorail/tracker/spam_helpers.py
@@ -0,0 +1,44 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is govered by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://developers.google.com/open-source/licenses/bsd
+
+"""Set of helpers for constructing spam-related pages.
+"""
+from framework import template_helpers
+from third_party import ezt
+
+from datetime import datetime
+
+def DecorateModerationQueue(
+ cnxn, issue_service, spam_service, user_service, moderation_items):
+ issue_ids = [item.issue_id for item in moderation_items]
+ issues = issue_service.GetIssues(cnxn, issue_ids)
+ issue_map = {}
+ for issue in issues:
+ issue_map[issue.issue_id] = issue
+
+ flag_counts = spam_service.LookUpFlagCounts(cnxn, issue_ids)
+
+ reporter_ids = [issue.reporter_id for issue in issues]
+ reporters = user_service.GetUsersByIDs(cnxn, reporter_ids)
+ comments = issue_service.GetCommentsForIssues(cnxn, issue_ids)
+
+ items = []
+ for item in moderation_items:
+ issue=issue_map[item.issue_id]
+ first_comment = comments.get(item.issue_id, ["[Empty]"])[0]
+
+ items.append(template_helpers.EZTItem(
+ issue=issue,
+ summary=template_helpers.FitUnsafeText(issue.summary, 80),
+ comment_text=template_helpers.FitUnsafeText(first_comment.content, 80),
+ reporter=reporters[issue.reporter_id],
+ flag_count=flag_counts.get(issue.issue_id, 0),
+ is_spam=ezt.boolean(item.is_spam),
+ verdict_time=item.verdict_time,
+ classifier_confidence=item.classifier_confidence,
+ reason=item.reason,
+ ))
+
+ return items
« no previous file with comments | « appengine/monorail/tracker/spam.py ('k') | appengine/monorail/tracker/tablecell.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698