summaryrefslogtreecommitdiff
path: root/app/Console/ProjectDailySummaryCalculation.php
blob: 04c4083dbb45ba34b3dcce13894157f082c9ec49 (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
29
<?php

namespace Console;

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

class ProjectDailySummaryCalculation extends Base
{
    protected function configure()
    {
        $this
            ->setName('projects:daily-summary')
            ->setDescription('Calculate daily summary data 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->projectDailySummary->updateTotals($project['id'], date('Y-m-d'));
        }
    }
}