[mirrorbrain-commits] [opensuse-svn] r6645 - trunk/tools/download-redirector-v2/mirrordoctor/mb

From: Novell Forge SVN <noreply_at_novell.com>
Date: Sun, 1 Mar 2009 17:39:50 -0700 (MST)
Author: poeml
Date: 2009-03-01 17:39:48 -0700 (Sun, 01 Mar 2009)
New Revision: 6645

Modified:
   trunk/tools/download-redirector-v2/mirrordoctor/mb/vacuum.py
Log:
mb vacuum:
- adjust for the new database scheme, which makes it much easier to find and
  delete stale file, and also extremely faster, because no joins are needed
  anymore.


Modified: trunk/tools/download-redirector-v2/mirrordoctor/mb/vacuum.py
===================================================================
--- trunk/tools/download-redirector-v2/mirrordoctor/mb/vacuum.py	2009-03-02 00:29:28 UTC (rev 6644)
+++ trunk/tools/download-redirector-v2/mirrordoctor/mb/vacuum.py	2009-03-02 00:39:48 UTC (rev 6645)
@@ -2,39 +2,22 @@
 def stale(conn):
     """show statistics about stale files in the database"""
 
-    # file_server table
-    query = 'SELECT COUNT(*) FROM file_server fs LEFT OUTER JOIN server s ON fs.serverid = s.id WHERE s.id IS NULL'
-    n_file_stale = conn.FileServer._connection.queryAll(query)[0]
+    n_file_total = conn.Filearr.select().count()
 
-    query = 'SELECT COUNT(*) FROM file_server fs LEFT OUTER JOIN server s ON fs.serverid = s.id WHERE s.id IS NULL OR NOT s.enabled'
-    n_file_disabled_stale = conn.FileServer._connection.queryAll(query)[0]
+    query = "SELECT count(*) FROM filearr WHERE mirrors = '{}';"
+    n_file_stale = conn.Filearr._connection.queryAll(query)[0]
 
 
-
-    # file table
-    n_file_total = conn.File.select().count()
-
-    query = 'SELECT COUNT(*) FROM file f LEFT OUTER JOIN file_server fs ON f.id = fs.fileid WHERE fs.fileid IS NULL'
-    n_file_stale = conn.File._connection.queryAll(query)[0]
-
-
-    print 'file_server stale:            %10d' % n_file_stale
-    print 'file_server stale/disabled:   %10d' % n_file_disabled_stale
-    print
     print 'file total:                   %10d' % n_file_total
     print 'file stale:                   %10d' % n_file_stale
-    print 
 
 
 def vacuum(conn):
     """delete stale file entries from the database"""
 
-    print 'Deleting stales from file_server...'
-    query = 'DELETE FROM file_server WHERE serverid IN (SELECT id FROM server WHERE NOT enabled)'
-    conn.FileServer._connection.query(query)
+    print 'Deleting stale files...'
+    query = "DELETE FROM filearr WHERE mirrors = '{}';"
+    conn.Filearr._connection.query(query)
 
-    print 'Deleting stales from file...'
-    query = 'DELETE FROM file WHERE id IN (SELECT f.id FROM file f LEFT OUTER JOIN file_server fs ON f.id = fs.fileid WHERE fs.fileid IS NULL)'
-    conn.File._connection.query(query)
     print 'Done.'
 

_______________________________________________
Opensuse-svn mailing list
Opensuse-svn_at_forge.novell.com
http://forge.novell.com/mailman/listinfo/opensuse-svn


_______________________________________________
mirrorbrain-commits mailing list

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on 2009-03-02Z00:40:30

This archive was generated by hypermail 2.2.0 : 2009-07-10Z19:18:12 GMT