/[webpac2]/Webpacus/lib/Webpacus/Model/WebPAC.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /Webpacus/lib/Webpacus/Model/WebPAC.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 385 by dpavlin, Sun Jan 22 11:32:40 2006 UTC revision 400 by dpavlin, Sun Feb 19 13:14:26 2006 UTC
# Line 12  use File::Slurp; Line 12  use File::Slurp;
12  use Time::HiRes qw/time/;  use Time::HiRes qw/time/;
13  use Encode qw/encode decode from_to/;  use Encode qw/encode decode from_to/;
14  use Template;  use Template;
 use Data::Dumper;  
15    
16  =head1 NAME  =head1 NAME
17    
# Line 66  sub new { Line 65  sub new {
65    
66          $est_cfg->{encoding} = $est_cfg->{catalyst_encoding} || $c->config->{catalyst_encoding} or $c->log->fatal("can't find catalyst_encoding");          $est_cfg->{encoding} = $est_cfg->{catalyst_encoding} || $c->config->{catalyst_encoding} or $c->log->fatal("can't find catalyst_encoding");
67    
68          $log->debug("using config:" . Dumper($est_cfg) );          $log->dumper($est_cfg, 'est_cfg');
69    
70          if (! $est_cfg->{database}) {          if (! $est_cfg->{database}) {
71                  my $defaultnode = $est_cfg->{defaultnode} || $log->logdie("can't find defaultnode in estraier configuration");                  my $defaultnode = $est_cfg->{defaultnode} || $log->logdie("can't find defaultnode in estraier configuration");
# Line 87  sub new { Line 86  sub new {
86          $log->fatal("can't create Search::Estraier::Node $url") unless ($self->{est_node});          $log->fatal("can't create Search::Estraier::Node $url") unless ($self->{est_node});
87    
88          # save config parametars in object          # save config parametars in object
89          foreach my $f (qw/db_path template_path hits_on_page webpac_encoding defaultdepth/) {          foreach my $f (qw/
90                    db_path template_path hits_on_page webpac_encoding defaultdepth
91                    masterurl defaultnode
92                    /) {
93                  $self->{$f} = $c->config->{hyperestraier}->{$f} ||                  $self->{$f} = $c->config->{hyperestraier}->{$f} ||
94                          $c->config->{webpac}->{$f};                          $c->config->{webpac}->{$f};
95                  $log->debug("self->{$f} = " . $self->{$f});                  $log->debug("self->{$f} = " . $self->{$f});
# Line 138  sub new { Line 140  sub new {
140    
141  }  }
142    
143    =head2 setup_site
144    
145     $self->setup_site('site_name');
146    
147    Change node URL and database name according to site name (if available) or fallback
148    to C<defaultnode> from configuration.
149    
150    =cut
151    
152    sub setup_site {
153            my $self = shift;
154    
155            my $site = shift || $self->{defaultnode};
156    
157            $self->{log}->fatal("setup_site can't find site or defaultnode") unless ($site);
158    
159            my $url = $self->{masterurl} . '/node/' . $site;
160            $self->{est_node}->set_url( $url );
161            $self->{log}->debug("setup_site $site using $url");
162    }
163    
164  =head2 search  =head2 search
165    
# Line 165  sub search { Line 187  sub search {
187    
188          my $log = $self->{log};          my $log = $self->{log};
189    
190          $log->debug("search args: " . Dumper( $args ));          $log->dumper($args, 'args');
191    
192          my $query = $args->{phrase} || $log->warn("no query phrase") && return;          my $query = $args->{phrase} || $log->warn("no query phrase") && return;
193    
# Line 223  sub search { Line 245  sub search {
245    
246          $log->debug( sprintf("search took %.6fs and returned $hits hits.", $times->{est}) );          $log->debug( sprintf("search took %.6fs and returned $hits hits.", $times->{est}) );
247    
248          $log->debug( "hints: " . Dumper($result->{hints}) );          $log->dumper($result->{hints}, 'result->hints' );
249    
250          #          #
251          # fetch results          # fetch results
# Line 278  sub search { Line 300  sub search {
300    
301                          $times->{db} += time() - $t;                          $times->{db} += time() - $t;
302    
                         #$log->debug( "ds = " . Dumper( \@html_results ) );  
   
303                          $t = time();                          $t = time();
304    
305                          my $html = $self->apply(                          my $html = $self->apply(
# Line 302  sub search { Line 322  sub search {
322    
323          }          }
324    
         #$log->debug( '@results = ' . Dumper( \@results ) );  
   
325          $log->debug( sprintf(          $log->debug( sprintf(
326                  "duration breakdown: estraier %.6fs, hash %.6fs, store %.6fs, apply %.6fs, decode %.06f, total: %.6fs",                  "duration breakdown: estraier %.6fs, hash %.6fs, store %.6fs, apply %.6fs, decode %.06f, total: %.6fs",
327                  $times->{est}, $times->{hash}, $times->{db}, $times->{apply}, $times->{decode}, time() - $search_start_t,                  $times->{est}, $times->{hash}, $times->{db}, $times->{apply}, $times->{decode}, time() - $search_start_t,
# Line 329  sub record { Line 347  sub record {
347    
348          my $args = {@_};          my $args = {@_};
349          my $log = $self->{log};          my $log = $self->{log};
350          $log->debug("record args: " . Dumper( $args ));          $log->dumper( $args, 'args' );
351    
352          foreach my $f (qw/record_uri template/) {          foreach my $f (qw/record_uri template/) {
353                  $log->fatal("need $f") unless ($args->{$f});                  $log->fatal("need $f") unless ($args->{$f});

Legend:
Removed from v.385  
changed lines
  Added in v.400

  ViewVC Help
Powered by ViewVC 1.1.26