Merge branch 'dev' of https://github.com/OpzekerIT/pubg into dev
This commit is contained in:
commit
65a96699e9
5 changed files with 64 additions and 31 deletions
|
|
@ -1,4 +1,5 @@
|
|||
function new-lock {
|
||||
Write-Output 'Setting lock'
|
||||
if ($env:temp) {
|
||||
$lockFile = Join-Path -Path $env:temp -ChildPath 'lockfile_pubg.lock'
|
||||
}
|
||||
|
|
@ -10,12 +11,9 @@ function new-lock {
|
|||
Exit
|
||||
}
|
||||
New-Item -ItemType File -Path $lockFile | Out-Null
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
function remove-lock {
|
||||
Write-Output 'Removing lock'
|
||||
if ($env:temp) {
|
||||
$lockFile = Join-Path -Path $env:temp -ChildPath 'lockfile_pubg.lock'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,11 @@ error_reporting(E_ALL);
|
|||
}
|
||||
|
||||
echo "<br>";
|
||||
echo "Stats for $key (minimal 8 matches)";
|
||||
if($key == 'all'){
|
||||
echo "Stats for $key (minimal 20 matches)";
|
||||
}else{
|
||||
echo "Stats for $key (minimal 8 matches)";
|
||||
}
|
||||
echo "<table border='1' class='sortable'>";
|
||||
echo "<tr>
|
||||
<th>Player</th>
|
||||
|
|
@ -52,6 +56,10 @@ error_reporting(E_ALL);
|
|||
if ($player_data['matches'] < 8){
|
||||
continue;
|
||||
}
|
||||
if ($key == 'all' && $player_data['matches'] < 20) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$player_name = $player_data['playername'];
|
||||
$deaths = number_format($player_data['deaths'], 0, ',', '');
|
||||
$kills = number_format($player_data['kills'], 0, ',', '');
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ if ($fileContent -match "\`$clanmembers\s*=\s*array\(([^)]+)\)") {
|
|||
else {
|
||||
Write-Output "Clan members not found"
|
||||
}
|
||||
if ($clanMembersArray.count -ge 10 ) {
|
||||
if ($clanMembersArray.count -gt 10 ) {
|
||||
write-output "Currently not able to process more then 10 players"
|
||||
exit
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
Start-Transcript -Path '/var/log/dtch/matchparser.log' -Append
|
||||
Write-Output 'Running from'
|
||||
(Get-Location).path
|
||||
|
||||
if ($PSScriptRoot.length -eq 0) {
|
||||
$scriptroot = Get-Location
|
||||
|
|
@ -21,6 +24,19 @@ function Get-Change {
|
|||
return [math]::Round($change, 2)
|
||||
}
|
||||
|
||||
function Get-winratio {
|
||||
param (
|
||||
[int]$player_wins,
|
||||
[int]$player_matches
|
||||
)
|
||||
if ($player_wins -eq 0 -or $player_matches -eq 0) {
|
||||
$winratio = 0
|
||||
}
|
||||
else {
|
||||
$winratio = ($player_wins / $player_matches) * 100
|
||||
}
|
||||
return $winratio
|
||||
}
|
||||
function get-killstats {
|
||||
param (
|
||||
$player_name,
|
||||
|
|
@ -59,8 +75,8 @@ try {
|
|||
$filesarray += [PSCustomObject]@{name = $file.Name; date = $dateTime }
|
||||
}
|
||||
|
||||
try{ $latestFile = ($filesarray | where-object { ($_.date -gt (get-date).AddDays(-2)) -and ($_.date -lt (get-date).AddDays(-1))} | Sort-Object date)[0]}
|
||||
catch {$latestFile = ($filesarray | sort-object date )[-1]}
|
||||
try { $latestFile = ($filesarray | where-object { ($_.date -gt (get-date).AddDays(-2)) -and ($_.date -lt (get-date).AddDays(-1)) } | Sort-Object date)[0] }
|
||||
catch { $latestFile = ($filesarray | sort-object date )[-1] }
|
||||
$latestFile = Get-Item -Path "$scriptroot/../data/archive/$($latestFile.name)"
|
||||
Write-Output "Found file $($latestFile.FullName)"
|
||||
|
||||
|
|
@ -113,8 +129,10 @@ foreach ($player in $all_player_matches) {
|
|||
stats = $killstat
|
||||
winplace = (($all_player_matches | where-object { $_.playername -eq $player_name } ).player_matches | where-object { $_.id -eq $match.id }).stats.winplace
|
||||
}
|
||||
Write-Output "Writing to file $scriptroot/../data/killstats/$($match.id)_$player_name.json"
|
||||
$savekillstats | ConvertTo-Json | out-file "$scriptroot/../data/killstats/$($match.id)_$player_name.json"
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
Write-Output "$($match.id) already in cache"
|
||||
|
|
@ -131,7 +149,7 @@ foreach ($file in $matchfiles) {
|
|||
$killstats += $json
|
||||
}
|
||||
else {
|
||||
write-output "Archiveing $($file.name)"
|
||||
write-output "Archiving $($file.name)"
|
||||
Move-Item -Path $file.FullName -Destination "$scriptroot/../data/killstats/archive" -Force
|
||||
}
|
||||
}
|
||||
|
|
@ -145,11 +163,12 @@ foreach ($player in $all_player_matches.playername) {
|
|||
$kills = (($killstats.stats | where-object { $_.playername -eq $player }).kills | Measure-Object -sum).sum
|
||||
$dbno = (($killstats.stats | where-object { $_.playername -eq $player }).dbno | Measure-Object -sum).sum
|
||||
$humankills = (($killstats.stats | where-object { $_.playername -eq $player }).humankills | Measure-Object -sum).sum
|
||||
$player_matches = ($killstats.stats | where-object { $_.playername -eq $player}).count
|
||||
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1}).count
|
||||
$winratio = ($player_wins / $player_matches) * 100
|
||||
$player_matches = ($killstats.stats | where-object { $_.playername -eq $player }).count
|
||||
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1 }).count
|
||||
$winratio_old = (($oldstats.all | Where-Object { $_.playername -eq $player }).winratio)
|
||||
$winratio = Get-winratio -player_wins $player_wins -player_matches $player_matches
|
||||
$change = get-change -OldWinRatio $winratio_old -NewWinRatio $winratio
|
||||
|
||||
write-output 'all'
|
||||
write-output "Calculating for player $player"
|
||||
write-output "new winratio $winratio"
|
||||
|
|
@ -185,12 +204,10 @@ foreach ($player in $all_player_matches.playername) {
|
|||
$kills = (($killstats.stats | where-object { $_.playername -eq $player -and $_.gameMode -eq 'ibr' -and $_.matchType -eq 'event' }).kills | Measure-Object -sum).sum
|
||||
$dbno = (($killstats.stats | where-object { $_.playername -eq $player -and $_.gameMode -eq 'ibr' -and $_.matchType -eq 'event' }).dbno | Measure-Object -sum).sum
|
||||
$humankills = (($killstats.stats | where-object { $_.playername -eq $player -and $_.gameMode -eq 'ibr' -and $_.matchType -eq 'event' }).humankills | Measure-Object -sum).sum
|
||||
|
||||
$player_matches = ($killstats.stats | where-object { $_.playername -eq $player -and $_.gameMode -eq 'ibr' -and $_.matchType -eq 'event' }).count
|
||||
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1 -and $_.stats.gameMode -eq 'ibr' -and $_.stats.matchType -eq 'event'}).count
|
||||
|
||||
$winratio = ($player_wins / $player_matches) * 100
|
||||
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1 -and $_.stats.gameMode -eq 'ibr' -and $_.stats.matchType -eq 'event' }).count
|
||||
$winratio_old = (($oldstats.Intense | Where-Object { $_.playername -eq $player }).winratio)
|
||||
$winratio = Get-winratio -player_wins $player_wins -player_matches $player_matches
|
||||
$change = get-change -OldWinRatio $winratio_old -NewWinRatio $winratio
|
||||
|
||||
write-output 'event'
|
||||
|
|
@ -207,7 +224,7 @@ foreach ($player in $all_player_matches.playername) {
|
|||
matches = $player_matches
|
||||
KD_H = $humankills / $deaths
|
||||
KD_ALL = $kills / $deaths
|
||||
winratio = ($player_wins / $player_matches) * 100
|
||||
winratio = $winratio
|
||||
wins = $player_wins
|
||||
dbno = $dbno
|
||||
change = $change
|
||||
|
|
@ -226,9 +243,9 @@ foreach ($player in $all_player_matches.playername) {
|
|||
$dbno = (($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'airoyale' }).dbno | Measure-Object -sum).sum
|
||||
$humankills = (($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'airoyale' }).humankills | Measure-Object -sum).sum
|
||||
$player_matches = ($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'airoyale' }).count
|
||||
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1 -and $_.stats.matchType -eq 'airoyale'}).count
|
||||
$winratio = ($player_wins / $player_matches) * 100
|
||||
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1 -and $_.stats.matchType -eq 'airoyale' }).count
|
||||
$winratio_old = (($oldstats.Casual | Where-Object { $_.playername -eq $player }).winratio)
|
||||
$winratio = Get-winratio -player_wins $player_wins -player_matches $player_matches
|
||||
$change = get-change -OldWinRatio $winratio_old -NewWinRatio $winratio
|
||||
|
||||
write-output 'airoyale'
|
||||
|
|
@ -246,7 +263,7 @@ foreach ($player in $all_player_matches.playername) {
|
|||
matches = $player_matches
|
||||
KD_H = $humankills / $deaths
|
||||
KD_ALL = $kills / $deaths
|
||||
winratio = ($player_wins / $player_matches) * 100
|
||||
winratio = $winratio
|
||||
wins = $player_wins
|
||||
dbno = $dbno
|
||||
change = $change
|
||||
|
|
@ -264,9 +281,9 @@ foreach ($player in $all_player_matches.playername) {
|
|||
$dbno = (($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'official' }).dbno | Measure-Object -sum).sum
|
||||
$humankills = (($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'official' }).humankills | Measure-Object -sum).sum
|
||||
$player_matches = ($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'official' }).count
|
||||
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1 -and $_.stats.matchType -eq 'official'}).count
|
||||
$winratio = ($player_wins / $player_matches) * 100
|
||||
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1 -and $_.stats.matchType -eq 'official' }).count
|
||||
$winratio_old = (($oldstats.official | Where-Object { $_.playername -eq $player }).winratio)
|
||||
$winratio = Get-winratio -player_wins $player_wins -player_matches $player_matches
|
||||
$change = get-change -OldWinRatio $winratio_old -NewWinRatio $winratio
|
||||
write-output 'official'
|
||||
write-output "Calculating for player $player"
|
||||
|
|
@ -282,7 +299,7 @@ foreach ($player in $all_player_matches.playername) {
|
|||
matches = $player_matches
|
||||
KD_H = $humankills / $deaths
|
||||
KD_ALL = $kills / $deaths
|
||||
winratio = ($player_wins / $player_matches) * 100
|
||||
winratio = $winratio
|
||||
wins = $player_wins
|
||||
dbno = $dbno
|
||||
change = $change
|
||||
|
|
@ -302,9 +319,9 @@ foreach ($player in $all_player_matches.playername) {
|
|||
$dbno = (($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'custom' }).dbno | Measure-Object -sum).sum
|
||||
$humankills = (($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'custom' }).humankills | Measure-Object -sum).sum
|
||||
$player_matches = ($killstats.stats | where-object { $_.playername -eq $player -and $_.matchType -eq 'custom' }).count
|
||||
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1 -and $_.stats.matchType -eq 'custom'}).count
|
||||
$winratio = ($player_wins / $player_matches) * 100
|
||||
$player_wins = ($killstats | where-object { $_.stats.playername -eq $player -and $_.winplace -eq 1 -and $_.stats.matchType -eq 'custom' }).count
|
||||
$winratio_old = (($oldstats.custom | Where-Object { $_.playername -eq $player }).winratio)
|
||||
$winratio = Get-winratio -player_wins $player_wins -player_matches $player_matches
|
||||
$change = get-change -OldWinRatio $winratio_old -NewWinRatio $winratio
|
||||
write-output 'custom'
|
||||
write-output "Calculating for player $player"
|
||||
|
|
@ -320,7 +337,7 @@ foreach ($player in $all_player_matches.playername) {
|
|||
matches = $player_matches
|
||||
KD_H = $humankills / $deaths
|
||||
KD_ALL = $kills / $deaths
|
||||
winratio = ($player_wins / $player_matches) * 100
|
||||
winratio = $winratio
|
||||
wins = $player_wins
|
||||
dbno = $dbno
|
||||
change = $change
|
||||
|
|
@ -353,8 +370,10 @@ write-output "Writing file"
|
|||
|
||||
$date = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
|
||||
$filenameDate = ($date -replace ":", "-")
|
||||
write-output "writing to file : $scriptroot/../data/archive/$($filenameDate)_player_last_stats.json"
|
||||
($playerstats | convertto-json) | out-file "$scriptroot/../data/archive/$($filenameDate)_player_last_stats.json"
|
||||
|
||||
|
||||
write-output "Cleaning cache"
|
||||
|
||||
$files_keep = (($all_player_matches).player_matches.telemetry_url | Select-Object -Unique) | ForEach-Object { $_.split("/")[-1] }
|
||||
|
|
@ -369,3 +388,5 @@ foreach ($file in $difference) {
|
|||
}
|
||||
write-output "Operation complete"
|
||||
remove-lock
|
||||
$Error
|
||||
Stop-Transcript
|
||||
|
|
@ -1,4 +1,8 @@
|
|||
if ($PSScriptRoot.length -eq 0) {
|
||||
Start-Transcript -Path '/var/log/dtch/update_clan_members.log' -Append
|
||||
Write-Output 'Running from'
|
||||
(Get-Location).path
|
||||
|
||||
if ($PSScriptRoot.length -eq 0) {
|
||||
$scriptroot = Get-Location
|
||||
}
|
||||
else {
|
||||
|
|
@ -28,7 +32,7 @@ if ($fileContent -match "\`$clanmembers\s*=\s*array\(([^)]+)\)") {
|
|||
else {
|
||||
Write-Output "Clan members not found"
|
||||
}
|
||||
if ($clanMembersArray.count -ge 10 ) {
|
||||
if ($clanMembersArray.count -gt 10 ) {
|
||||
write-output "Currently not able to process more then 10 players"
|
||||
exit
|
||||
}
|
||||
|
|
@ -127,3 +131,5 @@ $lifetimestats['updated'] = $formattedString
|
|||
|
||||
$lifetimestats | convertto-json -Depth 100 | out-file "$scriptroot/../data/player_lifetime_data.json"
|
||||
remove-lock
|
||||
$Error
|
||||
Stop-Transcript
|
||||
Loading…
Add table
Add a link
Reference in a new issue