allow to return cleaned up values
This commit is contained in:
+3
-2
@@ -57,7 +57,8 @@ class Server:
|
|||||||
|
|
||||||
@self.app.get("/cleanup")
|
@self.app.get("/cleanup")
|
||||||
def cleanup():
|
def cleanup():
|
||||||
self._cleanup_database()
|
results = self._cleanup_database()
|
||||||
|
return jsonify(data=json.loads(results), status=200)
|
||||||
|
|
||||||
def run(self, host:str="0.0.0.0", port:str="8000", debug:bool=False):
|
def run(self, host:str="0.0.0.0", port:str="8000", debug:bool=False):
|
||||||
logging.getLogger("werkzeug").setLevel(logging.ERROR)
|
logging.getLogger("werkzeug").setLevel(logging.ERROR)
|
||||||
@@ -159,4 +160,4 @@ class Server:
|
|||||||
|
|
||||||
def _cleanup_database(self):
|
def _cleanup_database(self):
|
||||||
storage = StorageLoader.build(self.storage_type)()
|
storage = StorageLoader.build(self.storage_type)()
|
||||||
return jsonify(storage.cleanup())
|
return storage.cleanup()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from server.GameBoard import GameBoard
|
from server.GameBoard import GameBoard
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import edgedb, json, time
|
import gel, json, time
|
||||||
|
|
||||||
class EdgeDB:
|
class EdgeDB:
|
||||||
def __init__(self, database:str=None, tls_security:str='insecure', **kwargs):
|
def __init__(self, database:str=None, tls_security:str='insecure', **kwargs):
|
||||||
@@ -10,7 +10,7 @@ class EdgeDB:
|
|||||||
self._connect()
|
self._connect()
|
||||||
|
|
||||||
def _connect(self):
|
def _connect(self):
|
||||||
self.client = edgedb.create_client(
|
self.client = gel.create_client(
|
||||||
tls_security=self.tls_security,
|
tls_security=self.tls_security,
|
||||||
database=self.database
|
database=self.database
|
||||||
)
|
)
|
||||||
@@ -19,7 +19,7 @@ class EdgeDB:
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
return function(*args, **kwargs)
|
return function(*args, **kwargs)
|
||||||
except edgedb.errors.ClientConnectionFailedError:
|
except gel.errors.ClientConnectionFailedError:
|
||||||
self._connect()
|
self._connect()
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
@@ -112,11 +112,12 @@ class EdgeDB:
|
|||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
return self.run_query_with_reconnection(
|
return self.run_query_with_reconnection(
|
||||||
self.client.query,
|
self.client.query_json,
|
||||||
"""
|
"""
|
||||||
delete default::GameBoard { }
|
delete Moves { };
|
||||||
filter .turns < <std::int32>"200" or .is_winner_me = <std::bool>"false";
|
|
||||||
|
with gameboard := (delete GameBoard filter .turns < <std::int32>"200" or .is_winner_me = <std::bool>"false")
|
||||||
|
select gameboard {id, url, winner, turns, type: { is_ladder, name } };
|
||||||
|
|
||||||
delete default::Moves { }
|
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user