summaryrefslogtreecommitdiff
path: root/app/Console/ProjectDailyStatsCalculation.php
blob: 4b77c55634e8dafe408956965925309cb30b3395 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php

namespace Console;

use Model\Project;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ProjectDailyStatsCalculation extends Base
{
    protected function configure()
    {
        $this
            ->setName('projects:daily-stats')
            ->setDescription('Calculate daily statistics for all projects');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $projects = $this->project->getAllByStatus(Project::ACTIVE);

        foreach ($projects as $project) {
            $output->writeln('Run calculation for '.$project['name']);
            $this->projectDailyColumnStats->updateTotals($project['id'], date('Y-m-d'));
            $this->projectDailyStats->updateTotals($project['id'], date('Y-m-d'));
        }
    }
}