protected function execute(InputInterface $input, OutputInterface $output)
 {
     $log_file = $input->getArgument('log_file');
     $date = $input->getArgument('date');
     $service = new Analyzer($log_file, $date);
     $results = $service->analyzeUserAccessTop20();
     $summary = [];
     foreach ($results as $date => $users) {
         if (!isset($summary[0])) {
             $summary[0] = '';
         }
         $summary[0] .= sprintf('"%s","","",', $date);
         $i = 1;
         foreach ($users as $user => $value) {
             if (!isset($summary[$i])) {
                 $summary[$i] = '';
             }
             $summary[$i] .= sprintf('"%s","%s","",', $user, $value);
             $i++;
         }
         if ($i != 21) {
             for (; $i < 21; $i++) {
                 $summary[$i] .= '"","","",';
             }
         }
     }
     foreach ($summary as $s) {
         $output->writeln($s);
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $log_file = $input->getArgument('log_file');
     $date = $input->getArgument('date');
     $service = new Analyzer($log_file, $date);
     $results = $service->analyzeBookCategory();
     foreach ($results as $val) {
         $output->writeln($val);
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $log_file = $input->getArgument('log_file');
     $date = $input->getArgument('date');
     $service = new Analyzer($log_file, $date);
     $results = $service->analyzeUserDateAccess();
     // display
     foreach ($results as $date => $value) {
         $output->writeln(sprintf('"%s","%s"', $date, $value));
     }
 }
Exemplo n.º 4
0
 /**
  * @test
  * @group analyze-book-category
  * @group analyze
  **/
 public function ブックカテゴリ別アクセス数を分析する()
 {
     $log = ROOT . DS . 'data' . DS . 'category.log.csv';
     $service = new Analyzer($log, '2015/04');
     $result = $service->analyzeBookCategory();
     $this->assertEquals(17, count($result));
 }