Skip to content

Commit

Permalink
fixing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Korzhak committed Apr 22, 2019
1 parent 1347d47 commit 6e331af
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions thermostat_web/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions ts/migrations/0004_auto_20190422_1445.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
3 changes: 2 additions & 1 deletion ts/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils import timezone
from django.db import models


Expand All @@ -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}" \
Expand Down
9 changes: 8 additions & 1 deletion ts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6e331af

Please sign in to comment.