[xiph-commits] r14916 - branches/dir.xiph.org/cronjobs

balbinus at svn.xiph.org balbinus at svn.xiph.org
Sun May 18 14:44:13 PDT 2008


Author: balbinus
Date: 2008-05-18 14:44:13 -0700 (Sun, 18 May 2008)
New Revision: 14916

Modified:
   branches/dir.xiph.org/cronjobs/rotate_tables.php
Log:
Bug fixes on previous commit + new table

Modified: branches/dir.xiph.org/cronjobs/rotate_tables.php
===================================================================
--- branches/dir.xiph.org/cronjobs/rotate_tables.php	2008-05-18 21:29:34 UTC (rev 14915)
+++ branches/dir.xiph.org/cronjobs/rotate_tables.php	2008-05-18 21:44:13 UTC (rev 14916)
@@ -17,33 +17,46 @@
 /******************************************************************************/
 try
 {
+    printf("Creating logged_at index on api_log_%s... ", $yesterday);
+    $start = microtime(true);
     $sql = 'CREATE INDEX `logged_at` ON `api_log_%s` (`logged_at`);';
     $sql = sprintf($sql, $yesterday);
     $db->query($sql);
-    $sql = 'CREATE INDEX `message` ON `api_log_%s` (`message`, `logged_at`);'
+    printf("OK [%.3f s]\n", microtime(true) - $start);
+    
+    printf("Creating message index on api_log_%s... ", $yesterday);
+    $start = microtime(true);
+    $sql = 'CREATE INDEX `message` ON `api_log_%s` (`message`, `logged_at`);';
     $sql = sprintf($sql, $yesterday);
     $db->query($sql);
+    printf("OK [%.3f s]\n", microtime(true) - $start);
 }
 catch (SQLException $e)
 {
+    echo "[ERROR]\n";
+    
     // Mail the error...
     custom_exception_handler($e);
     
     // do nothing.
 }
 
+echo "Creating future tables... ";
 $sql_pattern = 'CREATE TABLE IF NOT EXISTS `api_log_%s` LIKE `api_log_template`;';
 for ($i = 0 ; $i <= 7 ; $i++)
 {
     $date = makeFutureDate('Ymd', $i);
+    echo $date." ";
     
     $sql = sprintf($sql_pattern, $date);
     try
     {
         $db->query($sql);
+        echo "[OK]... ";
     }
     catch (SQLException $e)
     {
+        echo "[ERROR] ! ";
         // Mail the error...
         custom_exception_handler($e);
         
@@ -51,4 +64,49 @@
     }
 }
 
+/******************************************************************************/
+/**                              PLAYLIST LOG                                **/
+/******************************************************************************/
+try
+{
+    printf("Creating stream_name_hash index on playlist_log_%s... ", $yesterday);
+    $start = microtime(true);
+    $sql = 'CREATE INDEX `stream_name_hash` ON `playlist_log_%s` (`stream_name_hash`);';
+    $sql = sprintf($sql, $yesterday);
+    $db->query($sql);
+    printf("OK [%.3f s]\n", microtime(true) - $start);
+}
+catch (SQLException $e)
+{
+    echo "[ERROR]\n";
+    
+    // Mail the error...
+    custom_exception_handler($e);
+    
+    // do nothing.
+}
+
+echo "Creating future tables... ";
+$sql_pattern = 'CREATE TABLE IF NOT EXISTS `playlist_log_%s` LIKE `playlist_log_template`;';
+for ($i = 0 ; $i <= 7 ; $i++)
+{
+    $date = makeFutureDate('Ymd', $i);
+    echo $date." ";
+    
+    $sql = sprintf($sql_pattern, $date);
+    try
+    {
+        $db->query($sql);
+        echo "[OK]... ";
+    }
+    catch (SQLException $e)
+    {
+        echo "[ERROR] ! ";
+        // Mail the error...
+        custom_exception_handler($e);
+        
+        // do nothing.
+    }
+}
+
 ?>



More information about the commits mailing list