Add management command to reset and update Hiccup statistics

Introduce a new management command `stats` that allows to reset and
update the Hiccup statistics easily. Resetting the statistics means
removing all of them and computing them again. Updating the statistics
means resuming counting from the last timestamp. To that end, a new
model `StatsMetadata` is created to hold the last known timestamp the
statistics were computed at.

The `stats` command is meant to be run at regular intervals. For example
with `cron`:

    0 0,6,12,18 * * * python /path/to/hiccup/manage.py stats update

FIXME:
    The counting algorithm drops duplicates based on their timestamp to
    avoid duplicate heartbeats. The true deduplication should happen on
    (`device_id`, `date`) instead. Better yet, the database should be
    cleared of those duplicates altogether.

Issue: HIC-112
Change-Id: I975c896bddbc1308d156f0dbd90d0b66d2d5529b
diff --git a/crashreport_stats/models.py b/crashreport_stats/models.py
index f1ae31b..16ccb51 100644
--- a/crashreport_stats/models.py
+++ b/crashreport_stats/models.py
@@ -31,8 +31,8 @@
 
     is_official_release = models.BooleanField(default=False)
     is_beta_release = models.BooleanField(default=False)
-    first_seen_on = models.DateField(auto_now_add=True)
-    released_on = models.DateField(auto_now_add=True)
+    first_seen_on = models.DateField()
+    released_on = models.DateField()
     heartbeats = models.IntegerField(default=0)
     prob_crashes = models.IntegerField(default=0)
     smpl = models.IntegerField(default=0)
@@ -61,7 +61,7 @@
 
     """
 
-    date = models.DateField(auto_now_add=True)
+    date = models.DateField()
     heartbeats = models.IntegerField(default=0)
     prob_crashes = models.IntegerField(default=0)
     smpl = models.IntegerField(default=0)
@@ -127,3 +127,15 @@
     version = models.ForeignKey(
         RadioVersion, db_index=True, related_name='daily_stats',
         on_delete=models.CASCADE)
+
+
+class StatsMetadata(models.Model):
+    """The stats metadata.
+
+    Attributes:
+        updated_at (models.DateTimeField): The last time the stats were
+            updated.
+
+    """
+
+    updated_at = models.DateTimeField()