[ews-app] Remove BuilderMapping table
authoraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Feb 2019 02:52:33 +0000 (02:52 +0000)
committeraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Feb 2019 02:52:33 +0000 (02:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194961

Reviewed by Stephanie Lewis.

Store builder name directly in build table, instead of having a separate
table for it.

* BuildSlaveSupport/ews-app/ews/models/__init__.py:
* BuildSlaveSupport/ews-app/ews/models/build.py:
* BuildSlaveSupport/ews-app/ews/models/buildermapping.py: Removed.
* BuildSlaveSupport/ews-app/ews/views/statusbubble.py:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242065 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/BuildSlaveSupport/ews-app/ews/models/__init__.py
Tools/BuildSlaveSupport/ews-app/ews/models/build.py
Tools/BuildSlaveSupport/ews-app/ews/models/buildermapping.py [deleted file]
Tools/BuildSlaveSupport/ews-app/ews/views/statusbubble.py
Tools/ChangeLog

index 8d5f218..2de7a64 100644 (file)
@@ -1,4 +1,3 @@
-from buildermapping import *
 from build import *
 from patch import *
 from step import *
index 7b3052c..3f62ba8 100644 (file)
@@ -26,7 +26,6 @@ import logging
 
 from django.db import models
 from ews.config import ERR_UNEXPECTED, SUCCESS
-from ews.models.buildermapping import BuilderMapping
 from ews.models.patch import Patch
 import ews.common.util as util
 
@@ -36,7 +35,9 @@ _log = logging.getLogger(__name__)
 class Build(models.Model):
     patch = models.ForeignKey(Patch, on_delete=models.CASCADE)
     build_id = models.IntegerField(primary_key=True)
-    builder = models.ForeignKey(BuilderMapping, on_delete=models.DO_NOTHING)
+    builder_id = models.IntegerField()
+    builder_name = models.TextField()
+    builder_display_name = models.TextField()
     number = models.IntegerField()
     result = models.IntegerField(null=True, blank=True)
     state_string = models.TextField()
diff --git a/Tools/BuildSlaveSupport/ews-app/ews/models/buildermapping.py b/Tools/BuildSlaveSupport/ews-app/ews/models/buildermapping.py
deleted file mode 100644 (file)
index 84f32ff..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-# Copyright (C) 2018-2019 Apple Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1.  Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 2.  Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
-# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-from __future__ import unicode_literals
-
-import logging
-
-from django.db import models
-from ews.config import ERR_UNEXPECTED, SUCCESS
-import ews.common.util as util
-
-_log = logging.getLogger(__name__)
-
-
-class BuilderMapping(models.Model):
-    builder_id = models.IntegerField(primary_key=True)
-    builder_name = models.TextField()
-    display_name = models.TextField()
-    created = models.DateTimeField(auto_now_add=True)
-    modified = models.DateTimeField(auto_now=True)
-
-    def __str__(self):
-        return "{}: {}".format(self.builder_id, self.display_name)
-
-    @classmethod
-    def save_mapping(cls, builder_id, builder_name, display_name):
-        if not BuilderMapping.is_valid_mapping(builder_id, builder_name, display_name):
-            return ERR_UNEXPECTED
-
-        mapping = BuilderMapping.get_existing_mapping(builder_id)
-        if mapping:
-            # If the mapping is updated, e.g.: display name changed.
-            return BuilderMapping.update_mapping(mapping, builder_id, builder_name, display_name)
-
-        BuilderMapping(builder_id, builder_name, display_name).save()
-        _log.info('Saved mapping for builder_id: {}, name: {}, display_name: {}'.format(builder_id, builder_name, display_name))
-        return SUCCESS
-
-    @classmethod
-    def update_mapping(cls, mapping, builder_id, builder_name, display_name):
-        if mapping.builder_id != builder_id:
-            _log.error('builder_id {} does not match with builder_id {}. Ignoring new data.'.format(mapping.builder_id, builder_id))
-            return ERR_UNEXPECTED
-
-        if mapping.builder_name == builder_name and mapping.display_name == display_name:
-            _log.debug('Mapping already exist for builder_id: {}'.format(builder_id))
-            return SUCCESS
-
-        mapping.builder_name = builder_name
-        mapping.display_name = display_name
-        mapping.save(update_fields=['builder_name', 'display_name', 'modified'])
-        _log.info('Updated mapping for builder_id: {}, name: {}, display_name: {}'.format(builder_id, builder_name, display_name))
-        return SUCCESS
-
-    @classmethod
-    def get_existing_mapping(cls, builder_id):
-        try:
-            return BuilderMapping.objects.get(builder_id=builder_id)
-        except:
-            return None
-
-    @classmethod
-    def is_valid_mapping(cls, builder_id, builder_name, display_name):
-        if not util.is_valid_id(builder_id):
-            return False
-        return True
index 1a7e633..18fa4b3 100644 (file)
@@ -26,19 +26,14 @@ from django.http import HttpResponse
 from django.shortcuts import render
 from django.views import View
 from django.views.decorators.clickjacking import xframe_options_exempt
-from ews.models.buildermapping import BuilderMapping
 from ews.models.patch import Patch
 import ews.config as config
 
 
 class StatusBubble(View):
     def _build_bubble(self, build, patch):
-        try:
-            builder_display_name = build.builder.display_name
-            builder_full_name = build.builder.builder_name
-        except BuilderMapping.DoesNotExist:
-            builder_display_name = build.builder_id
-            builder_full_name = ''
+        builder_display_name = build.builder_display_name
+        builder_full_name = build.builder_name
 
         bubble = {
             "name": builder_display_name,
index 72bfb65..09bd6ba 100644 (file)
@@ -1,3 +1,18 @@
+2019-02-25  Aakash Jain  <aakash_jain@apple.com>
+
+        [ews-app] Remove BuilderMapping table
+        https://bugs.webkit.org/show_bug.cgi?id=194961
+
+        Reviewed by Stephanie Lewis.
+
+        Store builder name directly in build table, instead of having a separate
+        table for it.
+
+        * BuildSlaveSupport/ews-app/ews/models/__init__.py:
+        * BuildSlaveSupport/ews-app/ews/models/build.py:
+        * BuildSlaveSupport/ews-app/ews/models/buildermapping.py: Removed.
+        * BuildSlaveSupport/ews-app/ews/views/statusbubble.py:
+
 2019-02-25  John Wilander  <wilander@apple.com>
 
         Introduce and adopt new class RegistrableDomain for eTLD+1