немного рефакторинга

This commit is contained in:
Danil Kislov
2019-07-02 18:22:12 +03:00
parent c95f228ef0
commit 364b23dbca
9 changed files with 95 additions and 84 deletions
+1 -1
View File
@@ -1 +1 @@
1.0.59 1.0.60
@@ -46,28 +46,26 @@ namespace JiraTimeBot.JiraIntegration
{ {
foreach (var comment in userComments.OrderBy(f=>f.CreatedDate)) foreach (var comment in userComments.OrderBy(f=>f.CreatedDate))
{ {
workTasks.Add(new TaskTimeItem var item = new TaskTimeItem(issue.Key.Value,
{ issue.Summary,
StartTime = issue.Updated.GetValueOrDefault(date.Value), 1,
Description = issue.Summary, TimeSpan.Zero,
Branch = issue.Key.Value, issue.Updated.GetValueOrDefault(date.Value),
FilesAffected = 1, 1,
Commits = 1, CommitType.Task);
Type = CommitType.Task workTasks.Add(item);
});
} }
} }
else else
{ {
workTasks.Add(new TaskTimeItem var item = new TaskTimeItem(issue.Key.Value,
{ issue.Summary,
StartTime = issue.Updated.GetValueOrDefault(date.Value), 1,
Description = issue.Summary, TimeSpan.Zero,
Branch = issue.Key.Value, issue.Updated.GetValueOrDefault(date.Value),
FilesAffected = 1, 1,
Commits = 1, CommitType.Task);
Type = CommitType.Task workTasks.Add(item);
});
} }
} }
+1
View File
@@ -92,6 +92,7 @@
<Compile Include="Mercurial\IMercurialLog.cs" /> <Compile Include="Mercurial\IMercurialLog.cs" />
<Compile Include="Mercurial\Modifiers\TechnicalInfoSkipper.cs" /> <Compile Include="Mercurial\Modifiers\TechnicalInfoSkipper.cs" />
<Compile Include="TasksProcessors\IAllTasksProcessors.cs" /> <Compile Include="TasksProcessors\IAllTasksProcessors.cs" />
<Compile Include="TaskTime\Objects\CommitType.cs" />
<Compile Include="TaskTime\TaskTimeSpread.cs" /> <Compile Include="TaskTime\TaskTimeSpread.cs" />
<Compile Include="UI\frmMain.cs"> <Compile Include="UI\frmMain.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
+7 -10
View File
@@ -72,16 +72,13 @@ namespace JiraTimeBot.Mercurial
} }
commitMessage = _technicalInfoSkipper.StripTechnicalInfo(commitMessage); commitMessage = _technicalInfoSkipper.StripTechnicalInfo(commitMessage);
var task = new TaskTimeItem var task = new TaskTimeItem(changeset.Branch,
{ commitMessage,
StartTime = changeset.Timestamp, 1,
Description = commitMessage, TimeSpan.Zero,
Branch = changeset.Branch, changeset.Timestamp,
FilesAffected = changeset.PathActions.Count, changeset.PathActions.Count,
Commits = 1, GetCommitType(changeset.Branch));
TimeSpent = TimeSpan.Zero,
Type = GetCommitType(changeset.Branch)
};
if (task.Type == CommitType.Release && task.Description.StartsWith("Merge with", StringComparison.CurrentCultureIgnoreCase)) if (task.Type == CommitType.Release && task.Description.StartsWith("Merge with", StringComparison.CurrentCultureIgnoreCase))
{ {
+3 -3
View File
@@ -26,6 +26,6 @@ using System.Runtime.InteropServices;
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.59")] [assembly: AssemblyVersion("1.0.60")]
[assembly: AssemblyFileVersion("1.0.59")] [assembly: AssemblyFileVersion("1.0.60")]
[assembly: AssemblyInformationalVersion("1.0.59")] [assembly: AssemblyInformationalVersion("1.0.60")]
@@ -0,0 +1,7 @@
namespace JiraTimeBot.TaskTime.Objects
{
public enum CommitType {
Task = 0,
Release = 1
}
}
@@ -11,10 +11,17 @@ namespace JiraTimeBot.TaskTime.Objects
public int Commits { get; set; } public int Commits { get; set; }
public int FilesAffected { get; set; } public int FilesAffected { get; set; }
public CommitType Type { get; set; } public CommitType Type { get; set; }
}
public enum CommitType { public TaskTimeItem(string branch, string description, int commits, TimeSpan timeSpent, DateTime startTime,
Task = 0, int filesAffected, CommitType type)
Release = 1 {
Branch = branch;
Description = description;
Commits = commits;
TimeSpent = timeSpent;
StartTime = startTime;
FilesAffected = filesAffected;
Type = type;
}
} }
} }
@@ -93,13 +93,13 @@ namespace JiraTimeBot.TaskTime
//Если указана задача контроля времени - то спишем туда 30 минут и вычеркнем их из общего рабочего времени. //Если указана задача контроля времени - то спишем туда 30 минут и вычеркнем их из общего рабочего времени.
if (!string.IsNullOrEmpty(timeControlTask)) if (!string.IsNullOrEmpty(timeControlTask))
{ {
return new TaskTimeItem return new TaskTimeItem(timeControlTask,
{ "Ведение учета времени",
TimeSpent = TimeSpan.FromMinutes(minutes), 1,
Branch = timeControlTask, TimeSpan.FromMinutes(minutes),
Commits = 1, DateTime.Now,
Description = "Ведение учета времени" 1,
}; CommitType.Task);
} }
return null; return null;
+13 -12
View File
@@ -34,19 +34,20 @@ namespace JiraTimeBot.TaskTime
{ {
sb.AppendLine($"- {task.Description}"); sb.AppendLine($"- {task.Description}");
} }
var taskTimeItem = new TaskTimeItem
{ var timeSpent = appendTime
Branch = taskGroup.Key, ? TimeSpan.FromMinutes(taskGroup.Sum(f => f.TimeSpent.TotalMinutes)) +
TimeSpent = appendTime ?
TimeSpan.FromMinutes(taskGroup.Sum(f=>f.TimeSpent.TotalMinutes)) + TimeSpan.FromMinutes(currentTaskTime):
TimeSpan.FromMinutes(currentTaskTime) TimeSpan.FromMinutes(currentTaskTime)
, : TimeSpan.FromMinutes(currentTaskTime);
Commits = taskGroup.Sum(f=>f.Commits),
Description = sb.ToString(), var taskTimeItem = new TaskTimeItem(
StartTime = taskGroup.Min(f=>f.StartTime), taskGroup.Key,
FilesAffected = taskGroup.Sum(f=>f.FilesAffected), sb.ToString(),
Type = taskGroup.First().Type taskGroup.Sum(f => f.Commits),
}; timeSpent,
taskGroup.Min(f => f.StartTime),
taskGroup.Sum(f => f.FilesAffected),
taskGroup.First().Type);
newList.Add(taskTimeItem); newList.Add(taskTimeItem);
} }