diff --git a/fgs/.model.py.swo b/fgs/.model.py.swo new file mode 100644 index 0000000..f8928cf Binary files /dev/null and b/fgs/.model.py.swo differ diff --git a/fgs/model.py b/fgs/model.py index b47bc90..70812e6 100644 --- a/fgs/model.py +++ b/fgs/model.py @@ -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) diff --git a/fgs/views.py b/fgs/views.py index e35ccaf..ffbdd66 100644 --- a/fgs/views.py +++ b/fgs/views.py @@ -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 })