Merge branch 'main' into avm99963-monorail

Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266

GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/api/issues_servicer.py b/api/issues_servicer.py
index 1cdfeca..9b6de13 100644
--- a/api/issues_servicer.py
+++ b/api/issues_servicer.py
@@ -1,7 +1,6 @@
-# Copyright 2018 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# Copyright 2018 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
 
 from __future__ import print_function
 from __future__ import division
@@ -25,7 +24,8 @@
 from framework import framework_constants
 from framework import framework_views
 from framework import permissions
-from proto import tracker_pb2
+from framework import sorting
+from mrproto import tracker_pb2
 from search import searchpipeline
 from tracker import field_helpers
 from tracker import tracker_bizobj
@@ -126,7 +126,8 @@
 
     with work_env.WorkEnv(mc, self.services) as we:
       related_refs = we.GetRelatedIssueRefs([issue])
-
+      migrated_id = we.GetIssueMigratedID(
+        issue_ref.project_name, issue_ref.local_id)
     with mc.profiler.Phase('making user views'):
       users_involved_in_issue = tracker_bizobj.UsersInvolvedInIssues([issue])
       users_by_id = framework_views.MakeAllUserViews(
@@ -137,7 +138,7 @@
     with mc.profiler.Phase('converting to response objects'):
       response = issues_pb2.IssueResponse()
       response.issue.CopyFrom(converters.ConvertIssue(
-          issue, users_by_id, related_refs, config))
+          issue, users_by_id, related_refs, config, migrated_id))
 
     return response
 
@@ -586,14 +587,15 @@
     if request.group_by == 'owner':
       # Map user ids to emails.
       snapshot_counts = [
-        issues_pb2.IssueSnapshotCount(
-          dimension=self.services.user.GetUser(mc.cnxn, key).email,
-          count=result) for key, result in results.iteritems()
+          issues_pb2.IssueSnapshotCount(
+              dimension=self.services.user.GetUser(mc.cnxn, key).email,
+              count=result)
+          for key, result in sorted(results.items(), key=sorting.Python2Key)
       ]
     else:
       snapshot_counts = [
-        issues_pb2.IssueSnapshotCount(dimension=key, count=result)
-          for key, result in results.items()
+          issues_pb2.IssueSnapshotCount(dimension=key, count=result)
+          for key, result in sorted(results.items(), key=sorting.Python2Key)
       ]
     response = issues_pb2.IssueSnapshotResponse()
     response.snapshot_count.extend(snapshot_counts)