Browse Source

Excluded the disabled publication already in SQL query

Andreas Kopmann 7 years ago
parent
commit
0fa61ce682
1 changed files with 11 additions and 13 deletions
  1. 11 13
      scopus-update-database.py

+ 11 - 13
scopus-update-database.py

@@ -54,19 +54,17 @@ def update_database():
             for pub in result:
                 id = int(pub['wpid'])
                 
-                
-                if (id > 0):
-                    if not wordpress_get_post(id):
-                        print "Marking post %d as ununsed; deleting citations" % id
-                        
-                        sql = "DELETE FROM `citations` WHERE `wpid` = %s"
-                        cursor.execute(sql, (id) )
-                        
-                        sql = "UPDATE `publications` SET `wpid` = 0 WHERE `wpid` = %s"
-                        cursor.execute(sql, (id) )
-                        npubs += 1
-    
-    
+                if not wordpress_get_post(id):
+                    print "Marking post %d as ununsed; deleting citations" % id
+                    
+                    sql = "DELETE FROM `citations` WHERE `wpid` = %s"
+                    cursor.execute(sql, (id) )
+                    
+                    sql = "UPDATE `publications` SET `wpid` = 0 WHERE `wpid` = %s"
+                    cursor.execute(sql, (id) )
+                    npubs += 1
+
+
             # connection is not autocommit by default. So you must commit to save
             # your changes.
             connection.commit()