From fc351d59a69f64dbaba6b12b9e7f6666c81c14ff Mon Sep 17 00:00:00 2001
From: morkolai <nikolai-mork@live.no>
Date: Fri, 13 Mar 2020 10:42:38 +0100
Subject: [PATCH] =?UTF-8?q?#52=20Laget=20funskjon=20som=20oppdaterer=20db?=
 =?UTF-8?q?=20basert=20p=C3=A5=20tid?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 soitool/database.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/soitool/database.py b/soitool/database.py
index d3123c3..12e6539 100644
--- a/soitool/database.py
+++ b/soitool/database.py
@@ -224,6 +224,20 @@ class Database:
         ).total_seconds()
         return seconds_to_update
 
+    def update_codebook_auto(self):
+        """
+        Updates Codebook if it is less than 10 til next update.
+
+        Returns
+        -------
+        sec_to_next_update : float
+            Seconds to next update
+        """
+        sec_to_next_update = self.seconds_to_next_update()
+        if sec_to_next_update < 10:
+            self.update_codebook()
+        return sec_to_next_update
+
     def add_code_to(self, word, mode="ascii"):
         """
         Generate and insert a code for the new word in DB-table CodeBook.
-- 
GitLab