swap leaguemember functionality
This commit is contained in:
commit
58e70f8f55
18 changed files with 2710 additions and 24 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);
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
APP_NAME="Hoschis Tippspiel"
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:skYbYLqiGeOCTWD7J9xHzAKgmwuTkknm9BLGinIgn88=
|
||||
APP_KEY=base64:1+1OyIuQj0id5SH2kBWdQoCDdmEqwGGHxkqtfJPLA00=
|
||||
APP_DEBUG=true
|
||||
APP_LOG_LEVEL=debug
|
||||
APP_URL=http://localhost
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use App\Leagues\League;
|
|||
use App\Leagues\LeagueMember;
|
||||
use App\Leagues\Match;
|
||||
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Log;
|
||||
use DB;
|
||||
|
||||
|
|
@ -125,6 +126,8 @@ class LeaguesController extends Controller
|
|||
return view ('leagues.matches', compact('season', 'matchesTotal','leagues','leagueNames','roundNames'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function showLeagueRanking() {
|
||||
|
||||
$a=new TimeLogger("LeaguesController::showLeagueRanking()");
|
||||
|
|
@ -166,6 +169,118 @@ class LeaguesController extends Controller
|
|||
return view ('leagues.chart',compact('season', 'leagueNames', 'userNames','leagueScores','rankInfo','rank','cols'));
|
||||
}
|
||||
|
||||
// Originall copied over from showLeagueRanking
|
||||
public static function showLeagueSwapForm() {
|
||||
|
||||
$a=new TimeLogger("LeaguesController::showLeagueSwapForm()");
|
||||
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)) {
|
||||
Log::info($a->getEndMessage());
|
||||
return redirect("/");
|
||||
}
|
||||
|
||||
$totalRanking = League::getTotalRankingOverall(); // Nur für Auf/Abstiegsinfo benötigt.
|
||||
$rankInfo=array();
|
||||
|
||||
foreach($totalRanking as $index => $entry) {
|
||||
$userId=$entry[0];
|
||||
$rankInfo[$userId]=$totalRanking[$index][4];
|
||||
}
|
||||
|
||||
$cols=array();
|
||||
$cols[1]="greenyellow";
|
||||
$cols[2]="orange";
|
||||
$cols[3]="lightgrey";
|
||||
$cols[4]="";
|
||||
|
||||
$leagueScores=array();
|
||||
foreach([1,2,3,4] as $rank) {
|
||||
$leagueScores[$rank] = League::getRanking($rank);
|
||||
}
|
||||
|
||||
Log::info($a->getEndMessage());
|
||||
//error_log($a->getEndMessage());
|
||||
|
||||
return view ('leagues.chart_swapform',compact('season', 'leagueNames', 'userNames','leagueScores','rankInfo','rank','cols'));
|
||||
}
|
||||
|
||||
public static function swapLeagueMembers(Request $request) {
|
||||
Log::info("Start: LeaguesController::swapLeagueMembers");
|
||||
Log::info("Method triggered successfully.");
|
||||
|
||||
Log::info($request->method()); // Klappt
|
||||
|
||||
$input=$request->input();
|
||||
Log::info("Params:".sizeof($input));
|
||||
foreach ($input as $key => $value) {
|
||||
Log::info( $key."=>".$value );
|
||||
}
|
||||
|
||||
$leagueIds = League::getIds();
|
||||
$strLeagueIds = join(",", $leagueIds);
|
||||
Log::info("League Ids: ".$strLeagueIds);
|
||||
|
||||
$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);
|
||||
|
||||
}
|
||||
|
||||
public static function showSingleUserMatches($userId) {
|
||||
$season = Season::getCurrent();
|
||||
$leagueNames = League::getNames();
|
||||
|
|
|
|||
|
|
@ -312,9 +312,9 @@ class UsersController extends Controller
|
|||
if($max_round_id==-1) {
|
||||
$max_round_id = Round::getLastLockedRoundId();
|
||||
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;";
|
||||
$sql="SELECT DATE_FORMAT(date_sub(games.kickoff, INTERVAL 1 MINUTE),'%d.%m.%Y %H:%i') as start_date from rounds,games where rounds.season_id=11 and games.round_id=rounds.id order by games.id limit 1;";
|
||||
//dd($sql);
|
||||
$entries = DB::select($sql);
|
||||
$entries = DB::select(DB::raw($sql));
|
||||
|
||||
if (count($entries)>0) {
|
||||
$start_date = $entries[0]->start_date;
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'log' => env('APP_LOG', 'single'),
|
||||
'log' => env('APP_LOG', 'daily'),
|
||||
|
||||
'log_level' => env('APP_LOG_LEVEL', 'debug'),
|
||||
|
||||
|
|
|
|||
94
pfosten/config/logging.php
Normal file
94
pfosten/config/logging.php
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that gets used when writing
|
||||
| messages to the logs. The name specified in this option should match
|
||||
| one of the channels defined in the "channels" configuration array.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Out of
|
||||
| the box, Laravel uses the Monolog PHP logging library. This gives
|
||||
| you a variety of powerful log handlers / formatters to utilize.
|
||||
|
|
||||
| Available Drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog",
|
||||
| "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => ['daily'],
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => 'debug',
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => 'debug',
|
||||
'days' => 14,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => 'Laravel Log',
|
||||
'emoji' => ':boom:',
|
||||
'level' => 'critical',
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => 'debug',
|
||||
'handler' => SyslogUdpHandler::class,
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => StreamHandler::class,
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => 'debug',
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => 'debug',
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
|
|
@ -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>
|
||||
|
|
|
|||
119
pfosten/resources/views/leagues/chart_swapform.blade.php
Normal file
119
pfosten/resources/views/leagues/chart_swapform.blade.php
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
@extends('layouts.layout')
|
||||
|
||||
@section('content')
|
||||
<section class="text-center">
|
||||
<div id="leagueContainer" class="container">
|
||||
|
||||
<h2>{{ $season->name }}</h2>
|
||||
<h2>Spielerliga Platztausch</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<td style="width:50px;background-color:{{$cols[1]}}"></td>
|
||||
<td style="width:250px;"> = Qualifikationsplatz Liga 1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:50px;background-color:{{$cols[2]}}"></td>
|
||||
<td style="width:250px;"> = Qualifikationsplatz Liga 2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:50px;background-color:{{$cols[3]}}"></td>
|
||||
<td style="width:250px;"> = Qualifikationsplatz Liga 3</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@foreach($leagueScores as $rank => $_leagueScores)
|
||||
@foreach($_leagueScores as $leagueId => $playerTuples)
|
||||
<h2>{{ $leagueNames[$leagueId] }}</h2>
|
||||
|
||||
<table class="table-bordered col-lg-12">
|
||||
<tr class="table-bordered">
|
||||
|
||||
<td>Tausch</td>
|
||||
<td class="table-bordered" style="width:50px;">Pos</td>
|
||||
<td class="table-bordered" style="width:150px;">Spieler</td>
|
||||
<td class="table-bordered" style="width:50px;">Punkte</td>
|
||||
<td class="table-bordered" style="width:150px;">Tordifferenz</td>
|
||||
<td class="table-bordered" style="width:150px;">Torverhältnis</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<!-- Start Matchgruppen-Loop-->
|
||||
@foreach($playerTuples as $pos => $player)
|
||||
<tr class="table-bordered">
|
||||
<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>
|
||||
<td> {{$player[2]-$player[3]}} </td>
|
||||
<td> {{$player[2]}}:{{$player[3]}} </td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
</table>
|
||||
<p> </p>
|
||||
|
||||
@endforeach
|
||||
@endforeach
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
const checkbox = document.getElementById('leagueContainer')
|
||||
|
||||
checkbox.addEventListener('change', (event) => {
|
||||
let delta =0
|
||||
if (event.currentTarget.checked) {
|
||||
// Is going to be unchecked
|
||||
delta=-1
|
||||
} else {
|
||||
// Is going to be checked
|
||||
delta=+1
|
||||
}
|
||||
|
||||
// count checked boxes
|
||||
let inputElems = document.getElementsByTagName("input"), count = 0;
|
||||
for (let i=0; i<inputElems.length; i++) {
|
||||
if (inputElems[i].type === "checkbox" && inputElems[i].checked === true) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count==2) {
|
||||
let selected_players=[];
|
||||
|
||||
for (let i=0; i<inputElems.length; i++) {
|
||||
if (inputElems[i].type === "checkbox" && inputElems[i].checked === true) {
|
||||
selected_players.push(inputElems[i].id)
|
||||
inputElems[i].checked=false;
|
||||
}
|
||||
}
|
||||
alert("Tauschen:\n"+selected_players.join("\n"));
|
||||
|
||||
let url = '/league/swap';
|
||||
let token = '{{ csrf_token() }}'
|
||||
|
||||
fetch(url, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json, text-plain, */*",
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
"X-CSRF-TOKEN": token
|
||||
},
|
||||
method: 'post',
|
||||
credentials: "same-origin",
|
||||
body: JSON.stringify({
|
||||
user1_id: selected_players[0],
|
||||
user2_id: selected_players[1]
|
||||
})
|
||||
}).then((data) => {
|
||||
location.reload();
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<div class="lead">{{ $game->team1 }} : {{ $game->team2 }}</div>
|
||||
|
||||
<div >
|
||||
<div>
|
||||
<form method="POST" action="/tipps/store">
|
||||
{{ csrf_field() }}
|
||||
<div class="form-group">
|
||||
|
|
|
|||
|
|
@ -91,5 +91,10 @@ Route::get('/league_settings/season={season_id}','Leagues\LeaguesController@inde
|
|||
Route::get('/league_settings/create_league/start_round_id={start_round_id}/round_count={round_count}','Leagues\LeaguesController@createLeagues');
|
||||
Route::get('/league_show_rounds','Leagues\LeaguesController@showLeagueRounds');
|
||||
Route::get('/league/show','Leagues\LeaguesController@showLeagueRanking');
|
||||
Route::get('/league/swapform','Leagues\LeaguesController@showLeagueSwapForm');
|
||||
Route::post('/league/swap','Leagues\LeaguesController@swapLeagueMembers');
|
||||
|
||||
Route::get('/league/showSingleUserMatches/user_id={userId}','Leagues\LeaguesController@showSingleUserMatches');
|
||||
|
||||
/* Cache clearing on remote server */
|
||||
Route::get('/clear-cache', function() { Artisan::call('cache:clear');Artisan::call('config:clear'); return "Cache cleared, Config reloaded"; });
|
||||
|
|
|
|||
3
pfosten/set_alias.sh
Executable file
3
pfosten/set_alias.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
alias phpunit="docker-compose exec app vendor/bin/phpunit"
|
||||
alias artisan="docker-compose exec app php artisan"
|
||||
alias composer="docker-compose exec app composer"
|
||||
|
|
@ -8,6 +8,5 @@ str_now=datetime.datetime.now().strftime('%Y-%m-%d_%H%M%S')
|
|||
|
||||
filename="pfosten_"+str_now+".sql"
|
||||
print("Dumping "+filename)
|
||||
#cmd="""mysqldump -ud0274241 -psuperpfosten! -h hoschis-tippspiel.de d0274241 > """+filename
|
||||
cmd="""mysqldump --no-tablespaces --column-statistics=0 -ud0274241 -psuperpfosten! -h hoschis-tippspiel.de d0274241 > """+filename
|
||||
os.system(cmd)
|
||||
|
|
|
|||
469
tools/pfosten_2022-06-02_163647.sql
Normal file
469
tools/pfosten_2022-06-02_163647.sql
Normal file
File diff suppressed because one or more lines are too long
469
tools/pfosten_2022-06-03_115733.sql
Normal file
469
tools/pfosten_2022-06-03_115733.sql
Normal file
File diff suppressed because one or more lines are too long
469
tools/pfosten_2022-06-05_093059.sql
Normal file
469
tools/pfosten_2022-06-05_093059.sql
Normal file
File diff suppressed because one or more lines are too long
470
tools/pfosten_2022-06-11_091759.sql
Normal file
470
tools/pfosten_2022-06-11_091759.sql
Normal file
File diff suppressed because one or more lines are too long
470
tools/pfosten_2022-07-14_093702.sql
Normal file
470
tools/pfosten_2022-07-14_093702.sql
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue