[Koha-cvs] koha C4/Biblio.pm catalogue/MARCdetail.pl catal... [rel_TG]

Tumer Garip tgarip at neu.edu.tr
Mon Apr 23 14:32:11 CEST 2007


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_TG
Changes by:	Tumer Garip <tgarip1957>	07/04/23 12:32:10

Modified files:
	C4             : Biblio.pm 
	catalogue      : MARCdetail.pl 
	cataloguing    : addbiblio.pl additem.pl 
	opac           : opac-MARCdetail.pl 

Log message:
	Optimizing biblioadd and marcdetail. Speed gain of 400% is achieved

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&only_with_tag=rel_TG&r1=1.187.2.4&r2=1.187.2.5
http://cvs.savannah.gnu.org/viewcvs/koha/catalogue/MARCdetail.pl?cvsroot=koha&only_with_tag=rel_TG&r1=1.8.2.2&r2=1.8.2.3
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/addbiblio.pl?cvsroot=koha&only_with_tag=rel_TG&r1=1.19.2.2&r2=1.19.2.3
http://cvs.savannah.gnu.org/viewcvs/koha/cataloguing/additem.pl?cvsroot=koha&only_with_tag=rel_TG&r1=1.12.2.3&r2=1.12.2.4
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-MARCdetail.pl?cvsroot=koha&only_with_tag=rel_TG&r1=1.14.4.2&r2=1.14.4.3

Patches:
Index: C4/Biblio.pm
===================================================================
RCS file: /sources/koha/koha/C4/Biblio.pm,v
retrieving revision 1.187.2.4
retrieving revision 1.187.2.5
diff -u -b -r1.187.2.4 -r1.187.2.5
--- C4/Biblio.pm	11 Apr 2007 11:54:03 -0000	1.187.2.4
+++ C4/Biblio.pm	23 Apr 2007 12:32:10 -0000	1.187.2.5
@@ -616,18 +616,12 @@
 
 sub MARCgettagslib {
 # warn "MARCgettagslib";
-    my ( $dbh, $forlibrarian, $frameworkcode ) = @_;
+    my ( $dbh, $forlibrarian, $frameworkcode,$flag ) = @_;
     $frameworkcode = "" unless $frameworkcode;
     my $sth;
     my $libfield = ( $forlibrarian eq 1 ) ? 'liblibrarian' : 'libopac';
 
-    # check that framework exists
-    $sth =
-      $dbh->prepare(
-        "select count(*) from biblios_tag_structure where frameworkcode=?");
-    $sth->execute($frameworkcode);
-    my ($total) = $sth->fetchrow;
-    $frameworkcode = "" unless ( $total > 0 );
+   
     $sth =
       $dbh->prepare(
 "select tagfield,liblibrarian,libopac,mandatory,repeatable from biblios_tag_structure where frameworkcode=? order by tagfield"
@@ -644,7 +638,7 @@
 
     $sth =
       $dbh->prepare(
-"select tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,authtypecode,value_builder,seealso,hidden,isurl,link from biblios_subfield_structure where frameworkcode=? order by tagfield,tagsubfield"
+"select tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,authtypecode,value_builder,seealso,hidden,isurl,link from biblios_subfield_structure where frameworkcode=? and tab<>-1 and substr(hidden,$flag,1)<2 order by tagfield,tagsubfield"
     );
     $sth->execute($frameworkcode);
 
@@ -682,18 +676,12 @@
 }
 sub MARCitemsgettagslib {
 # warn "MARCitemsgettagslib";
-    my ( $dbh, $forlibrarian, $frameworkcode ) = @_;
+    my ( $dbh, $forlibrarian, $frameworkcode,$flag ) = @_;
     $frameworkcode = "" unless $frameworkcode;
     my $sth;
     my $libfield = ( $forlibrarian eq 1 ) ? 'liblibrarian' : 'libopac';
 
-    # check that framework exists
-    $sth =
-      $dbh->prepare(
-        "select count(*) from holdings_tag_structure where frameworkcode=?");
-    $sth->execute($frameworkcode);
-    my ($total) = $sth->fetchrow;
-    $frameworkcode = "" unless ( $total > 0 );
+   
     $sth =
       $dbh->prepare(
 "select tagfield,liblibrarian,libopac,mandatory,repeatable from holdings_tag_structure where frameworkcode=? order by tagfield"
@@ -710,7 +698,7 @@
 
     $sth =
       $dbh->prepare(
-"select tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,authtypecode,value_builder,seealso,hidden,isurl,link from holdings_subfield_structure where frameworkcode=? order by tagfield,tagsubfield"
+"select tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,authtypecode,value_builder,seealso,hidden,isurl,link from holdings_subfield_structure where frameworkcode=? and tab<>-1 and substr(hidden,$flag,1)<2 order by tagfield,tagsubfield"
     );
     $sth->execute($frameworkcode);
 

Index: catalogue/MARCdetail.pl
===================================================================
RCS file: /sources/koha/koha/catalogue/MARCdetail.pl,v
retrieving revision 1.8.2.2
retrieving revision 1.8.2.3
diff -u -b -r1.8.2.2 -r1.8.2.3
--- catalogue/MARCdetail.pl	26 Mar 2007 02:19:21 -0000	1.8.2.2
+++ catalogue/MARCdetail.pl	23 Apr 2007 12:32:10 -0000	1.8.2.3
@@ -67,8 +67,8 @@
 my @itemrecords;
 my $xmlhash;
 $frameworkcode=MARCfind_frameworkcode($dbh,$biblionumber);
-my $tagslib = &MARCgettagslib($dbh,1,$frameworkcode);
-my $itemstagslib = &MARCitemsgettagslib($dbh,1,$frameworkcode);
+my $tagslib = &MARCgettagslib($dbh,1,$frameworkcode,2);
+my $itemstagslib = &MARCitemsgettagslib($dbh,1,$frameworkcode,2);
 
 if ($retrieve_from eq "zebra"){
 ($xmlhash, at itemrecords)=ZEBRAgetrecord($biblionumber);
@@ -131,7 +131,7 @@
 	my @subfields_data;
 
 	# deal with leader 
-	unless (($tagslib->{'000'}->{'@'}->{tab}  ne $tabloop)  || (substr($tagslib->{'000'}->{'@'}->{hidden},1,1)>0)) {
+	if (($tagslib->{'000'}->{'@'}->{tab}  eq $tabloop) && (substr($tagslib->{'000'}->{'@'}->{hidden},1,1) eq "0")) {
 		
 		my %subfield_data;
 		$subfield_data{marc_value}=$leader->[0] ;
@@ -235,7 +235,7 @@
 my $leader=$itemrecord->{'leader'};
 my %this_row;
 		### The leader
-		unless (substr($itemstagslib->{'000'}->{'@'}->{hidden},1,1)>0){
+		if (substr($itemstagslib->{'000'}->{'@'}->{hidden},1,1) eq "0"){
 			my @datasub='000@';
 			$witness{$datasub[0]} = $itemstagslib->{'000'}->{'@'}->{lib};
 			$this_row{$datasub[0]} =$leader->[0];

Index: cataloguing/addbiblio.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/addbiblio.pl,v
retrieving revision 1.19.2.2
retrieving revision 1.19.2.3
diff -u -b -r1.19.2.2 -r1.19.2.3
--- cataloguing/addbiblio.pl	26 Mar 2007 02:19:21 -0000	1.19.2.2
+++ cataloguing/addbiblio.pl	23 Apr 2007 12:32:10 -0000	1.19.2.3
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: addbiblio.pl,v 1.19.2.2 2007/03/26 02:19:21 tgarip1957 Exp $
+# $Id: addbiblio.pl,v 1.19.2.3 2007/04/23 12:32:10 tgarip1957 Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -33,7 +33,6 @@
 my $format="USMARC";
 $format="UNIMARC" if (C4::Context->preference('marcflavour') eq 'UNIMARC');
 use MARC::File::XML(RecordFormat =>$format);
-use Encode;
 use C4::Biblioadd;
 ####
 my $dbh = C4::Context->dbh;
@@ -114,7 +113,7 @@
 $xmlhash=XML_xml2hash_onerecord($record) if ($biblionumber);
 $frameworkcode=MARCfind_frameworkcode( $dbh, $biblionumber );
 ###########
-my $tagslib = &MARCgettagslib($dbh,1,$frameworkcode);
+my $tagslib = &MARCgettagslib($dbh,1,$frameworkcode,3);
 if ($suggestionid && !$biblionumber){
 my $data=GetSuggestion($suggestionid) ;
 $xml=$data->{xml};

Index: cataloguing/additem.pl
===================================================================
RCS file: /sources/koha/koha/cataloguing/additem.pl,v
retrieving revision 1.12.2.3
retrieving revision 1.12.2.4
diff -u -b -r1.12.2.3 -r1.12.2.4
--- cataloguing/additem.pl	11 Apr 2007 11:54:04 -0000	1.12.2.3
+++ cataloguing/additem.pl	23 Apr 2007 12:32:10 -0000	1.12.2.4
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: additem.pl,v 1.12.2.3 2007/04/11 11:54:04 tgarip1957 Exp $
+# $Id: additem.pl,v 1.12.2.4 2007/04/23 12:32:10 tgarip1957 Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -82,7 +82,7 @@
 my $itemrecexist; #item record we are editing
 my $xml; ## data on html
  $frameworkcode=MARCfind_frameworkcode($dbh,$biblionumber) unless $frameworkcode;
-my $tagslib = &MARCitemsgettagslib($dbh,1,$frameworkcode);
+my $tagslib = &MARCitemsgettagslib($dbh,1,$frameworkcode,3);
 my $itemrecord;
 my $nextop="additem";
 my @errors; # store errors found while checking data BEFORE saving item.

Index: opac/opac-MARCdetail.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-MARCdetail.pl,v
retrieving revision 1.14.4.2
retrieving revision 1.14.4.3
diff -u -b -r1.14.4.2 -r1.14.4.3
--- opac/opac-MARCdetail.pl	26 Mar 2007 00:07:52 -0000	1.14.4.2
+++ opac/opac-MARCdetail.pl	23 Apr 2007 12:32:10 -0000	1.14.4.3
@@ -64,9 +64,9 @@
 my $norequests=$query->param('norequests');
 my $biblionumber=$query->param('bib');
 my $frameworkcode=MARCfind_frameworkcode($dbh,$biblionumber);
-my $tagslib = &MARCgettagslib($dbh,0,$frameworkcode);
+my $tagslib = &MARCgettagslib($dbh,0,$frameworkcode,1);
 my @itemrecords;
-my $itemstagslib = &MARCitemsgettagslib($dbh,0,$frameworkcode);
+my $itemstagslib = &MARCitemsgettagslib($dbh,0,$frameworkcode,1);
 # open template
 my $record =XMLgetbiblio($dbh,$biblionumber);
 my $xmlhash=XML_xml2hash_onerecord($record);
@@ -110,7 +110,7 @@
 			my %subfield_data;
 			my %tag_data;
 			next if ($tagslib->{$control->{'tag'}}->{'@'}->{tab}  ne $tabloop);
-			next if (substr($tagslib->{$control->{'tag'}}->{'@'}->{hidden},0,1)>0);			
+			next if (substr($tagslib->{$control->{'tag'}}->{'@'}->{hidden},0,1) gt "0");			
 			$subfield_data{marc_value}=$control->{'content'} ;
 			push(@subfields_data, \%subfield_data);
 				if (C4::Context->preference('hide_marc')) {
@@ -130,7 +130,7 @@
 			my %subfield_data;
 			my %tag_data;
 			next if ($tagslib->{$control->{'tag'}}->{'@'}->{tab}  ne $tabloop);
-			next if (substr($tagslib->{$control->{'tag'}}->{'@'}->{hidden},1,1)>0);			
+			next if (substr($tagslib->{$control->{'tag'}}->{'@'}->{hidden},1,1) gt "0");			
 			$subfield_data{marc_value}=$control->{'content'} ;
 			push(@subfields_data, \%subfield_data);
 				if (C4::Context->preference('hide_marc')) {
@@ -212,14 +212,14 @@
 my $leader=$itemrecord->{'leader'};
 my %this_row;
 		### The leader
-		unless (substr($itemstagslib->{'000'}->{'@'}->{hidden},0,1)>0){
+		if (substr($itemstagslib->{'000'}->{'@'}->{hidden},0,1) eq "0"){
 			my @datasub='000@';
 			$witness{$datasub[0]} = $itemstagslib->{'000'}->{'@'}->{lib};
 			$this_row{$datasub[0]} =$leader->[0];
 		}
 		 foreach my $control (@$controlfields){
 		next if ($itemstagslib->{$control->{'tag'}}->{'@'}->{tab}  ne 10);
-			next if (substr($itemstagslib->{$control->{'tag'}}->{'@'}->{hidden},0,1)>0);
+			next if (substr($itemstagslib->{$control->{'tag'}}->{'@'}->{hidden},0,1) gt "0");
 			my @datasub=$control->{'tag'}.'@';
 			$witness{$datasub[0]} = $itemstagslib->{$control->{'tag'}}->{'@'}->{lib};
 			$this_row{$datasub[0]} =$control->{'content'};
@@ -229,7 +229,7 @@
 		   foreach my $subfield ( $data->{'subfield'}){
 			foreach my $code ( @$subfield){
 			next if ($itemstagslib->{$data->{'tag'}}->{$code->{'code'}}->{tab}  ne 10);
-			next if (substr($itemstagslib->{$data->{'tag'}}->{$code->{'code'}}->{hidden},0,1)>0);
+			next if (substr($itemstagslib->{$data->{'tag'}}->{$code->{'code'}}->{hidden},0,1) gt "0");
 			$witness{$data->{'tag'}.$code->{'code'}} = $itemstagslib->{$data->{'tag'}}->{$code->{'code'}}->{lib};
 			$this_row{$data->{'tag'}.$code->{'code'}} =get_authorised_value_desc($data->{'tag'}, $code->{'code'}, $code->{'content'}, '', $dbh);
 			}			





More information about the Koha-cvs mailing list