diff --git a/thermostat_web/settings.py b/thermostat_web/settings.py index b2fabcb..b20ec7d 100644 --- a/thermostat_web/settings.py +++ b/thermostat_web/settings.py @@ -108,13 +108,13 @@ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'UTC' +TIME_ZONE = 'EET' USE_I18N = True USE_L10N = True -USE_TZ = True +USE_TZ = False # Static files (CSS, JavaScript, Images) diff --git a/ts/migrations/0004_auto_20190422_1445.py b/ts/migrations/0004_auto_20190422_1445.py new file mode 100644 index 0000000..0f9bda5 --- /dev/null +++ b/ts/migrations/0004_auto_20190422_1445.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2 on 2019-04-22 14:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ts', '0003_auto_20190421_2303'), + ] + + operations = [ + migrations.AlterField( + model_name='logthermostat', + name='time', + field=models.DateTimeField(auto_now_add=True), + ), + ] diff --git a/ts/models.py b/ts/models.py index e895968..54484c2 100644 --- a/ts/models.py +++ b/ts/models.py @@ -1,3 +1,4 @@ +from django.utils import timezone from django.db import models @@ -17,7 +18,7 @@ class LogThermostat(models.Model): light_G = models.IntegerField("G", default=0) light_B = models.IntegerField("B", default=0) - time = models.DateTimeField(auto_now=True) + time = models.DateTimeField(auto_now_add=True) def __str__(self): return f"{self.time.strftime('%Y-%m-%d %H:%M:%S')} | State: {'On' if self.thermostat_state else 'Off'} | t: {self.temp}" \ diff --git a/ts/views.py b/ts/views.py index a42dbc9..33037ec 100644 --- a/ts/views.py +++ b/ts/views.py @@ -29,5 +29,12 @@ def get_queryset(self): start_date = datetime.today() - timedelta(days=1) end_date = datetime.now() - return LogThermostat.objects.filter(time__range=(start_date, end_date)) + data = LogThermostat.objects.filter(time__range=(start_date, end_date)) + if len(data) >= 30: + step = len(data) // 30 + buff = 0 + while buff <= len(data): + if buff % step: + data.e + return