add boundaries to model and view

This commit is contained in:
sessionm21 2020-05-13 06:54:04 +01:00
parent f2cad65626
commit efacfe76ec
3 changed files with 30 additions and 1 deletions

BIN
fgs/.model.py.swo Normal file

Binary file not shown.

View File

@ -33,6 +33,31 @@ class StimulusActivation(db.Model):
voltage_level = db.Column(db.Integer)
datetime = db.Column(db.DateTime)
class BoundingBox(db.Model):
id = db.Column(db.Integer, primary_key=True)
collar_id = db.Column(db.Integer, db.ForeignKey('collar.id'))
coord0x = db.Column(db.Float(precision=10))
coord0y = db.Column(db.Float(precision=10))
coord1x = db.Column(db.Float(precision=10))
coord1y = db.Column(db.Float(precision=10))
coord2x = db.Column(db.Float(precision=10))
coord2y = db.Column(db.Float(precision=10))
coord3x = db.Column(db.Float(precision=10))
coord3y = db.Column(db.Float(precision=10))
coord4x = db.Column(db.Float(precision=10))
coord4y = db.Column(db.Float(precision=10))
coord5x = db.Column(db.Float(precision=10))
coord5y = db.Column(db.Float(precision=10))
coord6x = db.Column(db.Float(precision=10))
coord6y = db.Column(db.Float(precision=10))
coord7x = db.Column(db.Float(precision=10))
coord7y = db.Column(db.Float(precision=10))
coord8x = db.Column(db.Float(precision=10))
coord8y = db.Column(db.Float(precision=10))
coord9x = db.Column(db.Float(precision=10))
coord9y = db.Column(db.Float(precision=10))
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String)

View File

@ -88,4 +88,8 @@ def collar_detail(id):
order_by(StimulusActivation.datetime.desc())
n_stimulus = stimulus_points.count()
return jsonify({'id': collar.id, 'name': collar.name, 'stimilus': n_stimulus })
boundary = BoundingBox.query.filter_by(collar_id=collar.id).\
order_by(DataPoint.datetime.desc()).\
first()
return jsonify({'id': collar.id, 'name': collar.name, 'stimilus': n_stimulus, 'boundary': boundary })