save killstats

This commit is contained in:
Thijs Stobbelaar 2023-11-06 09:53:41 +01:00
parent 2b5fa68257
commit 76b38729e7

View file

@ -47,10 +47,12 @@ function get-killstats {
} }
} }
# Get the latest file in the directory by last modification time # Get the latest file in the directory by last modification time
try { $latestFile = Get-ChildItem -Path "$scriptroot/../data/archive/" -File -ErrorAction Stop | Sort-Object LastWriteTime -Descending | Select-Object -First 1 try {
Write-Output "Found file $($latestFile.FullName)" $latestFile = Get-ChildItem -Path "$scriptroot/../data/archive/" -File -ErrorAction Stop | Sort-Object LastWriteTime -Descending | Select-Object -First 1
Write-Output "Found file $($latestFile.FullName)"
} catch { }
catch {
$latestFile = @() $latestFile = @()
} }
@ -70,7 +72,7 @@ $all_player_matches = get-content "$scriptroot/../data/player_matches.json" | c
$killstats = @() $killstats = @()
$i = 0 $i = 0
foreach ($player in ($all_player_matches)) { foreach ($player in $all_player_matches) {
if ($player.psobject.properties.name -eq 'new_win_matches') { if ($player.psobject.properties.name -eq 'new_win_matches') {
continue continue
} }
@ -96,7 +98,16 @@ foreach ($player in ($all_player_matches)) {
} }
write-output "Analyzing for player $player_name telemetry: $($match.telemetry_url)" write-output "Analyzing for player $player_name telemetry: $($match.telemetry_url)"
$killstats += get-killstats -player_name $player_name -telemetry ($telemetry | where-object { $_._T -eq 'LOGPLAYERKILLV2' }) -gameMode $match.gameMode -matchType $match.matchType $killstat = get-killstats -player_name $player_name -telemetry ($telemetry | where-object { $_._T -eq 'LOGPLAYERKILLV2' }) -gameMode $match.gameMode -matchType $match.matchType
$killstats += $killstat
if ($save) {
$savekillstats = @{
matchid = $match.id
created = $match.createdAt
stats = $killstats
}
$savekillstats | ConvertTo-Json | out-file "$scriptroot/../data/killstats/$($match.id).json"
}
} }
} }