Updates API to use DB on get methods

This commit is contained in:
Sergi Delgado Segura
2019-11-14 17:35:52 +00:00
parent f33d2d61ac
commit 3a1bf0cc8a
2 changed files with 28 additions and 21 deletions

View File

@@ -52,6 +52,11 @@ class DBManager:
self.db.put(key, value)
def load_entry(self, key):
data = self.db.get(key.encode("utf-8"))
data = json.loads(data) if data is not None else data
return data
def delete_entry(self, key, prefix=None):
if isinstance(prefix, str):
key = prefix + key
@@ -60,6 +65,12 @@ class DBManager:
self.db.delete(key)
def load_watcher_appointment(self, key):
return self.load_entry(WATCHER_PREFIX + key)
def load_responder_job(self, key):
return self.load_entry(RESPONDER_PREFIX + key)
def load_watcher_appointments(self):
all_appointments = self.load_appointments_db(prefix=WATCHER_PREFIX)
non_triggered_appointments = {