Delete unused code and empty file
The util.py functions have been replaced by the stats management
command. The 'fill_in_build_fingerprints' function of raw_queries.py
is never called.
Issue: HIC-170
Change-Id: Ifc46582fb08fd6462f2cafbca0a47c82692f2e15
diff --git a/crashreport_stats/raw_querys.py b/crashreport_stats/raw_querys.py
index a71a346..8d8c77d 100644
--- a/crashreport_stats/raw_querys.py
+++ b/crashreport_stats/raw_querys.py
@@ -1,29 +1,6 @@
from django.conf import settings
-class FormatDict(dict):
- def __missing__(self, key):
- return "{" + key + "}"
-
-
-def fill_in_build_fingerprints(query, build_fingerprints):
- all_fingerprints_query = (
- "select distinct build_fingerprint from crashreports_crashreport"
- )
- if len(build_fingerprints) > 0:
- return query.format(
- FormatDict(
- fingerprint_placeholers=",".join(
- ["%s"] * len(build_fingerprints)
- )
- )
- )
- else:
- return query.format(
- FormatDict(fingerprint_placeholers=all_fingerprints_query)
- )
-
-
def execute_device_update_history_query(cursor, params):
if (
settings.DATABASES["default"]["ENGINE"]
diff --git a/crashreport_stats/util.py b/crashreport_stats/util.py
deleted file mode 100644
index a2111f7..0000000
--- a/crashreport_stats/util.py
+++ /dev/null
@@ -1,88 +0,0 @@
-from django.db import migrations, models
-import django.db.models.deletion
-
-from django.db import connection
-from datetime import date, timedelta
-
-from . import models as myModels
-
-from django.db import transaction
-
-
-def dictfetchall(cursor):
- "Returns all rows from a cursor as a dict"
- desc = cursor.description
- return [
- dict(zip([col[0] for col in desc], row)) for row in cursor.fetchall()
- ]
-
-
-@transaction.atomic
-def fill_version_data():
- myModels.Version.objects.all().delete()
- query = """
- SELECT fingerprint as build_fingerprint,
- ( select count(id) from crashreports_crashreport where boot_reason in ("RTC alarm") and crashreports_crashreport.build_fingerprint = fingerprint) as SMPL,
- ( select count(id) from crashreports_crashreport where boot_reason in ("UNKNOWN", "keyboard power on") and crashreports_crashreport.build_fingerprint = fingerprint) as prob_crashes,
- ( select count(id) from crashreports_crashreport where boot_reason not in ("RTC alarm", "UNKNOWN", "keyboard power on") and crashreports_crashreport.build_fingerprint = fingerprint) as other,
- ( select count(id) from crashreports_heartbeat where crashreports_heartbeat.build_fingerprint = fingerprint) as heartbeats,
- ( select min(crashreports_heartbeat.created_at) from crashreports_heartbeat where crashreports_heartbeat.build_fingerprint = fingerprint) as first_seen
- from (select distinct(build_fingerprint) as fingerprint
- from crashreports_heartbeat) group by fingerprint order by heartbeats;"""
- cursor = connection.cursor()
- cursor.execute(query, [])
- desc = cursor.description
- for row in cursor.fetchall():
- i = dict(zip([col[0] for col in desc], row))
- version = myModels.Version(
- build_fingerprint=i["build_fingerprint"],
- first_seen_on=i["first_seen"].split()[0],
- released_on=i["first_seen"].split()[0],
- heartbeats=i["heartbeats"],
- prob_crashes=i["prob_crashes"],
- smpl=i["SMPL"],
- other=i["other"],
- )
- version.save()
-
-
-@transaction.atomic
-def fill_version_daily_data():
- myModels.VersionDaily.objects.all().delete()
- query = """
- SELECT build_fingerprint, count(id) as heartbeats,
- strftime("%%Y-%%m-%%d",crashreports_heartbeat.date) as date,
- ( select count(id) from crashreports_crashreport where boot_reason in ("RTC alarm") and crashreports_crashreport.build_fingerprint = crashreports_heartbeat.build_fingerprint and crashreports_crashreport.date >= %s and crashreports_crashreport.date < %s) as SMPL,
- ( select count(id) from crashreports_crashreport where boot_reason in ("UNKNOWN", "keyboard power on") and crashreports_crashreport.build_fingerprint = crashreports_heartbeat.build_fingerprint and crashreports_crashreport.date >= %s and crashreports_crashreport.date < %s) as prob_crashes,
- ( select count(id) from crashreports_crashreport where boot_reason not in ("RTC alarm", "UNKNOWN", "keyboard power on") and crashreports_crashreport.build_fingerprint = crashreports_heartbeat.build_fingerprint and crashreports_crashreport.date >= %s and crashreports_crashreport.date < %s) as other
- from crashreports_heartbeat where crashreports_heartbeat.date >= %s and crashreports_heartbeat.date < %s
- group by build_fingerprint"""
- start = date(2016, 8, 1)
- end = date.today() + timedelta(days=5)
- delta = end - start
- for d in range(delta.days + 1):
- day = start + timedelta(days=d)
- print("Getting Stats for " + str(day))
- cursor = connection.cursor()
- cursor.execute(query, [str(day), str(day + timedelta(days=1))] * 4)
- desc = cursor.description
- for row in cursor.fetchall():
- i = dict(zip([col[0] for col in desc], row))
- try:
- version_daily = myModels.VersionDaily(
- version=myModels.Version.objects.get(
- build_fingerprint=i["build_fingerprint"]
- ),
- heartbeats=i["heartbeats"],
- date=day,
- prob_crashes=i["prob_crashes"],
- smpl=i["SMPL"],
- other=i["other"],
- )
- except:
- print(
- "Skipping entry for {} {}".format(
- i["build_fingerprint"], day
- )
- )
- version_daily.save()
diff --git a/crashreports/forms.py b/crashreports/forms.py
deleted file mode 100644
index e69de29..0000000
--- a/crashreports/forms.py
+++ /dev/null