[LON-CAPA-cvs] cvs: loncom /metadata_database cleanup_database.pl

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 10 Aug 2006 20:07:03 -0000


albertel		Thu Aug 10 16:07:03 2006 EDT

  Modified files:              
    /loncom/metadata_database	cleanup_database.pl 
  Log:
  - switch from using column number to hash 
  
  
Index: loncom/metadata_database/cleanup_database.pl
diff -u loncom/metadata_database/cleanup_database.pl:1.4 loncom/metadata_database/cleanup_database.pl:1.5
--- loncom/metadata_database/cleanup_database.pl:1.4	Wed Jun  9 08:39:39 2004
+++ loncom/metadata_database/cleanup_database.pl	Thu Aug 10 16:07:01 2006
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # cleanup_database.pl Remove stale temporary search results.
 #
-# $Id: cleanup_database.pl,v 1.4 2004/06/09 12:39:39 matthew Exp $
+# $Id: cleanup_database.pl,v 1.5 2006/08/10 20:07:01 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -119,14 +119,11 @@
 
 my $sth = $dbh->prepare("SHOW TABLE STATUS");
 $sth->execute();
-my $results = $sth->fetchall_arrayref;
+my $results = $sth->fetchall_hashref(['Name']);
 
-foreach my $array (@$results) {
-    next if ($array->[14] ne 'temporary');  # [14] is the comment
-    my $name = $array->[0];
-    # [10] in status report is creation time.
-    # [11] in status report is update (last modification?) time.
-    my $tabletime = $array->[11];
+foreach my $name (keys(%$results)) {
+    next if ($results->{$name}{Comment} ne 'temporary'); 
+    my $tabletime = $results->{$name}{Update_time};
     # Times are like: 2002-07-25 10:17:08
     my ($year,$month,$day,$hour,$min,$sec)= 
         ($tabletime =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);