Skip to content

Commit

Permalink
fix selection of newest jira state file
Browse files Browse the repository at this point in the history
  • Loading branch information
TK5-Tim committed Aug 8, 2024
1 parent 6d06e68 commit 454fac8
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions WASP/Private/Read-JiraStateFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function Read-JiraStateFile () {
Author: Tim Keller
Contact: tim.keller@unibas.ch
Created: 2024-07-04
Updated: 2024-07-16
Updated: 2024-08-08
Version: 1.0.0
#>
param(
Expand All @@ -21,18 +21,14 @@ function Read-JiraStateFile () {
$JiraStateFolder = Join-Path -Path $LogPath -ChildPath $Config.Logger.LogSubFilePathJiraStates
} process {
try {
<#Create a ordered hashtable to find the newest jira state file in the jira state folder#>
$AvailableFiles = [Ordered]@{}
<#Create a hashtable to find the newest jira state file in the jira state folder#>
$AvailableFiles = @{}
$Prefix = $Config.Logger.LogFileNamePrefixJiraStates
$Suffix = ".json"
<#Extract the date from the jira state logs and add them to the AvailabeFiles hashtable#>
Get-ChildItem -Path $JiraStateFolder | ForEach-Object {$AvailableFiles[$_.Name] = $([datetime]::parseexact($($_.Name -replace "$Prefix(.+)$Suffix", '$1'), 'yyyy-MM-dd_HH-mm-ss', $null))}
foreach($item in $date_array)
{
$item -replace "$Prefix(.+)$Suffix", '$1'
}
<#Get the full file path of the newest jira state file and convert it from json#>
$FilePath= Join-Path -Path (Get-Item -Path $JiraStateFolder).FullName -ChildPath $($AvailableFiles.Keys | Select-Object -Last 1)
<#Get the full file path of the newest jira state file and convert it from json. The newest file is selected by ordering the available jira state files by date and selecting the last one in the list.#>
$FilePath= Join-Path -Path (Get-Item -Path $JiraStateFolder).FullName -ChildPath $($AvailableFiles.GetEnumerator() | Sort-Object {$_.Value} | Select-Object -Last 1).Key
$JiraState = Get-Content -Path $FilePath -Raw | ConvertFrom-Json -ErrorAction Stop
<#Put the the information of the jira state log into the format that the name@version is the key of the hashtable and the status and assignee are the values#>
$IssuesState = @{}
Expand All @@ -49,7 +45,3 @@ function Read-JiraStateFile () {
return $IssuesState
}
}




0 comments on commit 454fac8

Please sign in to comment.