Changeset 19768
- Timestamp:
- 09/23/08 21:55:46 (5 years ago)
- Location:
- lang/perl/App-Hachero/trunk
- Files:
-
- 4 added
- 5 removed
- 9 modified
- 1 moved
-
lib/App/Hachero/Plugin/Analyze/AccessCount.pm (modified) (1 diff)
-
lib/App/Hachero/Plugin/Analyze/Sample.pm (deleted)
-
lib/App/Hachero/Plugin/Analyze/UA.pm (deleted)
-
lib/App/Hachero/Plugin/Analyze/UserAgent.pm (modified) (1 diff)
-
lib/App/Hachero/Plugin/Output/DBIC.pm (modified) (1 diff)
-
lib/App/Hachero/Plugin/Output/HadoopReduce.pm (deleted)
-
lib/App/Hachero/Plugin/Output/TT.pm (added)
-
lib/App/Hachero/Plugin/OutputLine/HadoopMap.pm (modified) (1 diff)
-
lib/App/Hachero/Result.pm (added)
-
t/app/02_result.t (added)
-
t/plugin/analyze/01_ua.t (deleted)
-
t/plugin/analyze/02_accesscount.t (modified) (1 diff)
-
t/plugin/analyze/03_useragent.t (modified) (1 diff)
-
t/plugin/classify/03_useragent.t (moved) (moved from lang/perl/App-Hachero/trunk/t/plugin/classify/02_useragent.t)
-
t/plugin/output/01_dbic.t (modified) (3 diffs)
-
t/plugin/output/02_hadoop_reduce.t (deleted)
-
t/plugin/output/03_dbic_failure.t (modified) (1 diff)
-
t/plugin/output/04_tt.t (added)
-
t/plugin/output_line/01_hadoop_map.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/App-Hachero/trunk/lib/App/Hachero/Plugin/Analyze/AccessCount.pm
r19478 r19768 12 12 my $time = $req->{datetime}->clone->truncate(to => $truncate); 13 13 my $key = $time->epoch; 14 $context->result->{'AccessCount'}->{$key} = { 15 datetime => DateTime::Format::MySQL->format_datetime($time), 16 count => ($context->result->{'AccessCount'}->{$key}->{count} || 0) + 1, 17 } 14 $context->result->{AccessCount} ||= App::Hachero::Result::AccessCount->new; 15 $context->result->{AccessCount}->push( 16 { 17 datetime => DateTime::Format::MySQL->format_datetime($time), 18 } 19 ); 18 20 } 19 21 22 package App::Hachero::Result::AccessCount; 23 use base qw(App::Hachero::Result); 24 __PACKAGE__->mk_classdata(primary => ['datetime']); 25 20 26 1; -
lang/perl/App-Hachero/trunk/lib/App/Hachero/Plugin/Analyze/UserAgent.pm
r19505 r19768 16 16 my $key = $time->epoch.$browser_string; 17 17 18 $context->result->{'UserAgent'}->{$key} = { 19 datetime => DateTime::Format::MySQL->format_datetime($time), 20 useragent => $browser_string, 21 count => ($context->result->{'UserAgent'}->{$key}->{count} || 0) + 1, 22 }; 18 $context->result->{UserAgent} ||= App::Hachero::Result::UserAgent->new; 19 20 $context->result->{UserAgent}->push( 21 { 22 datetime => DateTime::Format::MySQL->format_datetime($time), 23 useragent => $browser_string, 24 } 25 ); 23 26 } 24 27 28 package App::Hachero::Result::UserAgent; 29 use base qw(App::Hachero::Result); 30 __PACKAGE__->mk_classdata('primary' => [qw(datetime useragent)]); 31 25 32 1; -
lang/perl/App-Hachero/trunk/lib/App/Hachero/Plugin/Output/DBIC.pm
r19336 r19768 8 8 my $schema = App::Hachero::Plugin::Output::DBIC::Schema 9 9 ->connect(@{$self->config->{config}->{connect_info}}); 10 unless ($schema) { 11 $context->log(error => "connection error"); 12 return; 13 } 10 14 for my $key (keys %{$context->result}) { 11 15 (my $table = $key) =~ s/\:\://g; 12 for (values %{$context->result->{$key}}) { 13 my $rs = eval {$schema->resultset($table)}; 14 $context->log(error => $!) if $@; 15 if ($rs) { 16 my $rs = eval {$schema->resultset($table)}; 17 if ($@) { 18 $context->log(error => $!); 19 next; 20 } 21 if ($rs) { 22 my $result = $context->result->{$key}; 23 for my $data ($result->values) { 16 24 eval { 17 $rs->update_or_create($ _)25 $rs->update_or_create($data) 18 26 }; 19 27 if ($@) { 20 28 $context->log(error => $!); 21 29 } 22 } else {23 $context->log(error => "$table not found");24 30 } 31 } else { 32 $context->log(error => "$table not found"); 25 33 } 26 34 } -
lang/perl/App-Hachero/trunk/lib/App/Hachero/Plugin/OutputLine/HadoopMap.pm
r19363 r19768 11 11 local $Data::Dumper::Terse = 0; 12 12 for my $prime_key (keys %{$context->result}) { 13 my $result = $context->result->{$prime_key} ;13 my $result = $context->result->{$prime_key}->data; 14 14 for my $second_key (keys %{$result}) { 15 15 my $value = Dumper $result->{$second_key}; -
lang/perl/App-Hachero/trunk/t/plugin/analyze/02_accesscount.t
r19262 r19768 33 33 $app->run_hook('parse'); 34 34 $app->run_hook('analyze'); 35 my $value = (values %{$app->result->{AccessCount} })[0];35 my $value = (values %{$app->result->{AccessCount}->data})[0]; 36 36 is_deeply $value, $block->expected; 37 37 } -
lang/perl/App-Hachero/trunk/t/plugin/analyze/03_useragent.t
r19499 r19768 37 37 $app->run_hook('classify'); 38 38 $app->run_hook('analyze'); 39 my $value = (values %{$app->result->{UserAgent}})[0]; 39 my $res = $app->result->{UserAgent}; 40 my $value = (values %{$app->result->{UserAgent}->data})[0]; 40 41 is_deeply $value, $block->expected; 41 42 } -
lang/perl/App-Hachero/trunk/t/plugin/output/01_dbic.t
r18806 r19768 3 3 use Test::Base; 4 4 use App::Hachero; 5 use App::Hachero::Result; 5 6 use App::Hachero::Plugin::Output::DBIC; 6 7 … … 41 42 my $rs = $schema->resultset($exp->{tablename}); 42 43 $rs->delete_all; 43 $app->result($block->input); 44 my ($key, $value) = %{$block->input}; 45 my $res = App::Hachero::Result->new; 46 for (@{$value}) { 47 $res->primary([ keys %{$_} ]) unless $res->primary; 48 $res->push($_); 49 } 50 $app->result({$key => $res}); 44 51 $app->run_hook('output'); 45 52 my @rows = $rs->all; … … 58 65 --- input 59 66 AccessCount: 60 '2008-08-21 18:13:00': 61 datetime: '2008-08-21 18:13:00' 62 count: 5 63 '2008-08-21 18:14:00': 64 datetime: '2008-08-21 18:14:00' 65 count: 2 67 - datetime: '2008-08-21 18:13:00' 68 - datetime: '2008-08-21 18:13:00' 69 - datetime: '2008-08-21 18:13:00' 70 - datetime: '2008-08-21 18:13:00' 71 - datetime: '2008-08-21 18:13:00' 72 - datetime: '2008-08-21 18:14:00' 73 - datetime: '2008-08-21 18:14:00' 66 74 --- expected 67 75 tablename: AccessCount -
lang/perl/App-Hachero/trunk/t/plugin/output/03_dbic_failure.t
r19499 r19768 24 24 connect_info => [ 25 25 'dbi:mysql:test', 26 'root',27 26 ], 28 27 } -
lang/perl/App-Hachero/trunk/t/plugin/output_line/01_hadoop_map.t
r19721 r19768 3 3 use Test::More tests => 3; 4 4 use App::Hachero; 5 use App::Hachero::Result; 5 6 use URI; 6 7 use File::Temp; 7 8 use IO::All; 9 use Digest::MD5 qw(md5_hex); 8 10 9 11 BEGIN { … … 27 29 28 30 my $app = App::Hachero->new({config => $config}); 29 $app->result({ 30 foo => { 31 bar => {a => 1, b => 2}, 32 } 33 });34 31 my $res = App::Hachero::Result->new; 32 $res->primary(['a']); 33 $res->push({a => 1}); 34 my $primary = 'foo'; 35 my $secondary = md5_hex(1); 36 $app->result({$primary => $res}); 35 37 $app->run_hook('output_line'); 36 38 close STDOUT; … … 39 41 my ($key,$value) = split(/\t/,$contents); 40 42 41 is $key, 'foo-bar';43 is $key, "$primary-$secondary"; 42 44 my $VAR1; 43 45 eval $value; 44 is_deeply $VAR1, {a => 1, b => 2};46 is_deeply $VAR1, {a => 1, count => 1};
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)