Skip to content

Commit

Permalink
🔧 fix: retrieval of worklogs per user, issue and date range was missi…
Browse files Browse the repository at this point in the history
…ng the user predicate
  • Loading branch information
Peter Hraško committed Jan 29, 2024
1 parent 4b5055e commit 91824e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
26 changes: 14 additions & 12 deletions jwl.jira/VanillaJiraServerApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace jwl.jira;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Json;
using System.Xml.Linq;
using jwl.infra;

public class VanillaJiraServerApi
Expand Down Expand Up @@ -58,6 +59,7 @@ public async Task<WorkLog[]> GetIssueWorklogs(DateOnly from, DateOnly to, IEnume

var result = responseTasks
.SelectMany(task => task.Result.Worklogs)
.Where(worklog => worklog.Author.Name == UserName)
.Where(worklog => worklog.Started.Value >= minDt && worklog.Started.Value < supDt)
.Select(wl => new WorkLog(
Id: wl.Id.Value,
Expand All @@ -83,15 +85,15 @@ public async Task AddWorklog(string issueKey, DateOnly day, int timeSpentSeconds
.Add(issueKey)
.Add(@"worklog")
};
var request = new api.rest.request.JiraAddWorklogByIssueKey()
{
Started = day
var request = new api.rest.request.JiraAddWorklogByIssueKey(
Started: day
.ToDateTime(TimeOnly.MinValue)
.ToString(@"yyyy-MM-dd""T""hh"";""mm"";""ss.fffzzzz")
.Replace(":", string.Empty)
.Replace(';', ':'),
TimeSpentSeconds = timeSpentSeconds,
Comment = comment
};
TimeSpentSeconds: timeSpentSeconds,
Comment: comment
);
await _httpClient.PostAsJsonAsync(uriBuilder.Uri.PathAndQuery, request);
}

Expand Down Expand Up @@ -137,15 +139,15 @@ public async Task UpdateWorklog(string issueKey, long worklogId, DateOnly day, i
.Add(@"worklog")
.Add(worklogId.ToString())
};
var request = new api.rest.request.JiraAddWorklogByIssueKey()
{
Started = day
var request = new api.rest.request.JiraAddWorklogByIssueKey(
Started: day
.ToDateTime(TimeOnly.MinValue)
.ToString(@"yyyy-MM-dd""T""hh"";""mm"";""ss.fffzzzz")
.Replace(":", string.Empty)
.Replace(';', ':'),
TimeSpentSeconds = timeSpentSeconds,
Comment = comment
};
TimeSpentSeconds: timeSpentSeconds,
Comment: comment
);
await _httpClient.PutAsJsonAsync(uriBuilder.Uri.PathAndQuery, request);
}
}
6 changes: 2 additions & 4 deletions jwl.jira/api/rest/request/JiraAddWorklogByIssueKey.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma warning disable SA1313
namespace jwl.jira.api.rest.request;

public class JiraAddWorklogByIssueKey
public record JiraAddWorklogByIssueKey(string Started, int TimeSpentSeconds, string? Comment)
{
public string? Started { get; init; }
public int? TimeSpentSeconds { get; init; }
public string? Comment { get; init; }
}

0 comments on commit 91824e2

Please sign in to comment.