db = $db ?? App::getDb(); } /** * @return array */ public function getTeams(): array { $rows = $this->db->getRowset( 'SELECT id, TRIM(team_name) AS name FROM teams ORDER BY TRIM(team_name)' ); return array_map( static fn (array $row): array => [ 'id' => (int) $row['id'], 'name' => $row['name'], ], $rows ); } /** * @return array */ public function getSprintsByTeamId(int $teamId): array { $rows = $this->db->getRowset( 'SELECT id, jira_sprint_id, sprint_name, sprint_activate_datetime, sprint_complete_datetime, sprint_completion_percentage FROM sprints WHERE team_id = :team_id ORDER BY sprint_activate_datetime ASC', ['team_id' => $teamId] ); return array_map( static fn (array $row): array => [ 'id' => (int) $row['id'], 'jira_sprint_id' => (int) $row['jira_sprint_id'], 'sprint_name' => $row['sprint_name'], 'sprint_activate_datetime' => $row['sprint_activate_datetime'], 'sprint_complete_datetime' => $row['sprint_complete_datetime'], 'sprint_completion_percentage' => $row['sprint_completion_percentage'] !== null ? (float) $row['sprint_completion_percentage'] : null, ], $rows ); } }