Updating repo for cross-computer work

This commit is contained in:
Torsten 2020-01-17 09:32:06 +01:00
parent 807cf49bc0
commit 1fea0f4fe7
18 changed files with 87847 additions and 5202 deletions

View file

@ -7,6 +7,7 @@ use DB;
use Carbon;
use Log;
use App\MyClasses\TimeLogger;
use Symfony\Component\CssSelector\Tests\Node\SelectorNodeTest;
class Tipp extends Model
{
@ -77,6 +78,8 @@ class Tipp extends Model
])->first();
}
public static function getScoreLocal($goals1, $goals2, $tipp1, $tipp2, $joker) {
$score=0;
$tippTendenz = $tipp1 - $tipp2;
@ -788,4 +791,69 @@ class Tipp extends Model
return $rankingDisplay2;
}
// Creates array of countings of all joker usages
public static function getJokerUsageArray($user_id,$round_id) {
$seasonId=Round::getSeasonId($round_id);
$firstRoundId=Season::getFirstRoundId($seasonId);
if ($firstRoundId==-1) return 0; // No first round detected.
$sql= <<<EOD
SELECT
count(*) as cnt,
concat(tipps.score1,':',tipps.score2) as game_result
FROM
tipps,games,rounds
WHERE
tipps.user_id=$user_id
AND
tipps.game_id = games.id
AND
games.round_id = rounds.id
AND
joker = true
AND
rounds.id >= $firstRoundId
AND
rounds.id <= $round_id
GROUP BY 2
ORDER BY 1 DESC
;
EOD;
$result = DB::select($sql);
$joker_usage_array=array();
foreach ($result as $line) {
$key = $line->game_result;
$value = $line->cnt;
$joker_usage_array[$key]=$value;
}
return $joker_usage_array;
}
// Creates string from array of countings of all joker usages
public static function getJokerUsageString($user_id, $round_id) {
$joker_usage_array=Tipp::getJokerUsageArray($user_id,$round_id);
//Log::info("RoundId: ".$round_id.", Joker usage array size:".sizeof($joker_usage_array));
$str_result="";
foreach ($joker_usage_array as $key => $value) {
if (strlen($str_result)>0) {
$str_result=$str_result.", ";
}
$str_result=$str_result.$value."x".$key;
}
return $str_result;
}
}