summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Metzger2020-06-10 15:51:05 +0200
committerLukas Metzger2020-06-10 15:51:05 +0200
commitcd5b0fb700f531d3dc7b3313cf030ab0d8d60a7b (patch)
tree1d333ba854853a25b161cbe8d335267a65c829af
parentChanged default timeframe to 365 days (diff)
downloadbwlp-statistics-cd5b0fb700f531d3dc7b3313cf030ab0d8d60a7b.tar.gz
bwlp-statistics-cd5b0fb700f531d3dc7b3313cf030ab0d8d60a7b.tar.xz
bwlp-statistics-cd5b0fb700f531d3dc7b3313cf030ab0d8d60a7b.zip
Added minimal date for locations, machines and vms
-rw-r--r--pages/locations.py17
-rw-r--r--pages/machines.py13
-rw-r--r--pages/vms.py13
3 files changed, 42 insertions, 1 deletions
diff --git a/pages/locations.py b/pages/locations.py
index 9cb36bc..85adcfc 100644
--- a/pages/locations.py
+++ b/pages/locations.py
@@ -33,6 +33,7 @@ def layout():
date=get_newest_date(),
display_format='DD-MM-YYYY',
max_date_allowed=get_newest_date(),
+ min_date_allowed=get_oldest_date(),
initial_visible_month=get_newest_date(),
first_day_of_week=1,
persistence=True,
@@ -44,7 +45,9 @@ def layout():
id='locations-satellite',
options=[{'label': s, 'value': s} for s in get_satellites()],
value=None,
- placeholder='All Satellites'
+ placeholder='All Satellites',
+ persistence=True,
+ persistence_type='memory'
)
])
]),
@@ -224,3 +227,15 @@ def get_newest_date():
db.closeConnection(dbcon)
return data[0]['date']
+
+def get_oldest_date():
+ dbcon = db.getConnection()
+ cursor = dbcon.cursor()
+
+ cursor.execute("""SELECT date FROM reports ORDER BY date ASC LIMIT 1""")
+
+ data = cursor.fetchall()
+
+ db.closeConnection(dbcon)
+ return data[0]['date']
+
diff --git a/pages/machines.py b/pages/machines.py
index f314777..b82df43 100644
--- a/pages/machines.py
+++ b/pages/machines.py
@@ -33,6 +33,7 @@ def layout():
date=get_newest_date(),
display_format='DD-MM-YYYY',
max_date_allowed=get_newest_date(),
+ min_date_allowed=get_oldest_date(),
initial_visible_month=get_newest_date(),
first_day_of_week=1,
persistence=True,
@@ -291,3 +292,15 @@ def get_newest_date():
db.closeConnection(dbcon)
return data[0]['date']
+
+def get_oldest_date():
+ dbcon = db.getConnection()
+ cursor = dbcon.cursor()
+
+ cursor.execute("""SELECT date FROM reports ORDER BY date ASC LIMIT 1""")
+
+ data = cursor.fetchall()
+
+ db.closeConnection(dbcon)
+ return data[0]['date']
+
diff --git a/pages/vms.py b/pages/vms.py
index f0b9a05..c9ca141 100644
--- a/pages/vms.py
+++ b/pages/vms.py
@@ -33,6 +33,7 @@ def layout():
date=get_newest_date(),
display_format='DD-MM-YYYY',
max_date_allowed=get_newest_date(),
+ min_date_allowed=get_oldest_date(),
initial_visible_month=get_newest_date(),
first_day_of_week=1,
persistence=True,
@@ -143,3 +144,15 @@ def get_newest_date():
db.closeConnection(dbcon)
return data[0]['date']
+
+def get_oldest_date():
+ dbcon = db.getConnection()
+ cursor = dbcon.cursor()
+
+ cursor.execute("""SELECT date FROM reports ORDER BY date ASC LIMIT 1""")
+
+ data = cursor.fetchall()
+
+ db.closeConnection(dbcon)
+ return data[0]['date']
+