Skip to content

Commit

Permalink
add sensor app
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmolony committed Dec 18, 2023
1 parent f15d2d7 commit b19e1c0
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@
# Application definition

INSTALLED_APPS = [

# Builtin
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

# Custom
'sensor'
]

MIDDLEWARE = [
Expand Down
Empty file added sensor/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions sensor/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions sensor/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class SensorConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'sensor'
26 changes: 26 additions & 0 deletions sensor/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 5.0 on 2023-12-18 13:26

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
]

operations = [
migrations.RunSQL(
"""
CREATE TABLE sensor_reading (
timestamp TIMESTAMP NOT NULL,
sensor_name TEXT NOT NULL,
reading FLOAT NOT NULL,
PRIMARY KEY (timestamp, sensor_name)
);
SELECT create_hypertable('sensor_reading', 'timestamp');
""",
reverse_sql="""
DROP TABLE sensor_reading;
"""
),
]
Empty file added sensor/migrations/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions sensor/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.db import models

# Create your models here.
class Reading(models.Model):
timestamp = models.DateTimeField(blank=False, null=False)
sensor_name = models.TextField(blank=False, null=False)
reading = models.FloatField(blank=False, null=False)

class Meta:
managed = False
3 changes: 3 additions & 0 deletions sensor/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions sensor/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.

0 comments on commit b19e1c0

Please sign in to comment.