Skip to content

Commit

Permalink
Fix statistik suara (chart)
Browse files Browse the repository at this point in the history
  • Loading branch information
billalxcode committed Jul 8, 2022
1 parent 6d2f0c1 commit 6903685
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/Controllers/Rest/Suara.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ public function getall()
public function getChart() {
$this->context['error'] = false;

// $suaraData = $this->suaraModel->db->query("SELECT created_at as y_date, TIME(created_at) as waktu, COUNT(id) as count FROM suara GROUP BY TIME(created_at) ORDER BY (y_date) ASC");
// $record = $suaraData->getResult();
$record = $this->suaraModel->select("COUNT(id) as count, created_at as waktu")->findAll();
$suaraData = $this->suaraModel->db->query("SELECT created_at as y_date, HOUR(created_at) as waktu, COUNT(id) as count FROM suara GROUP BY HOUR(created_at) ORDER BY (y_date) ASC");
$record = $suaraData->getResult();
$data = [];

foreach ($record as $row) {
$data['label'][] = $row['waktu'];
$data['data'][] = intval($row['count']);
$data['label'][] = $row->waktu;
$data['data'][] = intval($row->count);
}
$this->context['data'] = $data;
return $this->response->setJSON($this->context);
Expand Down

0 comments on commit 6903685

Please sign in to comment.