| OLD | NEW |
| 1 # Copyright 2008 Google Inc. | 1 # Copyright 2008 Google Inc. |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 return message.date | 497 return message.date |
| 498 return None | 498 return None |
| 499 | 499 |
| 500 def get_time_since_landed(self): | 500 def get_time_since_landed(self): |
| 501 """Returns approximate time since issue was landed or None.""" | 501 """Returns approximate time since issue was landed or None.""" |
| 502 landed = self.get_landed_date() | 502 landed = self.get_landed_date() |
| 503 if landed: | 503 if landed: |
| 504 return datetime.datetime.now() - landed | 504 return datetime.datetime.now() - landed |
| 505 return None | 505 return None |
| 506 | 506 |
| 507 def update_cq_status_url_if_any(self, cq_message): |
| 508 """Parses the cq_message for CQ status url and updates corresponding |
| 509 patchset with it. |
| 510 """ |
| 511 url, issue_num, patchset_num = utils.parse_cq_status_url_message(cq_message) |
| 512 if not url: |
| 513 return |
| 514 if self.key.id() != issue_num: |
| 515 logging.error('CQ posted CQ Status URL %s to the wrong issue %s', |
| 516 url, self.key.id()) |
| 517 return |
| 518 for patchset in self.patchsets: |
| 519 if patchset.key.id() == patchset_num: |
| 520 patchset.cq_status_url = url |
| 521 patchset.put() |
| 522 logging.info('saved cq_status_url %s to patchset %s', url, patchset.key) |
| 523 return |
| 524 logging.error('CQ posted CQ Status URL %s with unrecognized patchset %s', |
| 525 url, patchset_num) |
| 526 |
| 527 |
| 507 | 528 |
| 508 def can_skip_checks_on_revert(landed_age): | 529 def can_skip_checks_on_revert(landed_age): |
| 509 """Returns whether CQ checks on revert can be skipped.""" | 530 """Returns whether CQ checks on revert can be skipped.""" |
| 510 if landed_age is None: | 531 if landed_age is None: |
| 511 return False | 532 return False |
| 512 return landed_age < REVERT_MAX_AGE_FOR_CHECKS_BYPASSING | 533 return landed_age < REVERT_MAX_AGE_FOR_CHECKS_BYPASSING |
| 513 | 534 |
| 514 | 535 |
| 515 def _calculate_delta(patch, patchset_id, patchsets): | 536 def _calculate_delta(patch, patchset_id, patchsets): |
| 516 """Calculates which files in earlier patchsets this file differs from. | 537 """Calculates which files in earlier patchsets this file differs from. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 data = ndb.BlobProperty() | 680 data = ndb.BlobProperty() |
| 660 url = ndb.StringProperty() | 681 url = ndb.StringProperty() |
| 661 created = ndb.DateTimeProperty(auto_now_add=True) | 682 created = ndb.DateTimeProperty(auto_now_add=True) |
| 662 modified = ndb.DateTimeProperty(auto_now=True) | 683 modified = ndb.DateTimeProperty(auto_now=True) |
| 663 n_comments = ndb.IntegerProperty(default=0) | 684 n_comments = ndb.IntegerProperty(default=0) |
| 664 # TODO(maruel): Deprecated, remove once the live instance has all its data | 685 # TODO(maruel): Deprecated, remove once the live instance has all its data |
| 665 # converted to TryJobResult instances. | 686 # converted to TryJobResult instances. |
| 666 build_results = ndb.StringProperty(repeated=True) | 687 build_results = ndb.StringProperty(repeated=True) |
| 667 depends_on_patchset = ndb.StringProperty() | 688 depends_on_patchset = ndb.StringProperty() |
| 668 dependent_patchsets = ndb.StringProperty(repeated=True) | 689 dependent_patchsets = ndb.StringProperty(repeated=True) |
| 690 cq_status_url = ndb.StringProperty() |
| 669 | 691 |
| 670 @property | 692 @property |
| 671 def depends_on_tokens(self): | 693 def depends_on_tokens(self): |
| 672 tokens = None | 694 tokens = None |
| 673 if self.depends_on_patchset: | 695 if self.depends_on_patchset: |
| 674 issue_id, patchset_id = self.depends_on_patchset.split(':') | 696 issue_id, patchset_id = self.depends_on_patchset.split(':') |
| 675 issue = Issue.get_by_id(int(issue_id)) | 697 issue = Issue.get_by_id(int(issue_id)) |
| 676 patchset = PatchSet.get_by_id(int(patchset_id), parent=issue.key) | 698 patchset = PatchSet.get_by_id(int(patchset_id), parent=issue.key) |
| 677 tokens = (issue, patchset) | 699 tokens = (issue, patchset) |
| 678 return tokens | 700 return tokens |
| (...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1907 out.issues = sum((i.issues for i in items), []) | 1929 out.issues = sum((i.issues for i in items), []) |
| 1908 out.latencies = sum((i.latencies for i in items), []) | 1930 out.latencies = sum((i.latencies for i in items), []) |
| 1909 out.lgtms = sum((i.lgtms for i in items), []) | 1931 out.lgtms = sum((i.lgtms for i in items), []) |
| 1910 out.review_types = sum((i.review_types for i in items), []) | 1932 out.review_types = sum((i.review_types for i in items), []) |
| 1911 out.score = compute_score(out) | 1933 out.score = compute_score(out) |
| 1912 return ( | 1934 return ( |
| 1913 prev_issues != out.issues or | 1935 prev_issues != out.issues or |
| 1914 prev_latencies != out.latencies or | 1936 prev_latencies != out.latencies or |
| 1915 prev_lgtms != out.lgtms or | 1937 prev_lgtms != out.lgtms or |
| 1916 prev_review_types != out.review_types) | 1938 prev_review_types != out.review_types) |
| OLD | NEW |