Diff for /loncom/metadata_database/searchcat.pl between versions 1.28 and 1.29

version 1.28, 2003/02/03 05:39:37 version 1.29, 2003/02/03 13:42:16
Line 6 Line 6
 #  #
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
 #  #
 # This file is part of the LearningOnline Network with a  # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
 # Computer assisted personalized approach (loncapa).  
 #  #
 # Loncapa is free software; you can redistribute it and/or modify  # LON-CAPA is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by  # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or  # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.  # (at your option) any later version.
 #  #
 # Loncapa is distributed in the hope that it will be useful,  # LON-CAPA is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of  # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.  # GNU General Public License for more details.
 #  #
 # You should have received a copy of the GNU General Public License  # You should have received a copy of the GNU General Public License
 # along with loncapa; if not, write to the Free Software  # along with LON-CAPA; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #  #
 # /home/httpd/html/adm/gpl.txt  # /home/httpd/html/adm/gpl.txt
 #  #
 # http://www.loncapa.org/  # http://www.lon-capa.org/
 #  #
 # YEAR=2001  # YEAR=2001
 # 04/14/2001, 04/16/2001 Scott Harrison  # 04/14/2001, 04/16/2001 Scott Harrison
Line 376  sub escape ($) Line 375  sub escape ($)
 B<build_on_the_fly_dynamic_metadata> - evaluate and store dynamic metadata.  B<build_on_the_fly_dynamic_metadata> - evaluate and store dynamic metadata.
   
 Dynamic metadata is stored in a nohist_resevaldata GDBM database.  Dynamic metadata is stored in a nohist_resevaldata GDBM database.
 Most of the calculations in this subroutine are totally pointless  
 and not useful for anything that this subroutine does.  
 (THIS IS A FRUSTRATED SUBROUTINE THAT IS NON-OPTIMAL, *&*&!.)  
 The only thing that this subroutine really makes happen is adjusting  The only thing that this subroutine really makes happen is adjusting
 a 'count' value inside the F<nohist_new_resevaldata.db> as well  a 'count' value inside the F<nohist_new_resevaldata.db> as well
 as updating F<nohist_new_resevaldata.db> with information from  as updating F<nohist_new_resevaldata.db> with information from
 F<nohist_resevaldata.db>.  F<nohist_resevaldata.db>.
   
   It may need optmization, but since it gets called once a week. . .
 =over 4  =over 4
   
 Parameters:  Parameters:
Line 404  Returns: Line 401  Returns:
   
 sub build_on_the_fly_dynamic_metadata ($)  sub build_on_the_fly_dynamic_metadata ($)
   {    {
     # BEWARE ALL WHO TRY TO UNDERSTAND THIS ABSURDLY HORRIBLE SUBROUTINE.      # some elements in here maybe non-obvious
         
     # Do all sorts of mumbo-jumbo to compute the user's directory.      # Need to compute the user's directory.
     my $url = &declutter(shift(@_));      my $url = &declutter(shift(@_));
     $url =~ s/\.meta$//;      $url =~ s/\.meta$//;
     my %returnhash = ();      my %returnhash = ();
Line 444  sub build_on_the_fly_dynamic_metadata ($ Line 441  sub build_on_the_fly_dynamic_metadata ($
  # Untaint the url and use as part of a regular expression.   # Untaint the url and use as part of a regular expression.
  my $regexp = $url;   my $regexp = $url;
  $regexp =~ s/(\W)/\\$1/g;   $regexp =~ s/(\W)/\\$1/g;
  $regexp = '___'.$regexp.'___([a-z]+)$';   $regexp = '___'.$regexp.'___([a-z]+)$'; #' emacs
   
  # Check existing nohist database for this url.   # Check existing nohist database for this url.
  # THE ONLY TIME THIS IS IMPORTANT FOR THIS AWFUL SUBROUTINE          # this is modfying the 'count' entries
  # IS FOR 'count' ENTRIES          # and copying all othe entries over
  # AND FOR REFRESHING non-'count' ENTRIES INSIDE nohist_new DATABASE.  
  foreach (keys %evaldata)   foreach (keys %evaldata)
   {    {
     my $key = &unescape($_);      my $key = &unescape($_);
Line 494  sub build_on_the_fly_dynamic_metadata ($ Line 490  sub build_on_the_fly_dynamic_metadata ($
   }    }
  if ($ctype ne 'count')   if ($ctype ne 'count')
   {    {
     # ALERT!  THIS HORRIBLE LOOP IS ACTUALLY DOING SOMETHING                      # this is copying all data except 'count' attributes
     # USEFUL!  
     $newevaldata{$_} = $evaldata{$_};      $newevaldata{$_} = $evaldata{$_};
   }    }
       }        }
   }    }
   
  # THE ONLY OTHER TIME THIS LOOP IS USEFUL IS FOR THE 'count' HASH          # the only other time this loop is useful is for the 'count' hash
  # ELEMENT.          # element
  foreach (keys %cnt)   foreach (keys %cnt)
   {    {
     if ($listitems{$_} eq 'avg')      if ($listitems{$_} eq 'avg')
Line 519  sub build_on_the_fly_dynamic_metadata ($ Line 514  sub build_on_the_fly_dynamic_metadata ($
       }        }
   }    }
   
  # A RARE MOMENT OF DOING ANYTHING USEFUL INSIDE THIS          # seems to be doing something useful
  # BLEEPING SUBROUTINE.  
  if ($returnhash{'count'})   if ($returnhash{'count'})
   {    {
     my $newkey = $$.'_'.time.'_searchcat___'.&escape($url).'___count';      my $newkey = $$.'_'.time.'_searchcat___'.&escape($url).'___count';
Line 531  sub build_on_the_fly_dynamic_metadata ($ Line 525  sub build_on_the_fly_dynamic_metadata ($
  untie(%newevaldata); # Close/release the new nohist database.   untie(%newevaldata); # Close/release the new nohist database.
       }        }
     return(%returnhash);      return(%returnhash);
     # Celebrate!  We have now accomplished some simple calculations using  
     # 1000% bloated functionality in our subroutine.  Go wash your eyeballs  
     # out now.  
   }    }
   
 =pod  =pod

Removed from v.1.28  
changed lines
  Added in v.1.29


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>