Did stuff
This commit is contained in:
parent
c725c201a7
commit
ff93395ce0
@ -1,2 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
from .db import db
|
||||
from .default import Default
|
||||
from .details import Details
|
7
model_service/model/default.py
Normal file
7
model_service/model/default.py
Normal file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
from .db import db
|
||||
|
||||
|
||||
class Default(db.Model):
|
||||
default_id = db.Column(db.Integer, db.ForeignKey("details.id"), nullable=False)
|
||||
default = db.relationship("Details")
|
16
model_service/model/details.py
Normal file
16
model_service/model/details.py
Normal file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
from .db import db
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
|
||||
class Details(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True, auto_increment=True)
|
||||
name = db.Column(db.String(30), key=True)
|
||||
timestamp = db.Column(db.TIMESTAMP, nullable=False, server_default=func.now())
|
||||
|
||||
mid_window = db.Column(db.Float)
|
||||
mid_step = db.Column(db.Float)
|
||||
short_window = db.Column(db.Float)
|
||||
short_step = db.Column(db.Float)
|
||||
compute_beat = db.Column(db.Float)
|
||||
type = db.Column(db.String(15))
|
@ -1,2 +1,3 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from .default_schema import DefaultSchema
|
||||
from .details_schema import DetailsSchema
|
||||
|
9
model_service/schemas/default_schema.py
Normal file
9
model_service/schemas/default_schema.py
Normal file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
from marshmallow import fields
|
||||
from marshmallow_sqlalchemy import ModelSchema
|
||||
from model import Default
|
||||
|
||||
|
||||
class DefaultSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = Default
|
9
model_service/schemas/details_schema.py
Normal file
9
model_service/schemas/details_schema.py
Normal file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
from marshmallow import fields
|
||||
from marshmallow_sqlalchemy import ModelSchema
|
||||
from model import Details
|
||||
|
||||
|
||||
class DetailsSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = Details
|
@ -1,14 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
from flask import request, jsonify
|
||||
from flask_classful import FlaskView, route
|
||||
from model import db
|
||||
from model import db, Default, Details
|
||||
from schema import DetailsSchema, DefaultSchema
|
||||
from utils import json_required
|
||||
|
||||
import requests.exceptions
|
||||
|
||||
|
||||
class ModelView(FlaskView):
|
||||
|
||||
details_schema = DetailsSchema(many=False)
|
||||
default_schema = DefaultSchema(many=False)
|
||||
|
||||
@json_required
|
||||
def post(self):
|
||||
return jsonify({})
|
||||
|
||||
@ -22,6 +25,15 @@ class ModelView(FlaskView):
|
||||
def delete(self, _id: str):
|
||||
return jsonify({"id": _id})
|
||||
|
||||
@json_required
|
||||
@route('$default', methods=['PUT'])
|
||||
def put_default(self):
|
||||
return jsonify({})
|
||||
|
||||
Default.query.delete()
|
||||
#new_default = Default()
|
||||
|
||||
|
||||
db.session.add(new_default)
|
||||
db.session.commit()
|
||||
|
||||
return jsonify(self.default_schema.dump(new_default))
|
||||
|
Loading…
Reference in New Issue
Block a user