[LON-CAPA-cvs] cvs: modules /gerd/harvesting lonrecommender.pm

www www at source.lon-capa.org
Sat Jul 14 09:58:17 EDT 2012


www		Sat Jul 14 13:58:17 2012 EDT

  Modified files:              
    /modules/gerd/harvesting	lonrecommender.pm 
  Log:
  Routine to load counts. All db-reads now incorporated
  
  
Index: modules/gerd/harvesting/lonrecommender.pm
diff -u modules/gerd/harvesting/lonrecommender.pm:1.3 modules/gerd/harvesting/lonrecommender.pm:1.4
--- modules/gerd/harvesting/lonrecommender.pm:1.3	Thu Jul 12 21:12:17 2012
+++ modules/gerd/harvesting/lonrecommender.pm	Sat Jul 14 13:58:17 2012
@@ -5,7 +5,7 @@
 #
 # MODIFY $datapath VARIABLE FOR LOCATION OF DATA FILES
 #
-# $Id: lonrecommender.pm,v 1.3 2012/07/12 21:12:17 www Exp $
+# $Id: lonrecommender.pm,v 1.4 2012/07/14 13:58:17 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -317,6 +317,21 @@
 }
 
 # =================================================================================
+# Return the access counts for resource IDs 
+
+sub counts {
+   my @urls=@_;
+   my %output=();
+   my %hash=();
+   tie(%hash, 'GDBM_File', $datapath.'dbfiles/count.db',&GDBM_READER(),0640);
+   foreach my $url (@urls) {
+      $output{$url}=$hash{$url};
+   }
+   untie(%hash);
+   return(%output);
+}
+
+# =================================================================================
 # Write a file in groupimport format
 #
 
@@ -374,9 +389,10 @@
 
     my %taxos=&taxoids(3,5,8,90,900,1450,13624,31415);
     my %urls=&urlres(3,5,8,90,900,1450,13624,31415);
+    my %counts=&counts(3,5,8,90,900,1450,13624,31415);
 
     foreach my $key (keys(%taxos)) {
-       $r->print($key.' '.$urls{$key}.' => '.$taxos{$key}.' '.$taxonomy_categories{'cleartext_'.$taxos{$key}}."<br />\n");
+       $r->print($key.' '.$urls{$key}.' '.$counts{$key}.' => '.$taxos{$key}.' '.$taxonomy_categories{'cleartext_'.$taxos{$key}}."<br />\n");
     }
 
     




More information about the LON-CAPA-cvs mailing list