Foppe Hemminga 5 роки тому
батько
коміт
619251b192
1 змінених файлів з 9 додано та 8 видалено
  1. 9 8
      cron.py

+ 9 - 8
cron.py

@@ -84,7 +84,7 @@ def cron():
         properties = json.loads(row['property'])
         if 'name' not in properties:
             properties.append(name)
-        pprint(properties)
+        # pprint(properties)
         query_second = """SELECT player.value, properties.parent
             FROM player
             JOIN properties ON player.property = properties.property
@@ -93,30 +93,30 @@ def cron():
             AND player.property = ?;"""
         retrieved_properties = []
         for property in properties:
-            pprint((row['maintainer'], row['player'], property,))
+            # pprint((row['maintainer'], row['player'], property,))
             cur.execute(query_second, (row['maintainer'], row['player'], property,))
             p_row = cur.fetchone()
             if not p_row:
                 continue
-            print(f"property: '{property}' parent: '{p_row['parent']}' -> value: '{p_row['value']}'")
+            # print(f"property: '{property}' parent: '{p_row['parent']}' -> value: '{p_row['value']}'")
             retrieved_properties.append(property)
             new_value = ''
             if (p_row['parent']):
                 new_value = player_json[p_row['parent']][property]
             else:
                 new_value = player_json[property]
-            print(f"p_row['value']: {p_row['value']} != new_value: '{new_value}'")
+            # print(f"p_row['value']: {p_row['value']} != new_value: '{new_value}'")
             if str(p_row['value']) != str(new_value):
                 send_notification(row['maintainer'], row['player'], property, p_row['value'], new_value)
                 update_value(row['maintainer'], row['player'], property, new_value)
         new_properties = []
-        print(f"len(properties): {len(properties)}")
-        print(f"len(retrieved_properties): {len(retrieved_properties)}")
+        # print(f"len(properties): {len(properties)}")
+        # print(f"len(retrieved_properties): {len(retrieved_properties)}")
         for item in properties:
             if item not in retrieved_properties:
                 new_properties.append(item)
         if len(new_properties) > 0:
-            print(f"len(new_properties): {len(new_properties)}")
+            # print(f"len(new_properties): {len(new_properties)}")
             for item in new_properties:
                 query_third = """SELECT parent FROM properties where property = ?;"""
                 cur.execute(query_third, (item,))
@@ -129,7 +129,8 @@ def cron():
                     except KeyError:
                         query_fourth = """INSERT INTO properties (property, parent)
                             VALUES (?, 'personalstats')"""
-                         cur.execute(query_fourth, (item,))
+                        cur.execute(query_fourth, (item,))
+                        value = 0
                 print(f"item: {item} -> value: {value}")
                 update_missing_value(row['maintainer'], row['player'], item, value)
         time.sleep(1)