Rangliste almost done
This commit is contained in:
parent
12651fc2e8
commit
43fd8c8cbf
579 changed files with 172489 additions and 127 deletions
|
|
@ -20,7 +20,7 @@ class User extends Authenticatable
|
|||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password',
|
||||
'name', 'fullname', 'email', 'password',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -64,32 +64,69 @@ class User extends Authenticatable
|
|||
return null;
|
||||
}
|
||||
|
||||
public static function getScore($user_id) {
|
||||
|
||||
Log::info("User::getScore for userid=" . $user_id);
|
||||
|
||||
// Aufgerechnete Summe. wird $maxround_id mit übergeben, dann wird nur
|
||||
// bis zur entsprechenden Runde aufsummiert. Das setzt voraus, dass die
|
||||
// Runden in Reihenfolge eingegeben wurden...
|
||||
public static function getTotalScore($user_id,$maxround_id=1000000) {
|
||||
$season = Season::getCurrent();
|
||||
|
||||
$rounds = Round::where('season_id','=',$season->id)->get();
|
||||
|
||||
$totalScore=0;
|
||||
foreach($rounds as $round) {
|
||||
$games = Game::where('round_id','=',$round->id)->get();
|
||||
Log::info(' round_id=' . $round->id);
|
||||
foreach ($games as $game) {
|
||||
|
||||
Log::info(' game_id=' . $game->id);
|
||||
|
||||
$tipp = Tipp::getTipp($game->id,$user_id);
|
||||
$score = Tipp::getScore($tipp->id);
|
||||
|
||||
Log::info(" Game id=" . $game->id. ", Tipp id=". $tipp->id.", score=" . $score);
|
||||
|
||||
$totalScore+=$score;
|
||||
if ($round->id <= $maxround_id) {
|
||||
$totalScore += User::getRoundScore($user_id, $round->id);
|
||||
}
|
||||
}
|
||||
Log::info("Total score=" . $totalScore);
|
||||
return $totalScore;
|
||||
}
|
||||
|
||||
public static function getRoundScore($user_id, $round_id) {
|
||||
$games = Game::where('round_id','=',$round_id)->get();
|
||||
$totalScore=0;
|
||||
foreach ($games as $game) {
|
||||
$tipp = Tipp::getTipp($user_id,$game->id);
|
||||
$score = Tipp::getScore($tipp->id);
|
||||
$totalScore+=$score;
|
||||
}
|
||||
return $totalScore;
|
||||
}
|
||||
|
||||
// This totally does not belong here. But i am too afraid to put it into
|
||||
// a separate php file that gets smashed by autoregenerate.
|
||||
|
||||
public static function toGermanDate($engDate)
|
||||
{
|
||||
$values = explode("-", $engDate);
|
||||
$year = $values[0];
|
||||
$month = $values[1];
|
||||
$day = explode(" ", $values[2])[0];
|
||||
|
||||
$timeval = explode(" ", $engDate)[1];
|
||||
$hour = explode(":", $timeval)[0];
|
||||
$minute = explode(":", $timeval)[1];
|
||||
|
||||
return $day.".".$month.".".$year." ".$hour.":".$minute;
|
||||
}
|
||||
|
||||
public static function toDBDate($deDate)
|
||||
{
|
||||
$values = explode(" ", $deDate);
|
||||
|
||||
$year = explode(".",$values[0])[2];
|
||||
$month = explode(".",$values[0])[1];
|
||||
$day = explode(".", $values[0])[0];
|
||||
|
||||
Log::info("values[0]=".$values[0]." day=".$day."count=". count($values));
|
||||
|
||||
$hour="00";
|
||||
$minute="00";
|
||||
if (count($values)>1) {
|
||||
$hour = explode(":", $values[1])[0];
|
||||
$minute = explode(":", $values[1])[1];
|
||||
}
|
||||
|
||||
$dbDate=$year . "-" . $month . "-" . $day . " " . $hour . ":" . $minute . ":00";
|
||||
Log::info("deDate=".$deDate." converted to:".$dbDate);
|
||||
|
||||
return $dbDate;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue