Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend team - Sprint 2 #135

Merged
merged 92 commits into from Mar 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
5a7c79f
create new database model
Ziheng-Wang Mar 2, 2020
4a70332
create new database model
Ziheng-Wang Mar 3, 2020
067cc33
creating new database models
Ziheng-Wang Mar 3, 2020
73846e5
creating a new database model
Ziheng-Wang Mar 3, 2020
17d712f
new schema
Ricardo-1894 Mar 4, 2020
c1ba900
fix travis
Ricardo-1894 Mar 4, 2020
ddded28
Add black/flake8 configuration
alldne Mar 6, 2020
735cfb5
Fix flake8 issues
alldne Mar 6, 2020
92fe31e
Resolve conflicts on migrations
alldne Mar 6, 2020
b3629a7
Remove settings that force locally running app to use postgres
alldne Mar 6, 2020
e2980ab
Merge pull request #46 from gcivil-nyu-org/backend/develop
VentusXu09 Mar 6, 2020
0fb356d
Update code formatting rules
jackxujh Mar 7, 2020
1eda86f
Remove an obsolete configuration file
jackxujh Mar 7, 2020
018893a
Format existing code
jackxujh Mar 7, 2020
6e6b461
Merge pull request #52 from gcivil-nyu-org/backend/feature/code-forma…
daisycrego Mar 8, 2020
52a4600
Merge branch 'master' into backend/master
daisycrego Mar 8, 2020
74fb9cd
Merge pull request #54 from gcivil-nyu-org/backend/develop
Ricardo-1894 Mar 8, 2020
7f1adae
Add new data model in a new app
jackxujh Mar 8, 2020
775d549
Add serializers for the new data model
jackxujh Mar 8, 2020
56f5ab3
Add test for serializing AGEvent table
jackxujh Mar 8, 2020
8172a28
Add dependencies for data model serializer tests
jackxujh Mar 8, 2020
6bdcffd
Add a simulator to directly write measurements
jackxujh Mar 8, 2020
28d29f9
Format code
jackxujh Mar 8, 2020
688b1ef
Cross check to verify fields in measurements
jackxujh Mar 8, 2020
728a8eb
Format code: simulator.py
jackxujh Mar 8, 2020
6e30d9a
Add simulator tests for all sensor presets
jackxujh Mar 8, 2020
97e1e32
Add simulator tests for batch measurement logging
jackxujh Mar 8, 2020
09d804a
Set up simulator instance in setUp() for testing
jackxujh Mar 8, 2020
1f8e0a8
Add more tests for simulator's methods
jackxujh Mar 8, 2020
b0dde0a
Improve live mersurement simulation
jackxujh Mar 8, 2020
c5d4e00
Merge pull request #57 from gcivil-nyu-org/backend/master
daisycrego Mar 8, 2020
307153c
Add example data dump in ag_data app
jackxujh Mar 8, 2020
382a98d
Add additional data in example dump of ag_data
jackxujh Mar 8, 2020
90da0e1
Merge pull request #55 from gcivil-nyu-org/backend/feature/data-model
daisycrego Mar 9, 2020
83756cc
Merge branch 'backend-team' into backend/develop
jackxujh Mar 9, 2020
bbc63ac
Merge pull request #59 from gcivil-nyu-org/backend/develop
Ricardo-1894 Mar 9, 2020
666a99f
Merge branch 'backend-team' into sync-backend
alldne Mar 9, 2020
c4d72e8
Merge pull request #70 from gcivil-nyu-org/sync-backend
jackxujh Mar 9, 2020
9d4dc99
Add table for event venues
jackxujh Mar 10, 2020
50ac76f
Format code
jackxujh Mar 10, 2020
6f605c2
Fix broken tests and format code
jackxujh Mar 10, 2020
4a449df
Fix a broken test
jackxujh Mar 10, 2020
2ce0c36
Introduce table: Sensor Type
jackxujh Mar 11, 2020
26e3be6
Beautify code
jackxujh Mar 11, 2020
3b2defa
Migrate presets in common.py to presets.py
jackxujh Mar 11, 2020
7c1dddf
Format code
jackxujh Mar 11, 2020
919998c
Update sensor type creation and reset method
jackxujh Mar 11, 2020
dd0fdf6
Format code
jackxujh Mar 11, 2020
2578c93
Update database dump file: data_dump.json
jackxujh Mar 11, 2020
7009b29
Move data model serialization to its own branch
jackxujh Mar 11, 2020
ae975d2
Fix tests for simulator and data model
jackxujh Mar 11, 2020
3866957
Fix assertion in a Simulator test
jackxujh Mar 11, 2020
8cb4ebc
Merge pull request #74 from gcivil-nyu-org/backend/feature/data-model
Ricardo-1894 Mar 11, 2020
3aad582
Change latitude/longitude to DecimalField in db
jackxujh Mar 11, 2020
a690d37
Merge remote-tracking branch 'origin/backend/develop' into backend/fe…
jackxujh Mar 11, 2020
165b193
Fix decimal fields
jackxujh Mar 11, 2020
3e54c33
Refactor data model and rename fields
jackxujh Mar 11, 2020
d9c2174
Rename fields in data model
jackxujh Mar 11, 2020
11f7529
Format code
jackxujh Mar 11, 2020
8bcbf76
Merge pull request #77 from gcivil-nyu-org/backend/feature/data-model
daisycrego Mar 11, 2020
bb1ac51
Update models.py
Ziheng-Wang Mar 11, 2020
599f07d
Update simulator.py
Ziheng-Wang Mar 11, 2020
693125a
Update simulator.py
Ziheng-Wang Mar 11, 2020
830b8a3
Update data model comments
jackxujh Mar 11, 2020
ed97d21
Format code
jackxujh Mar 11, 2020
6b73362
Rename measurement_event to event_uuid in AGMeasurement
jackxujh Mar 11, 2020
d3b0399
Update models.py
Ziheng-Wang Mar 11, 2020
c5d2e65
Merge branch 'backend/develop' into backend/feature/data-model
jackxujh Mar 11, 2020
ee815f7
Add missing quotation marks for comments
jackxujh Mar 11, 2020
bb03a1b
Merge pull request #83 from gcivil-nyu-org/backend/feature/data-model
jackxujh Mar 11, 2020
4229b4b
Merge pull request #78 from gcivil-nyu-org/backend/develop
jackxujh Mar 11, 2020
6e7ed24
remove unused hardware py file
VentusXu09 Mar 11, 2020
5ca8561
Merge pull request #90 from gcivil-nyu-org/backend/feature/remove_unu…
alldne Mar 11, 2020
2a4ebb2
Merge branch 'backend-team' into backend/develop
alldne Mar 11, 2020
98e1b3f
Merge pull request #93 from gcivil-nyu-org/backend/develop
VentusXu09 Mar 11, 2020
68a7ac5
Correct preset names
jackxujh Mar 11, 2020
e1d200b
Improve presets
jackxujh Mar 11, 2020
64f5b33
Fix simulator
jackxujh Mar 11, 2020
f6eea7f
Merge branch 'backend/feature/data-model' into backend/feature-data-m…
jackxujh Mar 14, 2020
08cac57
Add a test for multiple simulator instances
jackxujh Mar 14, 2020
ac7ca59
Merge pull request #126 from gcivil-nyu-org/backend/feature/data-model
Ziheng-Wang Mar 14, 2020
a664a0e
Merge branch 'backend-team' into backend/develop
jackxujh Mar 14, 2020
aba80dc
Resolved conflicts by adding new features from backend/develop to master
Mar 14, 2020
c95e7c2
Resolved conflicts
Mar 14, 2020
5c3a1af
Added migrations
iamvibhorsingh Mar 14, 2020
fe2eea5
Removed trailing whitespaces
iamvibhorsingh Mar 14, 2020
7137d7a
Merge pull request #130 from gcivil-nyu-org/backend-sprint-2
jackxujh Mar 14, 2020
b1912f8
Merge pull request #131 from gcivil-nyu-org/backend/develop
jackxujh Mar 14, 2020
b71de85
Resolved travis conflicts
Mar 14, 2020
a276544
Merge pull request #133 from gcivil-nyu-org/backend-sprint2
alldne Mar 14, 2020
5e240ae
Merge branch 'backend-team' into backend/develop
iamvibhorsingh Mar 14, 2020
fcd6156
Merge pull request #134 from gcivil-nyu-org/backend/develop
Ricardo-1894 Mar 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions .coveralls

This file was deleted.

6 changes: 5 additions & 1 deletion .flake8
@@ -1,3 +1,7 @@
[flake8]
max-line-length = 92
exclude = tests/*
exclude =
.git,
__pycache__,
venv
**/migrations
1 change: 0 additions & 1 deletion .sonarcloud.properties

This file was deleted.

8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -30,11 +30,11 @@ before_script:
- python manage.py collectstatic --noinput

script:
- black . --check
- flake8 --exclude tests mysite/ mercury/
- flake8 --ignore=E501 mercury/tests/
- coverage run --source=mysite,mercury --omit="mercury/migrations/*" manage.py test
- black --check --exclude "migrations/" mysite mercury ag_data
- flake8 mysite/ mercury/ ag_data/
- coverage run --source=mysite,mercury,ag_data --omit="migrations/*" manage.py test

after_script:
- coveralls
- cat geckodriver.log

Empty file added ag_data/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions ag_data/apps.py
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class AgDataConfig(AppConfig):
name = "ag_data"
Empty file added ag_data/examples/data_dump.json
Empty file.
69 changes: 69 additions & 0 deletions ag_data/migrations/0001_initial.py
@@ -0,0 +1,69 @@
# Generated by Django 2.2.11 on 2020-03-11 00:36

import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import uuid


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='AGEvent',
fields=[
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('name', models.CharField(blank=True, max_length=40)),
('date', models.DateTimeField(default=django.utils.timezone.now)),
('description', models.CharField(blank=True, max_length=100)),
],
),
migrations.CreateModel(
name='AGSensorType',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(blank=True, max_length=1024)),
('processing_formula', models.IntegerField(default=0)),
('format', django.contrib.postgres.fields.jsonb.JSONField()),
],
),
migrations.CreateModel(
name='AGVenue',
fields=[
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('name', models.CharField(blank=True, max_length=100)),
('description', models.CharField(blank=True, max_length=100)),
('latitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)),
('longitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)),
],
),
migrations.CreateModel(
name='AGSensor',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(blank=True, max_length=1024)),
('type_id', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='ag_data.AGSensorType')),
],
),
migrations.CreateModel(
name='AGMeasurement',
fields=[
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('timestamp', models.DateTimeField(default=django.utils.timezone.now)),
('value', django.contrib.postgres.fields.jsonb.JSONField()),
('event_uuid', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ag_data.AGEvent')),
('sensor_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ag_data.AGSensor')),
],
),
migrations.AddField(
model_name='agevent',
name='venue_uuid',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='ag_data.AGVenue'),
),
]
Empty file added ag_data/migrations/__init__.py
Empty file.
67 changes: 67 additions & 0 deletions ag_data/models.py
@@ -0,0 +1,67 @@
from django.db import models
from django.contrib.postgres.fields import JSONField
import uuid
from django.utils import timezone


class AGVenue(models.Model):
"""Store the venue where events happens, including name, description, latitude and
longtitude.
"""

uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=100, blank=True)
description = models.CharField(max_length=100, null=False, blank=True)
latitude = models.DecimalField(
max_digits=9, decimal_places=6, blank=True, null=True
)
longitude = models.DecimalField(
max_digits=9, decimal_places=6, blank=True, null=True
)


class AGEvent(models.Model):
"""Stores the information about events including name, date and description.
"""

uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=40, blank=True)
date = models.DateTimeField(default=timezone.now)
description = models.CharField(max_length=100, null=False, blank=True)
venue_uuid = models.ForeignKey(AGVenue, null=True, on_delete=models.SET_NULL)


class AGSensorType(models.Model):
"""Stores the information about sensor types which is used to provide a sensor template
and related formula for different types of sensors.
"""

id = models.AutoField(primary_key=True)
name = models.CharField(max_length=1024, blank=True)
processing_formula = models.IntegerField(default=0, null=False)
format = JSONField()


class AGSensor(models.Model):
"""Stores the information about sensors including name and type id.
"""

id = models.AutoField(primary_key=True)
name = models.CharField(max_length=1024, blank=True)
type_id = models.ForeignKey(AGSensorType, null=False, on_delete=models.PROTECT)


class AGMeasurement(models.Model):
"""Stores the information about sensor measurements, including timestamp, event, sensor
id and measurement values.
"""

uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
timestamp = models.DateTimeField(default=timezone.now, blank=False)
event_uuid = models.ForeignKey(
AGEvent, on_delete=models.CASCADE, blank=False, null=False
)
sensor_id = models.ForeignKey(
AGSensor, on_delete=models.CASCADE, blank=False, null=False
)
value = JSONField()
52 changes: 52 additions & 0 deletions ag_data/presets.py
@@ -0,0 +1,52 @@
venue_presets = [
{
"agVenueName": "Washington Square Park",
"agVenueDescription": "Sunnyside Daycare's Butterfly Room.",
"agVenueLatitude": 40.730812,
"agVenueLongitude": -73.997456,
},
{
"agVenueName": "Central Park",
"agVenueDescription": "Muddy Puddles",
"agVenueLatitude": 40.794692,
"agVenueLongitude": -73.959156,
},
]

event_presets = [
{
"agEventName": "Sunny Day Test Drive",
"agEventDate": "2020-02-02T20:21:22",
"agEventDescription": "A very progressive test run at "
"Sunnyside Daycare's Butterfly Room.",
},
{
"agEventName": "Peppa Pig Muddy Puddles",
"agEventDate": "2020-03-01T00:34:57",
"agEventDescription": "George, "
"if you jump in muddy puddles, you must wear your boots.",
},
]

sensor_type_presets = [
{
"agSensorTypeID": 0,
"agSensorTypeName": "Simple Temperature Sensor",
"agSensorTypeFormula": 0,
"agSensorTypeFormat": {"reading": {"unit": "Celsius", "format": "float"}},
},
{
"agSensorTypeID": 1,
"agSensorTypeName": "Dual Temperature Sensor",
"agSensorTypeFormula": 0,
"agSensorTypeFormat": {
"internal": {"unit": "Keivin", "format": "float"},
"external": {"unit": "Keivin", "format": "float"},
},
},
]

sensor_presets = [
{"agSensorName": "Sample Simple Temperature", "agSensorType": 0},
{"agSensorName": "Sample Dual Temperature", "agSensorType": 1},
]