diff --git a/heima/sherlock/models.py b/heima/sherlock/models.py index 0d31e3d..e19c06d 100644 --- a/heima/sherlock/models.py +++ b/heima/sherlock/models.py @@ -21,10 +21,21 @@ class Gauge(models.Model): class DiffMeasure(object): + """Takes two measures and compute the differences between them. + + Attribues: + increase (decimal): the increase between the lowest value and the highest. + timedelta (timespan): the elapsed time between the two values. + """ def __init__(self, measure_1, measure_2): self.increase = abs(measure_1.diff(measure_2)) self.timedelta = abs(measure_1.moment - measure_2.moment) + def daily_average_increase(self): + """Returns the daily average increase, based on the two initial measures. + """ + return self.increase / self.timedelta.days + def diff_from_measures(measure1, measure2): """Generate the diff between the two measures.