이름 정리 기능 추가.
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
using TriliumMind.Data.Entities;
|
using System;
|
||||||
|
using TriliumMind.Data.Entities;
|
||||||
using TriliumMind.Models;
|
using TriliumMind.Models;
|
||||||
|
|
||||||
namespace TriliumMind.Services.Mappers;
|
namespace TriliumMind.Services.Mappers;
|
||||||
|
|
||||||
public static class JiraIssueMapper
|
public static class JiraIssueMapper
|
||||||
{
|
{
|
||||||
|
private static readonly char[] _specialCharacters = ['(', '/'];
|
||||||
|
|
||||||
public static JiraIssue ToEntity(this Issue issue)
|
public static JiraIssue ToEntity(this Issue issue)
|
||||||
{
|
{
|
||||||
return new JiraIssue
|
return new JiraIssue
|
||||||
@@ -13,9 +16,9 @@ public static class JiraIssueMapper
|
|||||||
Summary = issue.fields.summary ?? string.Empty,
|
Summary = issue.fields.summary ?? string.Empty,
|
||||||
Parent = issue.fields.parent?.key ?? issue.fields.customfield_10808,
|
Parent = issue.fields.parent?.key ?? issue.fields.customfield_10808,
|
||||||
Type = issue.fields.issuetype?.name ?? string.Empty,
|
Type = issue.fields.issuetype?.name ?? string.Empty,
|
||||||
Status = issue.fields.status?.description ?? string.Empty,
|
Status = issue.fields.status?.name ?? string.Empty,
|
||||||
Assignee = issue.fields.assignee?.displayName ?? string.Empty,
|
Assignee = CleanDisplayName(issue.fields.assignee?.displayName),
|
||||||
Manager = issue.fields.reporter?.displayName ?? string.Empty,
|
Manager = CleanDisplayName(issue.fields.reporter?.displayName),
|
||||||
Due = issue.fields.duedate?.ToUniversalTime() ?? DateTimeOffset.MinValue.ToUniversalTime(),
|
Due = issue.fields.duedate?.ToUniversalTime() ?? DateTimeOffset.MinValue.ToUniversalTime(),
|
||||||
Updated = issue.fields.UpdatedAt.ToUniversalTime(),
|
Updated = issue.fields.UpdatedAt.ToUniversalTime(),
|
||||||
Published = DateTimeOffset.MinValue.ToUniversalTime(),
|
Published = DateTimeOffset.MinValue.ToUniversalTime(),
|
||||||
@@ -23,4 +26,16 @@ public static class JiraIssueMapper
|
|||||||
NeedNotify = 0
|
NeedNotify = 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string CleanDisplayName(string? displayName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(displayName))
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
var specialCharIndex = displayName.IndexOfAny(_specialCharacters);
|
||||||
|
if (specialCharIndex >= 0)
|
||||||
|
displayName = displayName[..specialCharIndex];
|
||||||
|
|
||||||
|
return displayName.Trim();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user