-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodels.py
More file actions
42 lines (26 loc) · 1.02 KB
/
models.py
File metadata and controls
42 lines (26 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from sqlalchemy.dialects.postgresql import ARRAY
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
def get_model_options(model):
instances = model.query.all()
return [{"label": instance.name, "value": instance.name} for instance in instances]
class Filter(db.Model):
name = db.Column(db.String, primary_key=True)
filters = db.Column(db.JSON(), nullable=True)
scalar_graph_options = db.Column(db.JSON())
ts_graph_options = db.Column(db.JSON())
def __repr__(self):
return '<Filter %r>' % self.name
class Colors(db.Model):
name = db.Column(db.String, primary_key=True)
colors = db.Column(db.JSON(), nullable=True)
def __repr__(self):
return '<Color %r>' % self.name
class Labels(db.Model):
name = db.Column(db.String, primary_key=True)
labels = db.Column(db.JSON(), nullable=True)
def __repr__(self):
return '<Label %r>' % self.name
class Scenarios(db.Model):
name = db.Column(db.String, primary_key=True)
ids = db.Column(ARRAY(db.Integer))