aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-06-05 17:50:03 +0100
committerMichael Wood <michael.g.wood@intel.com>2015-06-05 17:50:03 +0100
commit9012266f7fcfcce45b0f9485b6d1c7575576209d (patch)
tree38748179130d358dff4fffaa61fc48a73b5d166f
parentf66d78b26ab4d88c0c00ea6b1f2f8897daca852a (diff)
downloaderror-report-web-9012266f7fcfcce45b0f9485b6d1c7575576209d.tar.gz
error-report-web-9012266f7fcfcce45b0f9485b6d1c7575576209d.tar.bz2
error-report-web-9012266f7fcfcce45b0f9485b6d1c7575576209d.zip
models: Fail gracefully if we haven't yet generated LEV_DISTANCE data
This can can happen if the data hasn't been generated by the migration yet or if this has been skipped. Signed-off-by: Michael Wood <michael.g.wood@intel.com>
-rw-r--r--Post/models.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Post/models.py b/Post/models.py
index d4a39b9..d1bae38 100644
--- a/Post/models.py
+++ b/Post/models.py
@@ -35,6 +35,9 @@ class BuildFailure(models.Model):
LEV_DISTANCE = models.IntegerField(blank=True, null=True)
def get_similar_fails(self):
+ if self.LEV_DISTANCE is None:
+ return BuildFailure.objects.none()
+
start = self.LEV_DISTANCE
end = self.LEV_DISTANCE + settings.SIMILAR_FAILURE_DISTANCE
@@ -43,11 +46,12 @@ class BuildFailure(models.Model):
return query_set
def get_similar_fails_count(self, count=False):
+
return self.get_similar_fails().count()
def calc_lev_distance(self):
if BuildFailure.objects.all().count() == 0:
- return 0
+ return 0
# Use the last 400 characters of the ERROR_DETAILS.
# This is where the error message is likely to occour and