Просмотр исходного кода

The profile logger now just clears single user data. Small fixes.

Iñigo Valentin 6 лет назад
Родитель
Сommit
f81d113cb6
3 измененных файлов с 40 добавлено и 30 удалено
  1. 2 2
      application/Controller.php
  2. 1 3
      application/Filter.php
  3. 37 25
      application/bin/log-profile.py

+ 2 - 2
application/Controller.php

@@ -151,11 +151,11 @@
                         $page = new Report_Skillup_Page($db, $pars[1]);
                         $page = new Report_Skillup_Page($db, $pars[1]);
                     }
                     }
                     elseif (strtoupper($pars[1]) == "RUNEUPGRADE"){
                     elseif (strtoupper($pars[1]) == "RUNEUPGRADE"){
-                    require_once($path["page"] . "Report_Runeupgrade_Page.php");
+                        require_once($path["page"] . "Report_Runeupgrade_Page.php");
                         $page = new Report_Runeupgrade_Page($db, $pars[1]);
                         $page = new Report_Runeupgrade_Page($db, $pars[1]);
                     }
                     }
                     elseif (strtoupper($pars[1]) == "RUNECRAFT"){
                     elseif (strtoupper($pars[1]) == "RUNECRAFT"){
-                    require_once($path["page"] . "Report_Runecraft_Page.php");
+                        require_once($path["page"] . "Report_Runecraft_Page.php");
                         $page = new Report_Runecraft_Page($db, $pars[1]);
                         $page = new Report_Runecraft_Page($db, $pars[1]);
                     }
                     }
 
 

+ 1 - 3
application/Filter.php

@@ -3,8 +3,6 @@
     global $QUALITY;
     global $QUALITY;
     global $RUNE_STAT;
     global $RUNE_STAT;
 
 
-    $a = "VARIALEA";
-
     $FILTER_CATALOG = [
     $FILTER_CATALOG = [
         "element" => 0,
         "element" => 0,
         "name" => "",
         "name" => "",
@@ -143,7 +141,7 @@
         "helper" => false,
         "helper" => false,
         "number" => 20,
         "number" => 20,
     ];
     ];
-    
+
     $FILTER_TEAM = [
     $FILTER_TEAM = [
         "name" => "",
         "name" => "",
         "area" => null
         "area" => null

+ 37 - 25
application/bin/log-profile.py

@@ -81,22 +81,6 @@ def openDatabase(name):
     print('Configuring database...')
     print('Configuring database...')
     try:
     try:
         db = sqlite3.connect(name)
         db = sqlite3.connect(name)
-        cursor = db.cursor()
-        cursor.execute('PRAGMA foreign_keys = OFF;')
-        cursor.execute('DELETE FROM scenario')
-        cursor.execute('DELETE FROM defense')
-        cursor.execute('DELETE FROM unit')
-        cursor.execute('DELETE FROM unit_skill')
-        cursor.execute('DELETE FROM rune')
-        cursor.execute('DELETE FROM building')
-        cursor.execute('DELETE FROM decoration')
-        cursor.execute('DELETE FROM inventory')
-        cursor.execute('DELETE FROM summon_special')
-        cursor.execute('DELETE FROM guild')
-        cursor.execute('DELETE FROM guild_member')
-        cursor.execute('DELETE FROM rune_craft')
-        db.commit()
-        cursor.close()
         return db
         return db
     except sqlite3.IntegrityError as e:
     except sqlite3.IntegrityError as e:
         print("Error executing statement: " + str(e))
         print("Error executing statement: " + str(e))
@@ -105,6 +89,41 @@ def openDatabase(name):
         print("I/O Error creating database " + name + ": " + str(e))
         print("I/O Error creating database " + name + ": " + str(e))
         raise
         raise
 
 
+"""
+Clears the user tables.
+
+It also disables referencial integrity.
+
+:param db: Sqlite database connection.
+:param data: Data in json format.
+:raises IntegrityError: The queryes couldn't bre executed.
+"""
+def clearData(db, data):
+    print('Clearing previous data...')
+    try:
+        uid = data["wizard_info"]["wizard_id"]
+        cursor = db.cursor()
+        cursor.execute('PRAGMA foreign_keys = OFF;')
+        cursor.execute('DELETE FROM scenario WHERE uid = ?', (uid))
+        cursor.execute('DELETE FROM defense WHERE uid = ?', (uid))
+        cursor.execute('DELETE FROM unit WHERE uid = ?', (uid))
+        cursor.execute('DELETE FROM unit_skill WHERE uid = ?', (uid))
+        cursor.execute('DELETE FROM rune WHERE uid = ?', (uid))
+        cursor.execute('DELETE FROM building WHERE uid = ?', (uid))
+        cursor.execute('DELETE FROM decoration WHERE uid = ?', (uid))
+        cursor.execute('DELETE FROM inventory WHERE uid = ?', (uid))
+        #cursor.execute('DELETE FROM summon_special')
+        #cursor.execute('DELETE FROM guild')
+        cursor.execute('DELETE FROM guild_member WHERE uid = ?', (uid))
+        cursor.execute('DELETE FROM rune_craft WHERE uid = ?', (uid))
+        db.commit()
+        cursor.close();
+    except sqlite3.IntegrityError as e:
+        print("Error executing statement: " + str(e))
+        raise
+    return
+
+
 """
 """
 Closes the database.
 Closes the database.
 
 
@@ -659,7 +678,7 @@ def parseRunes(db, data):
             substat_3_enchant = 0
             substat_3_enchant = 0
             substat_3_grind = 0
             substat_3_grind = 0
         if len(rune["sec_eff"]) > 3:
         if len(rune["sec_eff"]) > 3:
-            substat_4 = rune["sec_eff"][0][0]
+            substat_4 = rune["sec_eff"][3][0]
             substat_4_value = rune["sec_eff"][3][1]
             substat_4_value = rune["sec_eff"][3][1]
             substat_4_enchant = rune["sec_eff"][3][2]
             substat_4_enchant = rune["sec_eff"][3][2]
             substat_4_grind = rune["sec_eff"][3][3]
             substat_4_grind = rune["sec_eff"][3][3]
@@ -929,14 +948,6 @@ def get_max_efficiency(substats, efficiency, level, stars, quality):
     substat_upgrades_remaining = (4 - math.floor((min(level, 12) / 3))) - max((3 - quality), 0)
     substat_upgrades_remaining = (4 - math.floor((min(level, 12) / 3))) - max((3 - quality), 0)
     new_stats = max(min(4 - len(substats), substat_upgrades_remaining), 0)
     new_stats = max(min(4 - len(substats), substat_upgrades_remaining), 0)
     old_stats = substat_upgrades_remaining - new_stats
     old_stats = substat_upgrades_remaining - new_stats
-    
-    #if id == 16042097882:
-    #    print("substat_upgrades_remaining: " + str(substat_upgrades_remaining))
-    #    print("quality: " + str(quality))
-    #    print("level: " + str(level))
-    #    print("math.floor((min(level, 12) / 3)): " + str(math.floor((min(level, 12) / 3))))
-    #    print("old_stats: " + str(old_stats))
-    #    print("new_stats: " + str(new_stats))
 
 
     if old_stats > 0:
     if old_stats > 0:
         # we can repeatedly upgrade the most value of the existing stats
         # we can repeatedly upgrade the most value of the existing stats
@@ -1053,6 +1064,7 @@ if verifyKey(db, data, key) == False:
     print("Invalid API KEY...")
     print("Invalid API KEY...")
     sys.exit(-1)
     sys.exit(-1)
 else:
 else:
+    clearData(db, data)
     parsePlayer(db, data)
     parsePlayer(db, data)
     parseScenarios(db, data)
     parseScenarios(db, data)
     parseDefense(db, data)
     parseDefense(db, data)