| <?php |
|
|
| namespace Kanboard\Model; |
|
|
| use Kanboard\Core\Base; |
|
|
| |
| |
| |
| |
| |
| |
| class ProjectDailyStatsModel extends Base |
| { |
| |
| |
| |
| |
| |
| const TABLE = 'project_daily_stats'; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| public function updateTotals($project_id, $date) |
| { |
| $this->db->startTransaction(); |
|
|
| $lead_cycle_time = $this->averageLeadCycleTimeAnalytic->build($project_id); |
|
|
| $this->db->table(self::TABLE)->eq('day', $date)->eq('project_id', $project_id)->remove(); |
|
|
| $this->db->table(self::TABLE)->insert(array( |
| 'day' => $date, |
| 'project_id' => $project_id, |
| 'avg_lead_time' => $lead_cycle_time['avg_lead_time'], |
| 'avg_cycle_time' => $lead_cycle_time['avg_cycle_time'], |
| )); |
|
|
| $this->db->closeTransaction(); |
|
|
| return true; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| public function getRawMetrics($project_id, $from, $to) |
| { |
| $metrics = $this->db->table(self::TABLE) |
| ->columns('day', 'avg_lead_time', 'avg_cycle_time') |
| ->eq('project_id', $project_id) |
| ->gte('day', $from) |
| ->lte('day', $to) |
| ->asc('day') |
| ->findAll(); |
|
|
| foreach ($metrics as &$metric) { |
| $metric['avg_lead_time'] = (int) $metric['avg_lead_time']; |
| $metric['avg_cycle_time'] = (int) $metric['avg_cycle_time']; |
| } |
|
|
| return $metrics; |
| } |
| } |
|
|