latest
This commit is contained in:
parent
663183ecb5
commit
48a888e4f4
1 changed files with 21 additions and 9 deletions
|
|
@ -48,7 +48,17 @@ 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 {
|
try {
|
||||||
$latestFile = Get-ChildItem -Path "$scriptroot/../data/archive/" -File -ErrorAction Stop | Sort-Object LastWriteTime -Descending | Select-Object -First 1
|
$filesarray = @()
|
||||||
|
$files = Get-ChildItem -Path "$scriptroot/../data/archive/" -File -ErrorAction Stop
|
||||||
|
foreach ($file in $files) {
|
||||||
|
$dateinfile = $file.Name.split('_')[0]
|
||||||
|
$format = 'yyyy-MM-ddTHH-mm-ss\Z'
|
||||||
|
$culture = [Globalization.CultureInfo]::InvariantCulture
|
||||||
|
$dateTime = [datetime]::ParseExact($dateinfile, $format, $culture)
|
||||||
|
$filesarray += [PSCustomObject]@{name = $file.Name; date = $dateTime }
|
||||||
|
|
||||||
|
}
|
||||||
|
$latestFile = ($filesarray | where-object { $_.date -gt (get-date).AddDays(-1) } | Sort-Object date)[-1]
|
||||||
Write-Output "Found file $($latestFile.FullName)"
|
Write-Output "Found file $($latestFile.FullName)"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +119,8 @@ foreach ($player in $all_player_matches) {
|
||||||
}
|
}
|
||||||
$savekillstats | ConvertTo-Json | out-file "$scriptroot/../data/killstats/$($match.id)_$player_name.json"
|
$savekillstats | ConvertTo-Json | out-file "$scriptroot/../data/killstats/$($match.id)_$player_name.json"
|
||||||
|
|
||||||
} else{
|
}
|
||||||
|
else {
|
||||||
Write-Output "$($match.id) already in cache"
|
Write-Output "$($match.id) already in cache"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +133,8 @@ foreach($file in $matchfiles){
|
||||||
$json = get-content $file | ConvertFrom-Json
|
$json = get-content $file | ConvertFrom-Json
|
||||||
if ($json.created -gt $last_month) {
|
if ($json.created -gt $last_month) {
|
||||||
$killstats += $json.stats
|
$killstats += $json.stats
|
||||||
}else{
|
}
|
||||||
|
else {
|
||||||
write-output "Archiveing $($file.name)"
|
write-output "Archiveing $($file.name)"
|
||||||
Move-Item -Path $file.FullName -Destination "$scriptroot/../data/killstats/archive" -Force
|
Move-Item -Path $file.FullName -Destination "$scriptroot/../data/killstats/archive" -Force
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue