add 12NächteChallenge2021

This commit is contained in:
marko
2021-12-21 10:21:17 +01:00
parent 0c4334990e
commit 40efdcea23
2 changed files with 33 additions and 8 deletions

View File

@@ -33,14 +33,19 @@ class record{
}
public static function getTopAchievers($options=array()){
$query = <<<SQL
SELECT `wkParticipo_Users`.`vorname`, `wkParticipo_Users`.`name`, COUNT(*)
FROM `achievements<=>user`
JOIN `wkParticipo_Users`
ON `wkParticipo_Users`.`id` = `achievements<=>user`.`userId`
GROUP BY `wkParticipo_Users`.`id`
ORDER BY `COUNT(*)` DESC;
SQL;
$from = array_key_exists('from',$options)?$options['from']:null;
$to = array_key_exists('to',$options)?$options['to']:null;
$query =
"SELECT `wkParticipo_Users`.`vorname`, `wkParticipo_Users`.`name`, COUNT(*) ".
"FROM `achievements<=>user` JOIN `wkParticipo_Users` ".
"ON `wkParticipo_Users`.`id` = `achievements<=>user`.`userId` ".
(
($from!=null&&$to!=null)?
("BETWEEN CONVERT(\"".$from."\", datetime) AND CONVERT(\"".$to."\", datetime) "):
("")
).
"GROUP BY `wkParticipo_Users`.`id` ".
"ORDER BY `COUNT(*)` DESC;";
return dbQuery(self::$db, $query);
}