From a0d93268e03401c6c560043c9a55f692a0d01583 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20M=C3=BCller?= <j.mueller@vr.rwth-aachen.de>
Date: Wed, 4 Mar 2020 17:13:47 +0100
Subject: [PATCH] Fix get_simulation_time_info

---
 access_node/__main__.py                    | 4 ++--
 access_node/controllers/nest_controller.py | 9 ++++++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/access_node/__main__.py b/access_node/__main__.py
index 4336dd4..0fcc2f6 100644
--- a/access_node/__main__.py
+++ b/access_node/__main__.py
@@ -12,7 +12,7 @@ import requests
 import psycopg2
 
 
-def SetupDB(postgres_username, postgres_password, port):
+def SetupNestDB(postgres_username, postgres_password, port):
 	con = psycopg2.connect(database="postgres", user=postgres_username,
                        password=postgres_password, host="database", port=str(port))
 	print("Database connection opened successfully!")
@@ -54,7 +54,7 @@ def SetupDB(postgres_username, postgres_password, port):
 
 def main():
 	# Connect to the Database and initalize basic Table structure
-	SetupDB('postgres', 'docker', 5432)
+	SetupNestDB('postgres', 'docker', 5432)
 
 	# get info node
 	with open('access_node//info_node.json', 'r') as f:
diff --git a/access_node/controllers/nest_controller.py b/access_node/controllers/nest_controller.py
index 428de81..f53a4ab 100644
--- a/access_node/controllers/nest_controller.py
+++ b/access_node/controllers/nest_controller.py
@@ -228,9 +228,12 @@ def nest_get_simulation_time_info():  # noqa: E501
                        password="docker", host="database", port="5432")
     
     cur = con.cursor()
-    cur.execute("SELECT MAX(CURRENT_SIM_TIME) FROM SIMULATION_NODES")
-    time = cur.fetchall()[0][0]
-    return time
+    cur.execute("SELECT MIN(CURRENT_SIM_TIME) FROM SIMULATION_NODES")
+    current_time = cur.fetchall()[0][0]
+
+    # TODO Add Start and End time when available
+    time_info = SimulationTimeInfo(current=current_time)
+    return time_info
 
 
 def nest_get_spikes(_from=None, to=None, gids=None, offset=None, limit=None):  # noqa: E501
-- 
GitLab