diff --git a/homepage/machs/index.php b/homepage/machs/index.php
index d088723..2b946a9 100644
--- a/homepage/machs/index.php
+++ b/homepage/machs/index.php
@@ -52,6 +52,26 @@ processPostData($dbConnection, $_POST);
+12-Nächte-Challenge");
+ if($now < $from) echo("Die 12-Nächte-Challenge geht vom 24.12.2021--06.01.2022. Ziel ist es möglichts an allen Tagen ein Achievement zu erhalten. Sobald es losgeht, wird hier die aktuelle Rangliste stehen.");
+ record::setDbConnection($dbConnection);
+ $zwölfer = record::getTopAchievers(array('from'=>"2021-12-24", 'to'=>"2022-01-06"));
+ echo("
");
+ record::setDbConnection($dbConnection);
+ foreach( record::getTopAchievers(array('from'=>"2021-12-24", 'to'=>"2022-01-06")) as $t ){
+ echo("| ".$t['vorname']." | ".$t['name']." | ".$t['COUNT(*)']." |
");
+ }
+ echo("
");
+ }
+?>
+
Eigene Achievements" );
diff --git a/homepage/machs/lib/record.php b/homepage/machs/lib/record.php
index df1b1ac..01f5f13 100644
--- a/homepage/machs/lib/record.php
+++ b/homepage/machs/lib/record.php
@@ -33,14 +33,19 @@ class record{
}
public static function getTopAchievers($options=array()){
- $query = <<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);
}