public/Get-FootballFixturePredictedScoreCardData.ps1
function Get-FootballFixturePredictedScoreCardData { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Competition, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Date, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Path ) process{ $ErrorActionPreference = 'Stop' try { $Hash1 =@{ Competition = $Competition Date = $Date PSFunctionName = $($MyInvocation.MyCommand.Name) } $Hash1 | Format-Table $CorectSP = Get-CorrectScoreProbability -Competition $Competition -Date $Date -TeamName vs -Path "$Path\sportsmonk-predictions" $UniqueFixtures += $CorectSP | Select-Object FixtureName -Unique # Get the top 3 scores per unqiue ficiture $SortedCP =@() foreach ($UniqueFixture in $UniqueFixtures) { $SortedCP += $CorectSP | Where-Object {$_.FixtureName -eq $UniqueFixture.FixtureName} ` | Sort-Object -Property Percentage -Descending | Select-Object -First 3 } # foreach if ($($SortedCP.Count) -ge 1) { # Get all the predictions for every fixture $PredictionPSObjects = Get-FootballFixturePredictedScore -Competition $Competition -Date $Date -Path $Path if ($( $PredictionPSObjects.Count) -lt 1) { throw 'No predictions found.' } # if # Get the Outcomes for all the fixtures $ResultPSObjects = Get-FootballFixtureOutcome -Competition $Competition -Date $Date -Path $Path if ($($ResultPSObjects.Count) -lt 1) { Write-Warning -Message 'No outcomes.' } # if # Array to store the results and the associated percentages $FixturePredictedScores =@() # Get the result and associated percentage foreach ($RObject in $ResultPSObjects) { $MatchPredictedScore = $PredictionPSObjects | Where-Object {$_.FixtureId -eq $($RObject.FixtureId)} $MatchPredictedScore = $MatchPredictedScore | Where-Object {$_.Result -eq $($RObject.FullTimeResult)} $FixturePredictedScores += $MatchPredictedScore } # ------ Export $CompetionPath = "$Path\game-predictions-outcomes\$Competition\$Date" $CompetionPathExists = Test-Path -Path $CompetionPath if (!$CompetionPathExists) { New-Item -Path $CompetionPath -ItemType Directory -Verbose | Out-Null } # if # Export top 3 scores to csv esp-laliga-240-2025-02-09 $SortedCP | Export-Csv -Path "$CompetionPath\$Competition-240-$Date.csv" -Force -Verbose # Export # The FT Score and the associated percentage if ($($FixturePredictedScores.Count) -lt 1) { Write-Warning -Message 'No FixturePredictedScores.' } else { $FixturePredictedScores | Export-Csv -Path "$CompetionPath\$Competition-$Date-matched-predicitons.csv" -Force } # if $FixturePredictedScores | Export-Csv -Path "$CompetionPath\$Competition-$Date-matched-predicitons.csv" -Force if ($($PredictionPSObjects.Count) -lt 1) { Write-Warning -Message 'No PredictionPSObjects.' } else { # Export all the predictions $PredictionPSObjects | Export-Csv -Path "$CompetionPath\$Competition-$Date-all-predicitons.csv" -Force } #if } # if } catch { throw "$($MyInvocation.MyCommand.Name): $_.Exception.Message" } # trycatch } # process } # function |