Changeset 238529 in webkit
- Timestamp:
- Nov 26, 2018 4:21:37 PM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/BuildSlaveSupport/ews-app/ews/models/patch.py
r238517 r238529 23 23 from __future__ import unicode_literals 24 24 25 import logging 26 25 27 from django.db import models 28 29 from ews.config import * 30 31 _log = logging.getLogger(__name__) 26 32 27 33 28 34 class Patch(models.Model): 29 patch id = models.IntegerField(primary_key=True)30 bug id = models.IntegerField()35 patch_id = models.IntegerField(primary_key=True) 36 bug_id = models.IntegerField() 31 37 obsolete = models.BooleanField(default=False) 32 38 created = models.DateTimeField(auto_now_add=True) … … 34 40 35 41 def __str__(self): 36 return str(self.patchid) 42 return str(self.patch_id) 43 44 @classmethod 45 def save_patch(cls, patch_id, bug_id=-1, obsolete=False): 46 if not Patch.is_valid_patch_id(patch_id): 47 return ERR_INVALID_PATCH_ID 48 49 if Patch.is_existing_patch_id(patch_id): 50 _log.info("Patch id {} already exists in database. Skipped saving.".format(patch_id)) 51 return ERR_EXISTING_PATCH 52 Patch(patch_id, bug_id, obsolete).save() 53 _log.info('Saved patch in database, id: {}'.format(patch_id)) 54 return SUCCESS 55 56 @classmethod 57 def save_patches(cls, patch_id_list): 58 for patch_id in patch_id_list: 59 Patch.save_patch(patch_id) 60 61 @classmethod 62 def is_valid_patch_id(cls, patch_id): 63 if not patch_id or type(patch_id) != int or patch_id < 1: 64 _log.warn('Invalid patch id: {}'.format(patch_id)) 65 return False 66 return True 67 68 @classmethod 69 def is_existing_patch_id(cls, patch_id): 70 return bool(Patch.objects.filter(patch_id=patch_id)) -
trunk/Tools/ChangeLog
r238527 r238529 1 2018-11-26 Aakash Jain <aakash_jain@apple.com> 2 3 [ews-app] Add methods to save patch to database 4 https://bugs.webkit.org/show_bug.cgi?id=191928 5 6 Reviewed by Lucas Forschler. 7 8 * BuildSlaveSupport/ews-app/ews/models/patch.py: 9 (Patch.save_patch): Method to save the patch to database. 10 (Patch.save_patches): Method to save multiple patches to database. 11 (Patch.is_valid_patch_id): Checks if the patch id is valid. 12 (Patch.is_existing_patch_id): Checks if the patch id already exists in database. 13 1 14 2018-11-26 Alex Christensen <achristensen@webkit.org> 2 15
Note: See TracChangeset
for help on using the changeset viewer.