Closed ajrbyers closed 9 years ago
In issue https://github.com/ajrbyers/mondroid/issues/4 I describe a magical (undefined) function that returns the datastructure we would need to do these sorts of calculations. Because that information can be derived from the data in the database, it shouldn't really be stored in the database. Like storing a person's age rather than their date of birth.
I'll write an implementation tomorrow illustrating what I mean. I'm thinking it might even be possible to get a similar datastructure using raw SQL and aggregates.
Luke to implement magic function:
downtime_between(now, then) ... [[<Check 2014-12-05 21:05>, <Check 2014-12-05 21:00>, <Check 2014-12-05 20:55> ...], ... [<Check 2014-12-05 20:05>, <Check 2014-12-05 20:10>], ... [...]]
I have a couple of ideas scratched out for this and a third one just popped into my head while considering what I've done for the 'time in state' function now attached to the Monitor model.
I'm closing this issue as the original premise is gone and the function being considered above is should be addressed as part of https://github.com/ajrbyers/mondroid/issues/7
Replace the DownTime model with a status model that groups up times and downtimes together something along the lines of:
These could be created by the management command reading in the checks from the fetcher log (a la https://github.com/ajrbyers/mondroid/issues/9) and are simply created when the status_code alternates between up and down. We can then display on the dashboard UP and DOWN periods very simply.
We could also record the Checks in-between, or we can assume that the checks are part of that particular status