mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-04 02:14:06 +02:00
split off infocontroller
This commit is contained in:
parent
7a6ff09eee
commit
66d177e23a
6 changed files with 55 additions and 36 deletions
23
src/Providers/InfoProvider.php
Normal file
23
src/Providers/InfoProvider.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php namespace Demostf\API\Providers;
|
||||
|
||||
class InfoProvider extends BaseProvider {
|
||||
public function listMaps() {
|
||||
$sql = 'SELECT DISTINCT(map), COUNT(map) AS count from demos GROUP BY map ORDER BY count DESC';
|
||||
$result = $this->query($sql);
|
||||
return $result->fetchAll(\PDO::FETCH_COLUMN);
|
||||
}
|
||||
|
||||
public function getStats() {
|
||||
$demoCount = $this->db->demo()->count();
|
||||
$playerCount = $this->db->user()->count();
|
||||
|
||||
$sql = 'SELECT count(user_id) FROM players GROUP BY user_id';
|
||||
$result = $this->query($sql);
|
||||
|
||||
return [
|
||||
'demos' => $demoCount,
|
||||
'players' => $playerCount,
|
||||
'uploaders' => $result->fetchColumn()
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue