Bläddra i källkod

[Bugfix] Try with one nested loop less

Foppe Hemminga 5 år sedan
förälder
incheckning
60d7e9cb09
1 ändrade filer med 23 tillägg och 23 borttagningar
  1. 23 23
      cron.py

+ 23 - 23
cron.py

@@ -103,29 +103,29 @@ def cron():
                 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)}")
-            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)}")
-                for item in new_properties:
-                    if item == 'tokenrefills':
-                        # Weird error
-                        continue
-                    if item == 'incendiaryammoused':
-                        continue
-                    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:
-                        value = player_json[item]
-                    print(f"item: {item} -> value: {value}")
-                    update_missing_value(row['maintainer'], row['player'], item, value)
+        new_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)}")
+            for item in new_properties:
+                if item == 'tokenrefills':
+                    # Weird error
+                    continue
+                if item == 'incendiaryammoused':
+                    continue
+                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:
+                    value = player_json[item]
+                print(f"item: {item} -> value: {value}")
+                update_missing_value(row['maintainer'], row['player'], item, value)
         time.sleep(1)
     conn.close()