[ews] Display status-bubble for try builds (builds for specific ews queues)
https://bugs.webkit.org/show_bug.cgi?id=235679

Reviewed by Jonathan Bedard.

* Tools/CISupport/ews-app/ews/models/build.py:
(Build.save_build): Save the patch information in database.
* Tools/CISupport/ews-app/ews/views/statusbubble.py:
(StatusBubble._build_bubble):
(StatusBubble._should_show_bubble_for_build):
(StatusBubble._build_bubbles_for_patch):

Canonical link: https://commits.webkit.org/246479@main

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288673 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/CISupport/ews-app/ews/models/build.py b/Tools/CISupport/ews-app/ews/models/build.py
index 244ba02..7d47f46 100644
--- a/Tools/CISupport/ews-app/ews/models/build.py
+++ b/Tools/CISupport/ews-app/ews/models/build.py
@@ -65,6 +65,10 @@
             # If the build data is already present in database, update it, e.g.: build complete event.
             return Build.update_build(build, patch_id, uid, builder_id, builder_name, builder_display_name, number, result, state_string, started_at, complete_at)
 
+        if not Patch.is_existing_patch_id(patch_id):
+            Patch.save_patch(patch_id)
+            _log.info('Received result for unknown patch. Saved patch {} to database'.format(patch_id))
+
         # Save the new build data, e.g.: build start event.
         Build(patch_id, uid, builder_id, builder_name, builder_display_name, number, result, state_string, started_at, complete_at).save()
         _log.info('Saved build {} in database for patch_id: {}'.format(uid, patch_id))
diff --git a/Tools/CISupport/ews-app/ews/views/statusbubble.py b/Tools/CISupport/ews-app/ews/views/statusbubble.py
index ac1f629..5af13f1 100644
--- a/Tools/CISupport/ews-app/ews/views/statusbubble.py
+++ b/Tools/CISupport/ews-app/ews/views/statusbubble.py
@@ -80,7 +80,7 @@
     BUILD_RETRY_MSG = 'retrying build'
     UNKNOWN_QUEUE_POSITION = '?'
 
-    def _build_bubble(self, patch, queue, hide_icons=False):
+    def _build_bubble(self, patch, queue, hide_icons=False, sent_to_buildbot=True):
         bubble = {
             'name': queue,
         }
@@ -97,7 +97,7 @@
         if builds:
             build = builds[0]
             builds = builds[:10]  # Limit number of builds to display in status-bubble hover over message
-        if not self._should_show_bubble_for_build(build):
+        if not self._should_show_bubble_for_build(build, sent_to_buildbot):
             return None
 
         if not build:
@@ -292,9 +292,11 @@
                 failed_builds.append(build)
         return failed_builds
 
-    def _should_show_bubble_for_build(self, build):
+    def _should_show_bubble_for_build(self, build, sent_to_buildbot=True):
         if build and build.result == Buildbot.SKIPPED and re.search(r'Patch .* doesn\'t have relevant changes', build.state_string):
             return False
+        if (not build) and (not sent_to_buildbot):
+            return False
         return True
 
     def _queue_position(self, patch, queue, parent_queue=None):
@@ -342,14 +344,12 @@
         if not patch:
             return (None, show_submit_to_ews, failed_to_apply, show_retry)
 
-        if patch.sent_to_buildbot:
-            for queue in StatusBubble.ALL_QUEUES:
-                bubble = self._build_bubble(patch, queue, hide_icons)
-                if bubble:
-                    show_submit_to_ews = False
-                    bubbles.append(bubble)
-                    if bubble['state'] in ('fail', 'error'):
-                        show_retry = True
+        for queue in StatusBubble.ALL_QUEUES:
+            bubble = self._build_bubble(patch, queue, hide_icons, patch.sent_to_buildbot)
+            if bubble:
+                bubbles.append(bubble)
+                if bubble['state'] in ('fail', 'error'):
+                    show_retry = True
 
         if patch.sent_to_commit_queue:
             if not patch.sent_to_buildbot:
@@ -358,6 +358,7 @@
             if cq_bubble:
                 bubbles.insert(0, cq_bubble)
 
+        show_submit_to_ews = not patch.sent_to_buildbot
         return (bubbles, show_submit_to_ews, failed_to_apply, show_retry)
 
     @xframe_options_exempt