Working on Case2: New League Creation after Qualification
This commit is contained in:
parent
d8a7f78cbd
commit
66671b1e81
11 changed files with 12726 additions and 40 deletions
|
|
@ -36,6 +36,7 @@ class Round extends Model
|
|||
|
||||
public static function isCompleted($round_id) {
|
||||
$round = Round::where('id','=',$round_id)->first();
|
||||
|
||||
$games = Game::where('round_id','=',$round->id)->get();
|
||||
$completed = true;
|
||||
foreach($games as $game) {
|
||||
|
|
@ -46,8 +47,16 @@ class Round extends Model
|
|||
return $completed;
|
||||
}
|
||||
|
||||
public static function getLastCompleteRoundId() {
|
||||
$season = Season::getCurrent();
|
||||
public static function getLastCompleteRoundId($seasonId=-1) {
|
||||
$season=null;
|
||||
if ($seasonId==-1) {
|
||||
$season = Season::getCurrent();
|
||||
} else {
|
||||
$season=Season::where('id','=',$seasonId)->first();
|
||||
}
|
||||
if (!$season) return -1;
|
||||
$seasonId=$season->id;
|
||||
|
||||
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
|
||||
$lastCompleteRound=-1;
|
||||
foreach ($rounds as $round) {
|
||||
|
|
@ -58,22 +67,35 @@ class Round extends Model
|
|||
return $lastCompleteRound;
|
||||
}
|
||||
|
||||
public static function getFirstIncompleteRound() {
|
||||
$season = Season::getCurrent();
|
||||
if (!$season) return -1;
|
||||
public static function getFirstIncompleteRound($seasonId=-1) {
|
||||
$season=null;
|
||||
if ($seasonId==-1) {
|
||||
$season = Season::getCurrent();
|
||||
} else {
|
||||
$season = Season::where('id','=',$seasonId)->first();
|
||||
}
|
||||
|
||||
$rounds = Round::where('season_id','=',$season->id)->orderBy('id')->get();
|
||||
if (!$season) return -1;
|
||||
$seasonId=$season->id;
|
||||
|
||||
$rounds = Round::where('season_id','=',$seasonId)->orderBy('id')->get();
|
||||
foreach($rounds as $round) {
|
||||
if (!Round::isCompleted($round->id)) return $round->id;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static function getNextRoundId($roundId) {
|
||||
$currentSeason = Season::getCurrent();
|
||||
public static function getNextRoundId($roundId, $seasonId=-1) {
|
||||
$season=null;
|
||||
if ($seasonId==-1) {
|
||||
$currentSeason=Season::getCurrent();
|
||||
} else {
|
||||
$currentSeason=Season::where('id','=', $seasonId)->first();
|
||||
}
|
||||
if (!$currentSeason) return -1;
|
||||
$seasonId = $currentSeason->id;
|
||||
|
||||
$rounds = Round::where('season_id','=',$currentSeason->id)->where('id','>=',$roundId)->get();
|
||||
$rounds = Round::where('season_id','=',$seasonId)->where('id','>=',$roundId)->get();
|
||||
foreach($rounds as $round) {
|
||||
if ($round->id == $roundId) { continue; }
|
||||
return $round->id;
|
||||
|
|
@ -81,9 +103,15 @@ class Round extends Model
|
|||
return -1;
|
||||
}
|
||||
|
||||
public static function getLastLockedRoundId() {
|
||||
$season = Season::getCurrent();
|
||||
public static function getLastLockedRoundId($seasonId=-1) {
|
||||
$season=null;
|
||||
if ($seasonId==-1) {
|
||||
$season=Season::getCurrent();
|
||||
} else {
|
||||
$season=Season::where('id','=', $seasonId)->first();
|
||||
}
|
||||
if (!$season) return -1;
|
||||
|
||||
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
|
||||
$lastLockedRoundId=-1;
|
||||
foreach ($rounds as $round) {
|
||||
|
|
@ -94,15 +122,29 @@ class Round extends Model
|
|||
return $lastLockedRoundId;
|
||||
}
|
||||
|
||||
public static function getFirstTippableRoundId() {
|
||||
$round = Round::getFirstTippableRound();
|
||||
public static function getFirstTippableRoundId($seasonId=-1) {
|
||||
$season=null;
|
||||
if ($seasonId==-1) {
|
||||
$currentSeason=Season::getCurrent();
|
||||
} else {
|
||||
$currentSeason=Season::where('id','=', $seasonId)->first();
|
||||
}
|
||||
if (!$season) return null;
|
||||
|
||||
$round = Round::getFirstTippableRound($season->id);
|
||||
if (!$round) return -1;
|
||||
return $round->id;
|
||||
}
|
||||
|
||||
public static function getFirstTippableRound() {
|
||||
$season = Season::getCurrent();
|
||||
public static function getFirstTippableRound($seasonId=-1) {
|
||||
$season=null;
|
||||
if ($seasonId==-1) {
|
||||
$currentSeason=Season::getCurrent();
|
||||
} else {
|
||||
$currentSeason=Season::where('id','=', $seasonId)->first();
|
||||
}
|
||||
if (!$season) return null;
|
||||
|
||||
$rounds=Round::where('season_id','=',$season->id)->orderBy('id')->get();
|
||||
$locked = false;
|
||||
foreach ($rounds as $round) {
|
||||
|
|
@ -113,6 +155,7 @@ class Round extends Model
|
|||
return null;
|
||||
}
|
||||
|
||||
// TODO: CHeck : Unused ??
|
||||
public static function getClosestRoundToNow() {
|
||||
$sql="select round_id,DATEDIFF(NOW(),kickoff) from games order by 2 desc limit 1;";
|
||||
$result=DB::select($sql);
|
||||
|
|
@ -154,10 +197,13 @@ class Round extends Model
|
|||
}
|
||||
|
||||
public static function getNames($seasonId=-1) {
|
||||
Log::info("Round::getNames for seasonId=".$seasonId);
|
||||
$season= Season::getCurrent();
|
||||
if ($seasonId!=-1) { $season = Season::where('id','=',$seasonId)->first(); }
|
||||
$rounds = Round::where('season_id','=',$season->id)->get();
|
||||
|
||||
Log::info("Number of rounds:".sizeof($rounds));
|
||||
|
||||
Log::info("START");
|
||||
$roundnames = array();
|
||||
foreach($rounds as $round) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue