TimeLogger moved, League ranking also for not completed but started rounds
This commit is contained in:
parent
78a4a04cdf
commit
90c6d60ecd
26 changed files with 692 additions and 376 deletions
|
|
@ -9,7 +9,7 @@ use Carbon\Carbon;
|
|||
use Auth;
|
||||
use App\User;
|
||||
use Log;
|
||||
|
||||
use App\MyClasses\TimeLogger;
|
||||
|
||||
class GamesController extends Controller
|
||||
{
|
||||
|
|
@ -23,8 +23,11 @@ class GamesController extends Controller
|
|||
|
||||
public function store() {
|
||||
if (Auth::guest()) { return redirect("/login"); }
|
||||
// Validate form
|
||||
|
||||
$a=new TimeLogger("GamesController::store");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
// Validate form
|
||||
Log::info("Starting validation");
|
||||
$this->validate(request(), [
|
||||
'id' => 'required',
|
||||
|
|
@ -60,6 +63,8 @@ class GamesController extends Controller
|
|||
$game->kickoff=User::toDBDate(request('kickoff'));
|
||||
$game->save();
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
|
||||
// Redirect to the Rounds Index
|
||||
return redirect('/rounds#'.$game->round_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,14 @@ use App\Leagues\Match;
|
|||
use Log;
|
||||
use DB;
|
||||
|
||||
use App\MyClasses\TimeLogger;
|
||||
|
||||
class LeaguesController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
$a=new TimeLogger("LeaguesController.index");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$season=Season::getCurrent();
|
||||
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
|
|
@ -62,14 +67,18 @@ class LeaguesController extends Controller
|
|||
|
||||
//
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
|
||||
return view('leagues.index', compact('season','rounds','start_round_id','start_round_name','league_mode','round_count'));
|
||||
}
|
||||
|
||||
public function createLeagues($start_round_id, $round_count) {
|
||||
|
||||
$a=new TimeLogger("LeaguesController::createLeagues()");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$users=User::getActives();
|
||||
if (sizeof($users)==0){
|
||||
Log::info($a->getEndMessage());
|
||||
return view("leagues.no_users");
|
||||
}
|
||||
|
||||
|
|
@ -79,12 +88,16 @@ class LeaguesController extends Controller
|
|||
|
||||
Match::createMatchups();
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
return redirect("/seasons");
|
||||
}
|
||||
|
||||
public function showLeagueRounds() {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
|
||||
$a=new TimeLogger("LeaguesController::showLeagueRounds()");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$season=Season::getCurrent();
|
||||
|
||||
$roundNames = Round::getNames();
|
||||
|
|
@ -106,18 +119,26 @@ class LeaguesController extends Controller
|
|||
$matchesTotal[$match->round_id][$league->id] = $lg;
|
||||
}
|
||||
}
|
||||
Log::info($a->getEndMessage());
|
||||
|
||||
return view ('leagues.matches', compact('season', 'matchesTotal','leagues','leagueNames','roundNames'));
|
||||
}
|
||||
|
||||
public static function showLeagueRanking() {
|
||||
|
||||
$a=new TimeLogger("LeaguesController::showLeagueRanking()");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$season = Season::getCurrent();
|
||||
//$leagues = array_reverse(League::getRanking($rank));
|
||||
$leagueNames = League::getNames();
|
||||
$userNames = User::getNames();
|
||||
|
||||
$leagues = League::where('season_id','=',$season->id)->where('rank','<=', 4)->orderBy('id')->get();
|
||||
if (!sizeof($leagues)) return redirect("/");
|
||||
if (!sizeof($leagues)) {
|
||||
Log::info($a->getEndMessage());
|
||||
return redirect("/");
|
||||
}
|
||||
|
||||
$totalRanking = League::getTotalRankingOverall(); // Nur für Auf/Abstiegsinfo benötigt.
|
||||
$rankInfo=array();
|
||||
|
|
@ -138,6 +159,9 @@ class LeaguesController extends Controller
|
|||
$leagueScores[$rank] = League::getRanking($rank);
|
||||
}
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
//error_log($a->getEndMessage());
|
||||
|
||||
return view ('leagues.chart',compact('season', 'leagueNames', 'userNames','leagueScores','rankInfo','rank','cols'));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use Auth;
|
|||
use DB;
|
||||
use Log;
|
||||
use Carbon;
|
||||
use App\MyClasses\TimeLogger;
|
||||
|
||||
class RoundmailController extends Controller
|
||||
{
|
||||
|
|
@ -22,6 +23,9 @@ class RoundmailController extends Controller
|
|||
if (Auth::guest()) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
|
||||
$a=new TimeLogger("RoundmailController::index()");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$mails_db = Roundmail::all();
|
||||
$mails=array();
|
||||
foreach($mails_db as $mail_db) {
|
||||
|
|
@ -39,6 +43,8 @@ class RoundmailController extends Controller
|
|||
}
|
||||
$mails=array_reverse($mails);
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
|
||||
return view('roundmails.index',compact('mails'));
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +52,9 @@ class RoundmailController extends Controller
|
|||
if (Auth::guest()) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
|
||||
$a=new TimeLogger("RoundmailController::show start");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$user_id=Auth::user()->id;
|
||||
|
||||
$users = DB::table('users')->where('deleted',null)->orderBy('lastname')->get();
|
||||
|
|
@ -124,6 +133,8 @@ class RoundmailController extends Controller
|
|||
if ($sender) {$sender_name = $sender->name;}
|
||||
}
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
|
||||
return view('roundmails.show',compact('mail_id','activeMailList','inactiveMailList','missingTippMailList','missingJokerMailList','adminMailList','send_date','user_id','topic', 'mail_message', 'recipients', 'sender_name','viewmode','tippSpielLink'));
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use App\Quota;
|
|||
use DB;
|
||||
use Auth;
|
||||
use Log;
|
||||
use App\MyClasses\TimeLogger;
|
||||
|
||||
class RoundsController extends Controller
|
||||
{
|
||||
|
|
@ -19,6 +20,9 @@ class RoundsController extends Controller
|
|||
if (Auth::guest()) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
|
||||
$a=new TimeLogger("RoundsController::index()");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$activeSeason=Season::getCurrent();
|
||||
$rounds =null;
|
||||
|
||||
|
|
@ -30,6 +34,8 @@ class RoundsController extends Controller
|
|||
$quotas = Quota::getQuotas();
|
||||
$round_count = Round::getCount();
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
|
||||
return view('rounds.index', compact('rounds','activeSeason', 'round_count'));
|
||||
|
||||
}
|
||||
|
|
@ -51,6 +57,9 @@ class RoundsController extends Controller
|
|||
if (Auth::guest()) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
|
||||
$a=new TimeLogger("RoundsController::store() start");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
// Validate form
|
||||
$this->validate(request(), [
|
||||
'name' => 'required',
|
||||
|
|
@ -108,6 +117,8 @@ class RoundsController extends Controller
|
|||
|
||||
Tipp::createAllTips();
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
|
||||
// Redirect to the home page
|
||||
return redirect('/rounds');
|
||||
}
|
||||
|
|
@ -116,6 +127,9 @@ class RoundsController extends Controller
|
|||
if (Auth::guest()) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
|
||||
$a=new TimeLogger("RoundsController::store_report()");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
// Validate form
|
||||
$this->validate(request(), [
|
||||
'round_id' => 'required'
|
||||
|
|
@ -133,6 +147,7 @@ class RoundsController extends Controller
|
|||
}
|
||||
$round->save();
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
|
||||
// Redirect to the home page
|
||||
return redirect('/rounds');
|
||||
|
|
@ -150,6 +165,9 @@ class RoundsController extends Controller
|
|||
if (Auth::guest()) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
|
||||
$a=new TimeLogger("RoundsController::storename()");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
// Validate form
|
||||
$this->validate(request(), [
|
||||
'round_id' => 'required',
|
||||
|
|
@ -160,6 +178,8 @@ class RoundsController extends Controller
|
|||
$round->name = request('name');
|
||||
$round->save();
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
|
||||
return redirect('/rounds');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,17 @@ use Auth;
|
|||
use Log;
|
||||
use DB;
|
||||
|
||||
use App\MyClasses\TimeLogger;
|
||||
|
||||
class TippsController extends Controller
|
||||
{
|
||||
//Duplicate from Tipps model
|
||||
//TODO: Refactor usage to use only the Tipps version
|
||||
public static function createTipps($user_id) {
|
||||
|
||||
$a=new TimeLogger("TippsController::createTipps()");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$activeSeason = Season::getCurrent();
|
||||
|
||||
$rounds = Round::all()->where('season_id', '=', $activeSeason->id);
|
||||
|
|
@ -44,15 +49,22 @@ class TippsController extends Controller
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
|
||||
}
|
||||
|
||||
//Duplicate from Tipps model
|
||||
//TODO: Refactor usage to use only the Tipps version
|
||||
public static function createAllTips(){
|
||||
$a=new TimeLogger("TippsController::createAllTipps()");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$users = DB::table('users')->where('deleted',null)->get();
|
||||
foreach($users as $user) {
|
||||
TippsController::createTipps($user->id);
|
||||
}
|
||||
Log::info($a->getEndMessage());
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
|
|
|||
|
|
@ -22,10 +22,15 @@ use Auth;
|
|||
use Log;
|
||||
|
||||
use Carbon;
|
||||
use App\MyClasses\TimeLogger;
|
||||
|
||||
class UsersController extends Controller
|
||||
{
|
||||
public function main() {
|
||||
$a=new TimeLogger("UsersController::main()");
|
||||
Log::info($a->getStartMessage());
|
||||
//error_log($a->getStartMessage());
|
||||
|
||||
$currentSeason=Season::getCurrent();
|
||||
$roundname="";
|
||||
$report="";
|
||||
|
|
@ -90,15 +95,30 @@ class UsersController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
//error_log($a->getEndMessage());
|
||||
|
||||
return view('main',compact('roundname','display_rounds','message_text_joker','message_text_tipps','nextRoundName','nextRoundLockTime', 'hourDiffToLock'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function index() {
|
||||
$a=new TimeLogger("UserController::index()");
|
||||
Log::info($a->getStartMessage());
|
||||
//error_log($a->getStartMessage());
|
||||
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
if (!Auth::user()->admin) { return redirect("/"); }
|
||||
|
||||
$activeUsers = User::getActives();
|
||||
|
||||
$b=new TimeLogger("UsersController::index-db_subqueries");
|
||||
Log::info($b->getStartMessage());
|
||||
|
||||
$currentSeason=Season::getCurrent();
|
||||
if (!$currentSeason) { return redirect('/'); }
|
||||
|
||||
|
|
@ -107,28 +127,45 @@ class UsersController extends Controller
|
|||
|
||||
$users = DB::table('users')->where('deleted',null)->orderBy('lastname')->get();
|
||||
|
||||
foreach($users as $key => $user) {
|
||||
if (User::hasMissingTipp($user->id)) {
|
||||
$users[$key]->missingTippText="Tipps fehlen";
|
||||
$users[$key]->tippStyling="red";
|
||||
Log::info($b->getEndMessage());
|
||||
|
||||
|
||||
Log::info($a->getStartMessage());
|
||||
$missingTipps = User::getMissingTippsAndJokers($users);
|
||||
|
||||
$c=new TimeLogger("UsersController::index-missingTipp Loop");
|
||||
Log::info($c->getStartMessage());
|
||||
|
||||
|
||||
foreach($users as $user_id => $user) {
|
||||
if (array_key_exists($user_id, $missingTipps["MISSING_TIPP"])) {
|
||||
$users[$user_id]->missingTippText = "Tipps fehlen";
|
||||
$users[$user_id]->tippStyling = "red";
|
||||
} else {
|
||||
$users[$key]->missingTippText="Runde getippt";
|
||||
$users[$key]->tippStyling="green";
|
||||
$users[$user_id]->missingTippText = "Runde getippt";
|
||||
$users[$user_id]->tippStyling = "green";
|
||||
}
|
||||
if (User::hasMissingJoker($user->id)) {
|
||||
$users[$key]->missingJokerText="Joker fehlt";
|
||||
$users[$key]->jokerStyling="red";
|
||||
|
||||
|
||||
if (array_key_exists($user_id, $missingTipps["MISSING_JOKER"])) {
|
||||
$users[$user_id]->missingJokerText = "Joker fehlt";
|
||||
$users[$user_id]->jokerStyling = "red";
|
||||
} else {
|
||||
$users[$key]->missingJokerText="Joker gesetzt";
|
||||
$users[$key]->jokerStyling="green";
|
||||
$users[$user_id]->missingJokerText = "Joker gesetzt";
|
||||
$users[$user_id]->jokerStyling = "green";
|
||||
}
|
||||
}
|
||||
|
||||
Log::info($c->getEndMessage());
|
||||
|
||||
$round = Round::getFirstTippableRound();
|
||||
$firstTippableRound=new Round();
|
||||
$firstTippableRound->name="-";
|
||||
if ($round) { $firstTippableRound = $round; }
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
//error_log($a->getEndMessage());
|
||||
|
||||
return view('users.index', compact('users','active_user_count','total_user_count', 'firstTippableRound'));
|
||||
}
|
||||
/*
|
||||
|
|
@ -160,6 +197,11 @@ class UsersController extends Controller
|
|||
|
||||
public function store() {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
|
||||
$a=new TimeLogger("UsersController::store()");
|
||||
Log::info($a->getStartMessage());
|
||||
//error_log($a->getStartMessage());
|
||||
|
||||
$season_id = Season::getCurrent()->id;
|
||||
// Validate form
|
||||
$this->validate(request(), [
|
||||
|
|
@ -194,6 +236,9 @@ class UsersController extends Controller
|
|||
|
||||
Tipp::createAllTips();
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
//error_log($a->getEndMessage());
|
||||
|
||||
return redirect('/users');
|
||||
}
|
||||
|
||||
|
|
@ -657,28 +702,28 @@ class UsersController extends Controller
|
|||
|
||||
|
||||
|
||||
public function gshirt_ranking() {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
public function gshirt_ranking() {
|
||||
if (Auth::guest()) { return redirect("/"); }
|
||||
|
||||
// Check ob mindestens eine Runde der Saison gelockt ist und angezeigt werden kann
|
||||
// Check ob mindestens eine Runde der Saison gelockt ist und angezeigt werden kann
|
||||
|
||||
$season=Season::getCurrent();
|
||||
$seasonId=$season->id;
|
||||
$season=Season::getCurrent();
|
||||
$seasonId=$season->id;
|
||||
|
||||
$max_round_id = Round::getLastCompleteRoundId();
|
||||
if ($max_round_id==-1) {
|
||||
$max_round_id = Round::getLastCompleteRoundId();
|
||||
if ($max_round_id==-1) {
|
||||
|
||||
$sql="select DATE_FORMAT(date_sub(min(games.kickoff), interval 1 hour),'%d.%m.%Y %H:%i') as start_date from rounds,games where rounds.season_id=".$seasonId." and games.round_id=rounds.id order by rounds.id;";
|
||||
//dd($sql);
|
||||
$entries = DB::select($sql);
|
||||
$sql="select DATE_FORMAT(date_sub(min(games.kickoff), interval 1 hour),'%d.%m.%Y %H:%i') as start_date from rounds,games where rounds.season_id=".$seasonId." and games.round_id=rounds.id order by rounds.id;";
|
||||
//dd($sql);
|
||||
$entries = DB::select($sql);
|
||||
|
||||
if (count($entries)>0) {
|
||||
$start_date = $entries[0]->start_date;
|
||||
return view('users.no_ranking', compact('start_date'));
|
||||
} else {
|
||||
return redirect("/");
|
||||
}
|
||||
if (count($entries)>0) {
|
||||
$start_date = $entries[0]->start_date;
|
||||
return view('users.no_ranking', compact('start_date'));
|
||||
} else {
|
||||
return redirect("/");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
namespace App\MyClasses;
|
||||
|
||||
class TimeLogger
|
||||
{
|
||||
public $startTime;
|
||||
public $pkey;
|
||||
public $functionName;
|
||||
|
||||
public function __construct($_functionName) {
|
||||
$this->startTime = microtime(true);
|
||||
$this->functionName =$_functionName;
|
||||
$this->pkey="".rand(1000,9999);
|
||||
}
|
||||
|
||||
public function getStartMessage() {
|
||||
return "[CLOCK] [".$this->pkey."-".$this->functionName."] [started]";
|
||||
}
|
||||
|
||||
public function getEndMessage() {
|
||||
return "[CLOCK] [".$this->pkey."-". $this->functionName."] [ended] [elapsed: ".number_format( ( microtime(true) - $this->startTime), 4)."]";
|
||||
}
|
||||
}
|
||||
44
pfosten/app/MyClasses/TimeLogger/TimeLogger.php
Normal file
44
pfosten/app/MyClasses/TimeLogger/TimeLogger.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
namespace App\MyClasses;
|
||||
|
||||
/* USAGE IN CLASS
|
||||
|
||||
--START OF FILE
|
||||
use App\MyClasses\TimeLogger;
|
||||
|
||||
--START OF METHOD
|
||||
$a=new TimeLogger("method XXX start");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
--END OF METHOD
|
||||
Log::info($a->getEndMessage());
|
||||
*/
|
||||
|
||||
class TimeLogger
|
||||
{
|
||||
public $startTime;
|
||||
public $pkey;
|
||||
public $functionName;
|
||||
|
||||
public function __construct($_functionName) {
|
||||
$this->startTime = microtime(true);
|
||||
$this->functionName =$_functionName;
|
||||
$this->pkey="".rand(1000,9999);
|
||||
}
|
||||
|
||||
public function getStartMessage() {
|
||||
return "[CLOCK] [".$this->pkey."-".$this->functionName."] [started]";
|
||||
}
|
||||
|
||||
public function getEndMessage() {
|
||||
$time= ( microtime(true) - $this->startTime);
|
||||
$timestr=number_format( $time, 4);
|
||||
|
||||
$retval="[CLOCK] [".$this->pkey."-". $this->functionName."] [ended] [elapsed: ".$timestr."]";
|
||||
if ($time > 1.5) {
|
||||
$retval=$retval." [PERFORMANCE_WARNING]";
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ use App\Season;
|
|||
use Log;
|
||||
use DB;
|
||||
use Carbon;
|
||||
use App\MyClasses\TimeLogger;
|
||||
|
||||
class Round extends Model
|
||||
{
|
||||
|
|
@ -127,22 +128,28 @@ class Round extends Model
|
|||
}
|
||||
|
||||
public static function getFirstTippableRound($seasonId=-1) {
|
||||
|
||||
$season=null;
|
||||
if ($seasonId==-1) {
|
||||
$season=Season::getCurrent();
|
||||
} else {
|
||||
$season=Season::where('id','=', $seasonId)->first();
|
||||
}
|
||||
if (!$season) return null;
|
||||
if (!$season) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
|
||||
|
||||
$locked = false;
|
||||
foreach ($rounds as $round) {
|
||||
if (!Round::hasLockedGame($round->id) ) {
|
||||
if (!Round::hasLockedGame($round->id)) {
|
||||
return $round;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
use DB;
|
||||
use Carbon;
|
||||
use Log;
|
||||
use App\MyClasses\TimeLogger;
|
||||
|
||||
class Tipp extends Model
|
||||
{
|
||||
|
|
@ -177,6 +178,10 @@ class Tipp extends Model
|
|||
}
|
||||
|
||||
public static function createTipps($user_id) {
|
||||
|
||||
$a=new TimeLogger("Tipp::createTipps()");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$activeSeason = Season::getCurrent();
|
||||
|
||||
$rounds = Round::all()->where('season_id', '=', $activeSeason->id);
|
||||
|
|
@ -202,14 +207,21 @@ class Tipp extends Model
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
|
||||
}
|
||||
|
||||
public static function createAllTips() {
|
||||
$a=new TimeLogger("Tipp::createAllTipps()");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$users = DB::table('users')->where('deleted',null)->get();
|
||||
foreach($users as $user) {
|
||||
Log::info("Creating tipps for userid ".$user->id);
|
||||
Tipp::createTipps($user->id);
|
||||
}
|
||||
Log::info($a->getEndMessage());
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -247,6 +259,9 @@ class Tipp extends Model
|
|||
// TODO: Implement partial caching
|
||||
public static function getRoundTipps($max_round_id=-1, $seasonId=-1)
|
||||
{
|
||||
$a=new TimeLogger("getRoundTipps max_round_id=".$max_round_id.", seasonId=".$seasonId);
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$startTime = microtime(true);
|
||||
|
||||
$currentSeason = Season::getCurrent();
|
||||
|
|
@ -353,6 +368,7 @@ class Tipp extends Model
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// CALCULATION OF SCORES, RANKS, ETC. (COMPUTE AGGREGATED VALUES) EXCEPT GREENSHIRT, ARGH !!
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
$highestDayscores = array();
|
||||
foreach ($user_ids as $user_id) {
|
||||
$totalRankScore = 0;
|
||||
|
|
@ -383,6 +399,7 @@ class Tipp extends Model
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// Sortier-Array nach Rang (nur für max_round_id)
|
||||
$userRankings = array();
|
||||
|
|
@ -509,6 +526,7 @@ class Tipp extends Model
|
|||
|
||||
// B) SET GSCORE TOTAL EVERY ROUND ( and take fouls into consideration )
|
||||
$maxScorePerRound=array();
|
||||
|
||||
foreach($user_ids as $user_id) {
|
||||
$foulCount=0;
|
||||
$totalScore=0;
|
||||
|
|
@ -558,7 +576,6 @@ class Tipp extends Model
|
|||
|
||||
//dd("User 11 Round 1 gshirt_score =".$roundtipps['1_11']['gshirt_score'].", totalscore=".$roundtipps['1_11']['gshirt_totalscore']);
|
||||
|
||||
|
||||
//////////////////////////////
|
||||
// START OF HURTFUL 6 PLACE RESTRICTION IF DAYSCORE WIN (exception: completely even scores)
|
||||
// If more than 6 DayScoreWinners: Restrict by dayscore (rank)
|
||||
|
|
@ -642,9 +659,11 @@ class Tipp extends Model
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
///// END OF HURTFUL 6 PLACE RESTRICTION
|
||||
|
||||
|
||||
/// CALCULATE RANK AND PAYOUT QUOTAS
|
||||
|
||||
$quotas=Quota::getQuotas();
|
||||
|
||||
error_log("Round-Count=".$round_count);
|
||||
|
|
@ -687,7 +706,6 @@ class Tipp extends Model
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////// END OF ROUNDTIPPS CREATION ///////////////////
|
||||
|
||||
$response = array();
|
||||
|
|
@ -698,6 +716,8 @@ class Tipp extends Model
|
|||
|
||||
Log::info("Tipp::getRoundTipps: ExecutionTime: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n");
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
|
@ -722,6 +742,9 @@ class Tipp extends Model
|
|||
}
|
||||
|
||||
public static function gshirt_table() {
|
||||
$a=new TimeLogger("Tipp::gshirt_table()");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$rt = Tipp::getRoundTipps();
|
||||
$roundtipps = $rt['roundtipps'];
|
||||
$round_ids = $rt['round_ids'];
|
||||
|
|
@ -760,6 +783,8 @@ class Tipp extends Model
|
|||
array_push($rankingDisplay2,$rankingDisplay[$user_id]);
|
||||
}
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
|
||||
return $rankingDisplay2;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use App\Game;
|
|||
use Carbon;
|
||||
use Log;
|
||||
use DB;
|
||||
use App\MyClasses\TimeLogger;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
|
|
@ -138,10 +139,77 @@ class User extends Authenticatable
|
|||
return $dbDate;
|
||||
}
|
||||
|
||||
public static function hasMissingTipp($user_id) {
|
||||
// TODO: implement hasMissingTipps($user_array)
|
||||
// OPTIMIZED VERSION FOR hasMissingTipp
|
||||
public static function getMissingTippsAndJokers($users) {
|
||||
$round = Round::getFirstTippableRound();
|
||||
if (!$round) return false;
|
||||
|
||||
$tippClock=new TimeLogger("User::getMissingTippsAndJokers()");
|
||||
Log::info($tippClock->getStartMessage());
|
||||
// expecting collection of user db objects like: $users = DB::table('users')->where('deleted',null)->orderBy('lastname')->get();
|
||||
$idlist = array();
|
||||
$usersWithoutJoker=array();
|
||||
foreach($users as $key => $user) {
|
||||
array_push($idlist,$key);
|
||||
array_push($usersWithoutJoker,$key);
|
||||
}
|
||||
|
||||
$games = Game::where('round_id','=',$round->id)->get();
|
||||
$gameIds=array();
|
||||
foreach ($games as $key => $game) {
|
||||
array_push($gameIds,$key);
|
||||
Log::info("GAME_ID:".$key);
|
||||
}
|
||||
|
||||
$tipps = Tipp::whereIn('game_id', $gameIds)->get();
|
||||
Log::info("Fetched advanced tipps, checking now for missing tipps and jokers");
|
||||
|
||||
$usersWithoutTipps=array();
|
||||
foreach($tipps as $tipp) {
|
||||
if ($tipp->score1 == -1 || $tipp->score2 == -1) {
|
||||
$usersWithoutTipps[$tipp->user_id]="no_tipp";
|
||||
Log::info("UserId ".$tipp->user_id." is missing a tipp!");
|
||||
}
|
||||
if ($tipp->joker == true) {
|
||||
Log::info("Removing from jokerlist: ".$tipp->user_id);
|
||||
unset($usersWithoutJoker[$tipp->user_id]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($usersWithoutJoker as $id) {
|
||||
Log::info("Jokerless:".$id);
|
||||
}
|
||||
|
||||
$result=array();
|
||||
$result["MISSING_TIPP"]=$usersWithoutTipps;
|
||||
$result["MISSING_JOKER"]=$usersWithoutJoker;
|
||||
|
||||
Log::info("USERLIST: ".implode(",",$idlist));
|
||||
Log::info($tippClock->getEndMessage());
|
||||
|
||||
|
||||
foreach(array_keys($result) as $key => $value) {
|
||||
Log::info("Main key: ".$key.", value=".$value);
|
||||
}
|
||||
|
||||
$mtipps=$result["MISSING_TIPP"];
|
||||
foreach($mtipps as $key => $value) {
|
||||
Log::info("MTipp: ".$key." => ".$value);
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function hasMissingTipp($user_id) {
|
||||
|
||||
$round = Round::getFirstTippableRound();
|
||||
if (!$round) return false;
|
||||
|
||||
//$a=new TimeLogger("User::hasMissingTipp()");
|
||||
//Log::info($a->getStartMessage());
|
||||
|
||||
$round_id = $round->id;
|
||||
$games = Game::where('round_id','=',$round_id)->get();
|
||||
|
||||
|
|
@ -151,14 +219,18 @@ class User extends Authenticatable
|
|||
|
||||
if(!$tipp) {
|
||||
Log::info("Tipp doesnt exist: game_id=".$game->id.", user_id=".$user_id);
|
||||
//Log::info($a->getEndMessage());
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($tipp->score1 == -1 || $tipp->score2 == -1) {
|
||||
//Log::info("!!! User ".$user_id." has a missing tipp for game_id ".$game->id.", round = ".$round_id);
|
||||
//Log::info($a->getEndMessage());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
//Log::info($a->getEndMessage());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ use App\Leagues\LeagueMember;
|
|||
use DB;
|
||||
use Log;
|
||||
|
||||
use App\MyClasses;
|
||||
|
||||
class League extends Model
|
||||
{
|
||||
|
||||
|
|
@ -159,9 +161,12 @@ class League extends Model
|
|||
$memberScores[$memberId] = $tpl;
|
||||
}
|
||||
|
||||
|
||||
$lastLockedRoundId=Round::getLastLockedRoundId();
|
||||
Log::info("LASTLOCKKEDROUNDID=".$lastLockedRoundId);
|
||||
$matches=Match::getMatchResults($league->id,-1);
|
||||
foreach ($matches as $match) {
|
||||
if (Round::isCompleted($match->round_id)) {
|
||||
if (Round::isCompleted($match->round_id) || $match->round_id==$lastLockedRoundId ) {
|
||||
$memberScores[$match->user1_id][1] += $match->user1_league_score;
|
||||
error_log("+++ ".$match->user1_id." +".$match->user1_league_score);
|
||||
$memberScores[$match->user1_id][2] += $match->user1_rankscore; // goals
|
||||
|
|
@ -215,6 +220,9 @@ class League extends Model
|
|||
// Nur für Auf und Abstiegsberechnung.
|
||||
// Schreibt den zukünftigen Rank auf Index4
|
||||
public static function getTotalRankingOverall($seasonId=-1) {
|
||||
$a=new MyClasses\TimeLogger("League::getTotalRankingOverall (seasonId=".$seasonId.")");
|
||||
Log::info($a->getStartMessage());
|
||||
|
||||
$userNames = User::getNames();
|
||||
|
||||
$totalRanking=array();
|
||||
|
|
@ -386,7 +394,10 @@ class League extends Model
|
|||
|
||||
|
||||
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
//error_log($a->getEndMessage());
|
||||
|
||||
|
||||
return $totalRanking;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,14 +258,18 @@ class Match extends Model
|
|||
$roundtipps = $roundtipps["roundtipps"];
|
||||
$matches = Match::getLeagueMatches($leagueId, $maxRoundId);
|
||||
|
||||
if ($maxRoundId==-1) { $maxRoundId = Round::getLastRoundId($season->id); }
|
||||
if ($maxRoundId==-1) {
|
||||
//$maxRoundId = Round::getLastRoundId($season->id);
|
||||
$maxRoundId = Round::getLastLockedRoundId($season->id);
|
||||
Log::info("LASTLOCKEDROUND_ID=".$maxRoundId);
|
||||
}
|
||||
|
||||
foreach($matches as $key => $match) {
|
||||
|
||||
$user1_key = $match->round_id."_".$match->user1_id;
|
||||
$user2_key = $match->round_id."_".$match->user2_id;
|
||||
|
||||
if (Round::isCompleted($match->round_id)) {
|
||||
if (array_key_exists($user1_key,$roundtipps ) && array_key_exists($user2_key,$roundtipps) ) {
|
||||
|
||||
$user1_score = $roundtipps[$user1_key]["rankscore"];
|
||||
$user2_score = $roundtipps[$user2_key]["rankscore"];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue