First version of LeagueSwap
This commit is contained in:
parent
07ce7961c9
commit
8cc4e620ec
5 changed files with 78 additions and 23 deletions
10
doc/swap_leaguemembers.sql
Normal file
10
doc/swap_leaguemembers.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
-- swap user1_id and user2_id
|
||||
update leagues_matches set user1_id=999 where user1_id=91 and league_id in (157,158,159,160);
|
||||
update leagues_matches set user1_id=91 where user1_id=22 and league_id in (157,158,159,160);
|
||||
update leagues_matches set user1_id=22 where user1_id=999 and league_id in (157,158,159,160);
|
||||
update leagues_matches set user2_id=999 where user2_id=91 and league_id in (157,158,159,160);
|
||||
update leagues_matches set user2_id=91 where user2_id=22 and league_id in (157,158,159,160);
|
||||
update leagues_matches set user2_id=22 where user2_id=999 and league_id in (157,158,159,160);
|
||||
update leagues_members set user_id=999 where user_id=91 and league_id in (157,158,159,160);
|
||||
update leagues_members set user_id=91 where user_id=22 and league_id in (157,158,159.160);
|
||||
update leagues_members set user_id=22 where user_id=999 and league_id in (157,158,159,160);
|
||||
|
|
@ -220,13 +220,64 @@ class LeaguesController extends Controller
|
|||
$input=$request->input();
|
||||
Log::info("Params:".sizeof($input));
|
||||
foreach ($input as $key => $value) {
|
||||
Log::info( ">".$key."=>".$value );
|
||||
Log::info( $key."=>".$value );
|
||||
}
|
||||
|
||||
$leagueIds = League::getIds();
|
||||
$strLeagueIds = join(",", $leagueIds);
|
||||
Log::info("League Ids: ".$strLeagueIds);
|
||||
|
||||
Log::info($request->input('user1', 'not_set'));
|
||||
$user1_id=$request->input('user1_id');
|
||||
$user2_id=$request->input('user2_id');
|
||||
Log::info($user1_id);
|
||||
Log::info($user2_id);
|
||||
$sql=str_replace("#USER1_ID",$user1_id, "update leagues_matches set user1_id=999 where user1_id=#USER1_ID and league_id in (#LEAGUES);");
|
||||
$sql=str_replace("#LEAGUES", $strLeagueIds,$sql);
|
||||
Log::info($sql);
|
||||
DB::update($sql);
|
||||
|
||||
$sql=str_replace("#USER1_ID",$user1_id, "update leagues_matches set user1_id=#USER1_ID where user1_id=#USER2_ID and league_id in (#LEAGUES);");
|
||||
$sql=str_replace("#USER2_ID", $user2_id,$sql);
|
||||
$sql=str_replace("#LEAGUES", $strLeagueIds,$sql);
|
||||
Log::info($sql);
|
||||
DB::update($sql);
|
||||
|
||||
$sql=str_replace("#USER2_ID",$user2_id, "update leagues_matches set user1_id=#USER2_ID where user1_id=999 and league_id in (#LEAGUES);");
|
||||
$sql=str_replace("#LEAGUES", $strLeagueIds,$sql);
|
||||
Log::info($sql);
|
||||
DB::update($sql);
|
||||
|
||||
$sql=str_replace("#USER1_ID",$user1_id, "update leagues_matches set user2_id=999 where user2_id=#USER1_ID and league_id in (#LEAGUES);");
|
||||
$sql=str_replace("#LEAGUES", $strLeagueIds,$sql);
|
||||
Log::info($sql);
|
||||
DB::update($sql);
|
||||
|
||||
$sql=str_replace("#USER1_ID",$user1_id, "update leagues_matches set user2_id=#USER1_ID where user2_id=#USER2_ID and league_id in (#LEAGUES);");
|
||||
$sql=str_replace("#USER2_ID", $user2_id,$sql);
|
||||
$sql=str_replace("#LEAGUES", $strLeagueIds,$sql);
|
||||
Log::info($sql);
|
||||
DB::update($sql);
|
||||
|
||||
$sql=str_replace("#USER2_ID",$user2_id, "update leagues_matches set user2_id=#USER2_ID where user2_id=999 and league_id in (#LEAGUES);");
|
||||
$sql=str_replace("#LEAGUES", $strLeagueIds,$sql);
|
||||
Log::info($sql);
|
||||
DB::update($sql);
|
||||
|
||||
$sql=str_replace("#USER1_ID",$user1_id, "update leagues_members set user_id=999 where user_id=#USER1_ID and league_id in (#LEAGUES);");
|
||||
$sql=str_replace("#LEAGUES", $strLeagueIds,$sql);
|
||||
Log::info($sql);
|
||||
DB::update($sql);
|
||||
|
||||
$sql=str_replace("#USER1_ID",$user1_id, "update leagues_members set user_id=#USER1_ID where user_id=#USER2_ID and league_id in (#LEAGUES);");
|
||||
$sql=str_replace("#USER2_ID", $user2_id,$sql);
|
||||
$sql=str_replace("#LEAGUES", $strLeagueIds,$sql);
|
||||
Log::info($sql);
|
||||
DB::update($sql);
|
||||
|
||||
$sql=str_replace("#USER2_ID",$user2_id, "update leagues_members set user_id=#USER2_ID where user_id=999 and league_id in (#LEAGUES);");
|
||||
$sql=str_replace("#LEAGUES", $strLeagueIds,$sql);
|
||||
Log::info($sql);
|
||||
DB::update($sql);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,16 @@ class League extends Model
|
|||
return $leagueNames;
|
||||
}
|
||||
|
||||
public static function getIds() {
|
||||
$season = Season::getCurrent();
|
||||
$leagues = League::where('season_id','=',$season->id)->get();
|
||||
$leagueIds = array();
|
||||
foreach($leagues as $league) {
|
||||
$leagueIds[]=$league->id; // push id onto array
|
||||
}
|
||||
return $leagueIds;
|
||||
}
|
||||
|
||||
public static function getStartRoundId($leagueId)
|
||||
{
|
||||
$league = League::where('id','=',$leagueId)->first();
|
||||
|
|
@ -368,23 +378,6 @@ class League extends Model
|
|||
usort($totalRanking, array('App\Leagues\League','cmpScore'));
|
||||
}
|
||||
|
||||
// HACK TO BE REMOVED: SET POSITIONS MANUALLY 2018-08
|
||||
|
||||
/*
|
||||
foreach ($totalRanking as $index => $entry) {
|
||||
$uid=$totalRanking[$index][0];
|
||||
if ($uid==65 or $uid==80 or $uid==84 or $uid==3) {
|
||||
$totalRanking[$index][4]=3;
|
||||
}
|
||||
if ($uid==68 or $uid==32 or $uid==9 or $uid==74) {
|
||||
$totalRanking[$index][4]=2;
|
||||
}
|
||||
}
|
||||
usort($totalRanking, array('App\Leagues\League','cmpScore'));
|
||||
*/
|
||||
|
||||
// END OF HACK
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
//error_log($a->getEndMessage());
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
<a style="font-weight:normal; font-color: blue; font-size: 22px;" href="/seasons">Saison</a>
|
||||
<a style="font-weight:normal; font-color: blue; font-size: 22px;" href="/rounds#{{\App\Round::getFirstIncompleteRound()}}">Runden</a>
|
||||
<a style="font-weight:normal; font-color: blue; font-size: 22px;" href="/users">Spieler</a>
|
||||
<a style="font-weight:normal; font-color: blue; font-size: 22px;" href="/league/swapform">Ligatausch</a>
|
||||
<a style="font-weight:normal; font-color: blue; font-size: 22px;" href="/roundmails">Rundmail</a>
|
||||
</div>
|
||||
</label>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
<!-- Start Matchgruppen-Loop-->
|
||||
@foreach($playerTuples as $pos => $player)
|
||||
<tr class="table-bordered">
|
||||
<td><input id="{{$player[0]}}__{{$userNames[$player[0]]}}__{{$leagueNames[$leagueId]}}" type="checkbox"></td>
|
||||
<td><input id="{{$player[0]}}" type="checkbox"></td>
|
||||
<td style="width:50px;background-color:{{ $cols[$rankInfo[$player[0]]] }}"> {{$pos+1}} </td>
|
||||
<td> <a name="playerid_{{$player[0]}}" class="{{ $player[0]==Auth::user()->id ? 'blink_text' : '' }}" href="/league/showSingleUserMatches/user_id={{$player[0]}}"> {{$userNames[$player[0]]}} </a> </td>
|
||||
<td> {{$player[1]}} </td>
|
||||
|
|
@ -101,11 +101,11 @@
|
|||
method: 'post',
|
||||
credentials: "same-origin",
|
||||
body: JSON.stringify({
|
||||
user1: inputElems[0].id,
|
||||
user2: inputElems[1].id
|
||||
user1_id: selected_players[0],
|
||||
user2_id: selected_players[1]
|
||||
})
|
||||
}).then((data) => {
|
||||
window.location.href = redirect;
|
||||
location.reload();
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.log(error);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue