Explorar o código

[Bugfix] simplify missing property issue

Foppe Hemminga %!s(int64=5) %!d(string=hai) anos
pai
achega
b7c967de29
Modificáronse 1 ficheiros con 7 adicións e 10 borrados
  1. 7 10
      cron.py

+ 7 - 10
cron.py

@@ -121,16 +121,13 @@ def cron():
                 query_third = """SELECT parent FROM properties where property = ?;"""
                 cur.execute(query_third, (item,))
                 parent = cur.fetchone()['parent']
-                if (parent):
-                    value = player_json[parent][item]
-                else:
-                    try:
-                        value = player_json[item]
-                    except KeyError:
-                        query_fourth = """INSERT INTO properties (property, parent)
-                            VALUES (?, 'personalstats')"""
-                        cur.execute(query_fourth, (item,))
-                        value = 0
+                try:
+                    if (parent):
+                        value = player_json[parent][item]
+                    else:
+                         value = player_json[item]
+                except KeyError:
+                    value = 0
                 print(f"item: {item} -> value: {value}")
                 update_missing_value(row['maintainer'], row['player'], item, value)
         time.sleep(1)