Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27cf8416aa | ||
|
|
2f1578a695 | ||
|
|
e26ef9d7f4 | ||
|
|
d8de5aba1c | ||
|
|
1e40f0a07c | ||
|
|
64723248a5 | ||
|
|
c97ab59b96 | ||
|
|
4e8fa0b801 | ||
|
|
61e53c3698 |
+1
-1
@@ -1 +1 @@
|
|||||||
1.0.61
|
1.0.70
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace JiraTimeBot.Configuration
|
|||||||
public int RoundToMinutes { get; set; }
|
public int RoundToMinutes { get; set; }
|
||||||
|
|
||||||
public string JiraUrl = "https://myteam.aeroclub.ru";
|
public string JiraUrl = "https://myteam.aeroclub.ru";
|
||||||
|
public bool PullBeforeProcess { get; set; }
|
||||||
public string RepositoryPath { get; set; }
|
public string RepositoryPath { get; set; }
|
||||||
public string MercurialAuthorEmail { get; set; }
|
public string MercurialAuthorEmail { get; set; }
|
||||||
public string JiraUserName { get; set; }
|
public string JiraUserName { get; set; }
|
||||||
@@ -61,7 +61,7 @@ namespace JiraTimeBot.Configuration
|
|||||||
var errors = new List<string>();
|
var errors = new List<string>();
|
||||||
message = null;
|
message = null;
|
||||||
|
|
||||||
if (settings.RoundToMinutes == default(int))
|
if (settings.RoundToMinutes == default)
|
||||||
{
|
{
|
||||||
errors.Add("Укажите округление времени, например, 10 (минут)");
|
errors.Add("Укажите округление времени, например, 10 (минут)");
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ namespace JiraTimeBot.Configuration
|
|||||||
File.WriteAllText(settingsPath, settingsString);
|
File.WriteAllText(settingsPath, settingsString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string _settingsFileName = "settings.json";
|
private static readonly string _settingsFileName = "settings.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum WorkType
|
public enum WorkType
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ namespace JiraTimeBot.DI
|
|||||||
|
|
||||||
_builder.RegisterType<JiraDescriptionSource>().AsSelf().As<IJiraDescriptionSource>();
|
_builder.RegisterType<JiraDescriptionSource>().AsSelf().As<IJiraDescriptionSource>();
|
||||||
_builder.RegisterType<JiraApi>().AsSelf().AsImplementedInterfaces();
|
_builder.RegisterType<JiraApi>().AsSelf().AsImplementedInterfaces();
|
||||||
|
|
||||||
|
_builder.RegisterType<JiraHistory>().AsSelf().As<IJiraHistory>();
|
||||||
|
|
||||||
_builder.Register(c => new Job(c.Resolve<IAllMercurialProviders>(), c.Resolve<ITaskTimeCalculator>(), c.Resolve<ILog>())).AsSelf();
|
_builder.Register(c => new Job(c.Resolve<IAllMercurialProviders>(), c.Resolve<ITaskTimeCalculator>(), c.Resolve<ILog>())).AsSelf();
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,15 @@ using JiraTimeBot.TaskTime.Objects;
|
|||||||
|
|
||||||
namespace JiraTimeBot.JiraIntegration
|
namespace JiraTimeBot.JiraIntegration
|
||||||
{
|
{
|
||||||
public class JiraApi
|
public interface IJiraApi
|
||||||
|
{
|
||||||
|
List<Issue> GetIssuesByJQL(string jql, Settings settings, DateTime? date = null, CancellationToken cancellationToken = default);
|
||||||
|
string GetTaskName(string branch, Settings settings);
|
||||||
|
List<Issue> GetWorkloggedIssuesByDate(Settings settings, DateTime? date = null, CancellationToken cancellationToken = default);
|
||||||
|
void SetTodayWorklog(List<TaskTimeItem> taskTimeItems, Settings settings, DateTime? date = null, bool dummy = false, bool addCommentsToWorklog = false, CancellationToken cancellationToken = default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JiraApi : IJiraApi
|
||||||
{
|
{
|
||||||
private readonly ILog _log;
|
private readonly ILog _log;
|
||||||
private readonly IJiraDescriptionSource _descriptionSource;
|
private readonly IJiraDescriptionSource _descriptionSource;
|
||||||
@@ -34,7 +42,7 @@ namespace JiraTimeBot.JiraIntegration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Issue> GetIssuesByJQL(string jql, Settings settings, DateTime? date = null, CancellationToken cancellationToken = default(CancellationToken))
|
public List<Issue> GetIssuesByJQL(string jql, Settings settings, DateTime? date = null, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var jira = Jira.CreateRestClient(settings.JiraUrl, settings.JiraUserName, settings.JiraPassword);
|
var jira = Jira.CreateRestClient(settings.JiraUrl, settings.JiraUserName, settings.JiraPassword);
|
||||||
date = date.GetValueOrDefault(DateTime.Now.Date);
|
date = date.GetValueOrDefault(DateTime.Now.Date);
|
||||||
@@ -61,14 +69,14 @@ namespace JiraTimeBot.JiraIntegration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Issue> GetWorkloggedIssuesByDate(Settings settings, DateTime? date = null, CancellationToken cancellationToken = default(CancellationToken))
|
public List<Issue> GetWorkloggedIssuesByDate(Settings settings, DateTime? date = null, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
date = date.GetValueOrDefault(DateTime.Now.Date);
|
date = date.GetValueOrDefault(DateTime.Now.Date);
|
||||||
var jql = "issueFunction in workLogged(\"on %DATE% by '%USER%'\")";
|
var jql = "issueFunction in workLogged(\"on %DATE% by '%USER%'\")";
|
||||||
return GetIssuesByJQL(jql, settings, date, cancellationToken);
|
return GetIssuesByJQL(jql, settings, date, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveWorklogsAddedByUser(List<TaskTimeItem> taskTimeItems, Settings settings, DateTime? date = null, bool dummy = false, CancellationToken cancellationToken = default(CancellationToken))
|
private void RemoveWorklogsAddedByUser(List<TaskTimeItem> taskTimeItems, Settings settings, DateTime? date = null, bool dummy = false, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var alreadyLoggedToday = GetWorkloggedIssuesByDate(settings, date);
|
var alreadyLoggedToday = GetWorkloggedIssuesByDate(settings, date);
|
||||||
foreach (var issue in alreadyLoggedToday)
|
foreach (var issue in alreadyLoggedToday)
|
||||||
@@ -77,7 +85,7 @@ namespace JiraTimeBot.JiraIntegration
|
|||||||
{
|
{
|
||||||
var workLogs = issue.GetWorklogsAsync(cancellationToken).Result;
|
var workLogs = issue.GetWorklogsAsync(cancellationToken).Result;
|
||||||
var userWorklogs = workLogs.Where(w =>
|
var userWorklogs = workLogs.Where(w =>
|
||||||
w.CreateDate.GetValueOrDefault().Date == date && w.Author.Equals(settings.JiraUserName,
|
w.StartDate.GetValueOrDefault().Date == date && w.Author.Equals(settings.JiraUserName,
|
||||||
StringComparison.InvariantCultureIgnoreCase)).ToList();
|
StringComparison.InvariantCultureIgnoreCase)).ToList();
|
||||||
foreach (var userWorklog in userWorklogs)
|
foreach (var userWorklog in userWorklogs)
|
||||||
{
|
{
|
||||||
@@ -92,7 +100,7 @@ namespace JiraTimeBot.JiraIntegration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTodayWorklog(List<TaskTimeItem> taskTimeItems, Settings settings, DateTime? date = null, bool dummy = false, bool addCommentsToWorklog = false, CancellationToken cancellationToken = default(CancellationToken))
|
public void SetTodayWorklog(List<TaskTimeItem> taskTimeItems, Settings settings, DateTime? date = null, bool dummy = false, bool addCommentsToWorklog = false, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
date = date.GetValueOrDefault(DateTime.Now.Date).Date;
|
date = date.GetValueOrDefault(DateTime.Now.Date).Date;
|
||||||
var jira = Jira.CreateRestClient(settings.JiraUrl, settings.JiraUserName, settings.JiraPassword);
|
var jira = Jira.CreateRestClient(settings.JiraUrl, settings.JiraUserName, settings.JiraPassword);
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ namespace JiraTimeBot.JiraIntegration
|
|||||||
TimeSpan.Zero,
|
TimeSpan.Zero,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
|
"",
|
||||||
CommitType.Task);
|
CommitType.Task);
|
||||||
workTasks.Add(item);
|
workTasks.Add(item);
|
||||||
}
|
}
|
||||||
@@ -66,6 +67,7 @@ namespace JiraTimeBot.JiraIntegration
|
|||||||
TimeSpan.Zero,
|
TimeSpan.Zero,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
|
"",
|
||||||
CommitType.Task);
|
CommitType.Task);
|
||||||
workTasks.Add(item);
|
workTasks.Add(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using JiraTimeBot.Configuration;
|
||||||
|
using JiraTimeBot.TaskTime.Objects;
|
||||||
|
|
||||||
|
namespace JiraTimeBot.JiraIntegration
|
||||||
|
{
|
||||||
|
public interface IJiraHistory
|
||||||
|
{
|
||||||
|
List<TaskTimeItem> GetDayWorklogs(DateTime date,
|
||||||
|
Settings settings,
|
||||||
|
CancellationToken cancellationToken = default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class JiraHistory: IJiraHistory
|
||||||
|
{
|
||||||
|
private readonly IJiraApi _jiraApi;
|
||||||
|
|
||||||
|
public JiraHistory(IJiraApi jiraApi)
|
||||||
|
{
|
||||||
|
_jiraApi = jiraApi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TaskTimeItem> GetDayWorklogs(DateTime date,
|
||||||
|
Settings settings,
|
||||||
|
CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
var tasks = _jiraApi.GetIssuesByJQL("worklogDate = \"%DATE%\" and worklogAuthor='%USER%'", settings, date, cancellationToken);
|
||||||
|
List<TaskTimeItem> resultItems = new List<TaskTimeItem>();
|
||||||
|
foreach (var issue in tasks)
|
||||||
|
{
|
||||||
|
var workLogs = issue.GetWorklogsAsync(cancellationToken).Result;
|
||||||
|
var user = settings.JiraUserName;
|
||||||
|
var userWorklogs = workLogs.Where(w =>
|
||||||
|
w.StartDate.GetValueOrDefault().Date == date && w.Author.Equals(user,
|
||||||
|
StringComparison.InvariantCultureIgnoreCase)).ToList();
|
||||||
|
if (!userWorklogs.Any())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstWorklog = userWorklogs.First();
|
||||||
|
|
||||||
|
var description = string.Join(Environment.NewLine, userWorklogs.Select(f => f.Comment).Distinct());
|
||||||
|
var totalTime = TimeSpan.FromSeconds(userWorklogs.Sum(f => f.TimeSpentInSeconds));
|
||||||
|
var startDate = firstWorklog?.CreateDate ?? date;
|
||||||
|
var commits = userWorklogs.Sum(f => f.Comment.Count(c => c == '\n'));
|
||||||
|
if (commits == 0)
|
||||||
|
{
|
||||||
|
commits = 1;
|
||||||
|
}
|
||||||
|
var taskType = CommitType.Task;
|
||||||
|
if (description.Contains("Подготовка и публикация"))
|
||||||
|
{
|
||||||
|
taskType = CommitType.Release;
|
||||||
|
}
|
||||||
|
|
||||||
|
resultItems.Add(new TaskTimeItem(issue.Key.Value, description, issue.Project, startDate, totalTime, commits, 1, "", taskType));
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultItems;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<LangVersion>7.1</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@@ -81,6 +82,7 @@
|
|||||||
<Compile Include="DI\ContainerBuilder.cs" />
|
<Compile Include="DI\ContainerBuilder.cs" />
|
||||||
<Compile Include="JiraIntegration\Comments\IJiraDescriptionSource.cs" />
|
<Compile Include="JiraIntegration\Comments\IJiraDescriptionSource.cs" />
|
||||||
<Compile Include="JiraIntegration\Comments\JiraDescriptionSource.cs" />
|
<Compile Include="JiraIntegration\Comments\JiraDescriptionSource.cs" />
|
||||||
|
<Compile Include="JiraIntegration\JiraHistory.cs" />
|
||||||
<Compile Include="Job.cs" />
|
<Compile Include="Job.cs" />
|
||||||
<Compile Include="Logger.cs" />
|
<Compile Include="Logger.cs" />
|
||||||
<Compile Include="Configuration\Settings.cs" />
|
<Compile Include="Configuration\Settings.cs" />
|
||||||
|
|||||||
+12
-2
@@ -78,8 +78,18 @@ namespace JiraTimeBot
|
|||||||
_log.Info("Использую Jira как источник информации.");
|
_log.Info("Использую Jira как источник информации.");
|
||||||
mercurial = _mercurialProviders.JiraCommitEmulator;
|
mercurial = _mercurialProviders.JiraCommitEmulator;
|
||||||
}
|
}
|
||||||
List<TaskTimeItem> commits = mercurial.GetMercurialLog(settings, realDate, cancellationToken);
|
|
||||||
List<TaskTimeItem> taskTimes = _taskTimeDiscoverer.CalculateTaskTime(commits, settings, cancellationToken);
|
List<TaskTimeItem> taskTimes;
|
||||||
|
if (!(tasksProcessor is MeetingProcessor))
|
||||||
|
{
|
||||||
|
List<TaskTimeItem> commits = mercurial.GetMercurialLog(settings, realDate, cancellationToken);
|
||||||
|
taskTimes = _taskTimeDiscoverer.CalculateTaskTime(commits, settings, cancellationToken);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var provider = _mercurialProviders.JiraHistory;
|
||||||
|
taskTimes = provider.GetDayWorklogs(realDate, settings, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
if (cancellationToken.IsCancellationRequested)
|
if (cancellationToken.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,5 +6,6 @@ namespace JiraTimeBot.Mercurial
|
|||||||
{
|
{
|
||||||
MercurialLog MercurialLog { get; }
|
MercurialLog MercurialLog { get; }
|
||||||
JiraCommitEmulator JiraCommitEmulator { get; }
|
JiraCommitEmulator JiraCommitEmulator { get; }
|
||||||
|
IJiraHistory JiraHistory { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace JiraTimeBot.Mercurial
|
|||||||
_technicalInfoSkipper = technicalInfoSkipper;
|
_technicalInfoSkipper = technicalInfoSkipper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TaskTimeItem> GetMercurialLog(Settings settings, DateTime? date = null, CancellationToken cancellationToken = default(CancellationToken))
|
public List<TaskTimeItem> GetMercurialLog(Settings settings, DateTime? date = null, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(settings.RepositoryPath) || !Directory.Exists(settings.RepositoryPath))
|
if (string.IsNullOrEmpty(settings.RepositoryPath) || !Directory.Exists(settings.RepositoryPath))
|
||||||
{
|
{
|
||||||
@@ -51,6 +51,12 @@ namespace JiraTimeBot.Mercurial
|
|||||||
var directoryInfo = new DirectoryInfo(repoDirectory);
|
var directoryInfo = new DirectoryInfo(repoDirectory);
|
||||||
|
|
||||||
var repo = new Repository(repoDirectory);
|
var repo = new Repository(repoDirectory);
|
||||||
|
|
||||||
|
if (settings.PullBeforeProcess)
|
||||||
|
{
|
||||||
|
repo.Pull();
|
||||||
|
}
|
||||||
|
|
||||||
var logCommand = new LogCommand
|
var logCommand = new LogCommand
|
||||||
{
|
{
|
||||||
Date = date,
|
Date = date,
|
||||||
@@ -80,7 +86,8 @@ namespace JiraTimeBot.Mercurial
|
|||||||
changeset.Timestamp,
|
changeset.Timestamp,
|
||||||
TimeSpan.Zero,
|
TimeSpan.Zero,
|
||||||
1,
|
1,
|
||||||
changeset.PathActions.Count,
|
changeset.PathActions.Count,
|
||||||
|
"",
|
||||||
GetCommitType(changeset.Branch));
|
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))
|
||||||
@@ -95,6 +102,7 @@ namespace JiraTimeBot.Mercurial
|
|||||||
|
|
||||||
task.Branch = branch;
|
task.Branch = branch;
|
||||||
task.Description = $"Подготовка и публикация версии {task.Project} {release}.";
|
task.Description = $"Подготовка и публикация версии {task.Project} {release}.";
|
||||||
|
task.ReleaseVersion = release;
|
||||||
}
|
}
|
||||||
workTasks.Add(task);
|
workTasks.Add(task);
|
||||||
_log?.Trace($" - Найден changeset: {changeset.Timestamp} - {changeset.Branch} - {changeset.AuthorEmailAddress} - {commitMessage}");
|
_log?.Trace($" - Найден changeset: {changeset.Timestamp} - {changeset.Branch} - {changeset.AuthorEmailAddress} - {commitMessage}");
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("JiraTimeBot")]
|
[assembly: AssemblyTitle("JiraTimeBot")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("JiraTimeBot")]
|
[assembly: AssemblyProduct("JiraTimeBot")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
// to COM components. If you need to access a type in this assembly from
|
// to COM components. If you need to access a type in this assembly from
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
[assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")]
|
[assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")]
|
||||||
// Version information for an assembly consists of the following four values:
|
// Version information for an assembly consists of the following four values:
|
||||||
//
|
//
|
||||||
// Major Version
|
// Major Version
|
||||||
// Minor Version
|
// Minor Version
|
||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
// 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.61")]
|
[assembly: AssemblyVersion("1.0.70")]
|
||||||
[assembly: AssemblyFileVersion("1.0.61")]
|
[assembly: AssemblyFileVersion("1.0.70")]
|
||||||
[assembly: AssemblyInformationalVersion("1.0.61")]
|
[assembly: AssemblyInformationalVersion("1.0.70")]
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
namespace JiraTimeBot.TaskTime.Objects
|
using System;
|
||||||
|
|
||||||
|
namespace JiraTimeBot.TaskTime.Objects
|
||||||
{
|
{
|
||||||
|
[Flags]
|
||||||
public enum CommitType {
|
public enum CommitType {
|
||||||
Task = 0,
|
Task = 1,
|
||||||
Release = 1
|
Release = 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,9 +12,10 @@ namespace JiraTimeBot.TaskTime.Objects
|
|||||||
public int FilesAffected { get; set; }
|
public int FilesAffected { get; set; }
|
||||||
public CommitType Type { get; set; }
|
public CommitType Type { get; set; }
|
||||||
public string Project { get; set; }
|
public string Project { get; set; }
|
||||||
|
public string ReleaseVersion { get; set; }
|
||||||
|
|
||||||
public TaskTimeItem(string branch, string description, string project, DateTime startTime, TimeSpan timeSpent, int commits,
|
public TaskTimeItem(string branch, string description, string project, DateTime startTime, TimeSpan timeSpent, int commits,
|
||||||
int filesAffected = 1, CommitType type = CommitType.Task)
|
int filesAffected = 1, string releaseVersion = "", CommitType type = CommitType.Task)
|
||||||
{
|
{
|
||||||
Branch = branch;
|
Branch = branch;
|
||||||
Description = description;
|
Description = description;
|
||||||
@@ -23,7 +24,16 @@ namespace JiraTimeBot.TaskTime.Objects
|
|||||||
TimeSpent = timeSpent;
|
TimeSpent = timeSpent;
|
||||||
StartTime = startTime;
|
StartTime = startTime;
|
||||||
FilesAffected = filesAffected;
|
FilesAffected = filesAffected;
|
||||||
|
ReleaseVersion = releaseVersion;
|
||||||
Type = type;
|
Type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MergeWith(TaskTimeItem toMerge)
|
||||||
|
{
|
||||||
|
Commits += toMerge.Commits;
|
||||||
|
TimeSpent += toMerge.TimeSpent;
|
||||||
|
Description += "\r\n" + toMerge.Description;
|
||||||
|
Type |= toMerge.Type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,11 +59,10 @@ namespace JiraTimeBot.TaskTime
|
|||||||
var workTasks = _spreadHelper.SpreadTime(taskCommits, remainMinutes, settings.RoundToMinutes);
|
var workTasks = _spreadHelper.SpreadTime(taskCommits, remainMinutes, settings.RoundToMinutes);
|
||||||
foreach (var workTask in workTasks)
|
foreach (var workTask in workTasks)
|
||||||
{
|
{
|
||||||
var existingItem = workTimeItems.FirstOrDefault(f => f.Branch == workTask.Branch);
|
TaskTimeItem existingItem = workTimeItems.FirstOrDefault(f => f.Branch == workTask.Branch);
|
||||||
if (existingItem != null)
|
if (existingItem != null)
|
||||||
{
|
{
|
||||||
existingItem.TimeSpent += workTask.TimeSpent;
|
existingItem.MergeWith(workTask);
|
||||||
existingItem.Description += "\r\n" + workTask.Description;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +99,7 @@ namespace JiraTimeBot.TaskTime
|
|||||||
TimeSpan.FromMinutes(minutes),
|
TimeSpan.FromMinutes(minutes),
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
|
"",
|
||||||
CommitType.Task);
|
CommitType.Task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,20 +19,18 @@ namespace JiraTimeBot.TaskTime
|
|||||||
public List<TaskTimeItem> SpreadTime(List<TaskTimeItem> source, int minutes, int roundToMinutes, bool roundUp = false, bool appendTime = true)
|
public List<TaskTimeItem> SpreadTime(List<TaskTimeItem> source, int minutes, int roundToMinutes, bool roundUp = false, bool appendTime = true)
|
||||||
{
|
{
|
||||||
List<TaskTimeItem> newList = new List<TaskTimeItem>();
|
List<TaskTimeItem> newList = new List<TaskTimeItem>();
|
||||||
int remainMinutes = minutes;
|
|
||||||
|
|
||||||
//Нам нужно раскидать 480 минут в день.
|
//Нам нужно раскидать 480 минут в день.
|
||||||
foreach (var taskGroup in source.GroupBy(f => f.Branch).OrderByDescending(f => f.Count()))
|
foreach (var taskGroup in source.GroupBy(f => f.Branch).OrderByDescending(f => f.Count()))
|
||||||
{
|
{
|
||||||
int currentTaskCommits = taskGroup.Count();
|
int currentTaskCommits = taskGroup.Count();
|
||||||
int currentTaskTime = (int)RoundTo(minutes / source.Count * currentTaskCommits, roundToMinutes, roundUp);
|
int currentTaskTime = (int)RoundTo(minutes / source.Count * currentTaskCommits, roundToMinutes, roundUp);
|
||||||
remainMinutes = remainMinutes - currentTaskTime;
|
|
||||||
|
|
||||||
var orderedTasks = taskGroup.OrderBy(f => f.StartTime).ToArray();
|
var orderedTasks = taskGroup.OrderBy(f => f.StartTime).ToArray();
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
foreach (var task in orderedTasks)
|
foreach (var taskDescription in orderedTasks.Select(f=>f.Description).Distinct())
|
||||||
{
|
{
|
||||||
sb.AppendLine($"- {task.Description}");
|
sb.AppendLine($"- {taskDescription}");
|
||||||
}
|
}
|
||||||
|
|
||||||
var timeSpent = appendTime
|
var timeSpent = appendTime
|
||||||
@@ -48,6 +46,7 @@ namespace JiraTimeBot.TaskTime
|
|||||||
timeSpent,
|
timeSpent,
|
||||||
taskGroup.Sum(f => f.Commits),
|
taskGroup.Sum(f => f.Commits),
|
||||||
taskGroup.Sum(f => f.FilesAffected),
|
taskGroup.Sum(f => f.FilesAffected),
|
||||||
|
taskGroup.First().ReleaseVersion,
|
||||||
taskGroup.First().Type);
|
taskGroup.First().Type);
|
||||||
|
|
||||||
newList.Add(taskTimeItem);
|
newList.Add(taskTimeItem);
|
||||||
|
|||||||
@@ -21,15 +21,16 @@ namespace JiraTimeBot.TasksProcessors
|
|||||||
|
|
||||||
public void Process(DateTime setForDate, DateTime realDate, List<TaskTimeItem> taskTimes, Settings settings, bool dummyMode, CancellationToken cancellationToken = default(CancellationToken))
|
public void Process(DateTime setForDate, DateTime realDate, List<TaskTimeItem> taskTimes, Settings settings, bool dummyMode, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
{
|
{
|
||||||
_log.Trace($"На реальную дату {realDate:dd.MM.yyyy} распределение по задачам:");
|
var totalTime = TimeSpan.FromSeconds(taskTimes.Sum(f => f.TimeSpent.TotalSeconds));
|
||||||
|
_log.Trace($"На реальную дату {realDate:dd.MM.yyyy} распределение по задачам ({totalTime:hh':'mm':'ss}):");
|
||||||
|
|
||||||
foreach (var taskTime in taskTimes.Where(f=>f.Type == CommitType.Task).OrderByDescending(f => f.TimeSpent))
|
foreach (var taskTime in taskTimes.Where(f=>f.Type.HasFlag(CommitType.Task)).OrderByDescending(f => f.TimeSpent))
|
||||||
{
|
{
|
||||||
var taskName = _jiraApi.GetTaskName(taskTime.Branch, settings);
|
var taskName = _jiraApi.GetTaskName(taskTime.Branch, settings);
|
||||||
_log.Trace($" - [{taskTime.Branch}, коммитов {taskTime.Commits}]: {taskName} - {taskTime.TimeSpent}");
|
_log.Trace($" - [{taskTime.Branch}, коммитов {taskTime.Commits}]: {taskName} - {taskTime.TimeSpent}");
|
||||||
}
|
}
|
||||||
|
|
||||||
var releases = taskTimes.Where(f => f.Type == CommitType.Release).GroupBy(f=>f.Description);
|
var releases = taskTimes.Where(f => f.Type.HasFlag(CommitType.Release)).GroupBy(f=>f.Description);
|
||||||
foreach (var release in releases)
|
foreach (var release in releases)
|
||||||
{
|
{
|
||||||
var sum = release.Sum(f => (int) f.TimeSpent.TotalMinutes);
|
var sum = release.Sum(f => (int) f.TimeSpent.TotalMinutes);
|
||||||
|
|||||||
+15
-2
@@ -53,6 +53,7 @@
|
|||||||
this.txtWorkDayDuration = new System.Windows.Forms.TextBox();
|
this.txtWorkDayDuration = new System.Windows.Forms.TextBox();
|
||||||
this.label9 = new System.Windows.Forms.Label();
|
this.label9 = new System.Windows.Forms.Label();
|
||||||
this.txtRandomMinutes = new System.Windows.Forms.TextBox();
|
this.txtRandomMinutes = new System.Windows.Forms.TextBox();
|
||||||
|
this.chkPullBeforeProcess = new System.Windows.Forms.CheckBox();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// label5
|
// label5
|
||||||
@@ -168,7 +169,7 @@
|
|||||||
//
|
//
|
||||||
// btnSave
|
// btnSave
|
||||||
//
|
//
|
||||||
this.btnSave.Location = new System.Drawing.Point(86, 359);
|
this.btnSave.Location = new System.Drawing.Point(86, 382);
|
||||||
this.btnSave.Name = "btnSave";
|
this.btnSave.Name = "btnSave";
|
||||||
this.btnSave.Size = new System.Drawing.Size(75, 23);
|
this.btnSave.Size = new System.Drawing.Size(75, 23);
|
||||||
this.btnSave.TabIndex = 32;
|
this.btnSave.TabIndex = 32;
|
||||||
@@ -272,11 +273,22 @@
|
|||||||
this.txtRandomMinutes.Size = new System.Drawing.Size(99, 20);
|
this.txtRandomMinutes.Size = new System.Drawing.Size(99, 20);
|
||||||
this.txtRandomMinutes.TabIndex = 43;
|
this.txtRandomMinutes.TabIndex = 43;
|
||||||
//
|
//
|
||||||
|
// chkPullBeforeProcess
|
||||||
|
//
|
||||||
|
this.chkPullBeforeProcess.AutoSize = true;
|
||||||
|
this.chkPullBeforeProcess.Location = new System.Drawing.Point(65, 359);
|
||||||
|
this.chkPullBeforeProcess.Name = "chkPullBeforeProcess";
|
||||||
|
this.chkPullBeforeProcess.Size = new System.Drawing.Size(83, 17);
|
||||||
|
this.chkPullBeforeProcess.TabIndex = 45;
|
||||||
|
this.chkPullBeforeProcess.Text = "Делать pull";
|
||||||
|
this.chkPullBeforeProcess.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
// frmSettings
|
// frmSettings
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(243, 391);
|
this.ClientSize = new System.Drawing.Size(243, 414);
|
||||||
|
this.Controls.Add(this.chkPullBeforeProcess);
|
||||||
this.Controls.Add(this.label9);
|
this.Controls.Add(this.label9);
|
||||||
this.Controls.Add(this.txtRandomMinutes);
|
this.Controls.Add(this.txtRandomMinutes);
|
||||||
this.Controls.Add(this.lblWorkDay);
|
this.Controls.Add(this.lblWorkDay);
|
||||||
@@ -340,5 +352,6 @@
|
|||||||
private System.Windows.Forms.TextBox txtWorkDayDuration;
|
private System.Windows.Forms.TextBox txtWorkDayDuration;
|
||||||
private System.Windows.Forms.Label label9;
|
private System.Windows.Forms.Label label9;
|
||||||
private System.Windows.Forms.TextBox txtRandomMinutes;
|
private System.Windows.Forms.TextBox txtRandomMinutes;
|
||||||
|
private System.Windows.Forms.CheckBox chkPullBeforeProcess;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,7 @@ namespace JiraTimeBot.UI
|
|||||||
txtJQL.Text = settings.JiraQuery;
|
txtJQL.Text = settings.JiraQuery;
|
||||||
txtWorkDayDuration.Text = settings.MinuterPerWorkDay.ToString();
|
txtWorkDayDuration.Text = settings.MinuterPerWorkDay.ToString();
|
||||||
txtRandomMinutes.Text = settings.RandomWorkMinutes.ToString();
|
txtRandomMinutes.Text = settings.RandomWorkMinutes.ToString();
|
||||||
|
chkPullBeforeProcess.Checked = settings.PullBeforeProcess;
|
||||||
|
|
||||||
cboWorkType_SelectedIndexChanged(null, null);
|
cboWorkType_SelectedIndexChanged(null, null);
|
||||||
}
|
}
|
||||||
@@ -72,7 +73,8 @@ namespace JiraTimeBot.UI
|
|||||||
JiraQuery = txtJQL.Text,
|
JiraQuery = txtJQL.Text,
|
||||||
TimeControlTask = txtTimeControlTask.Text,
|
TimeControlTask = txtTimeControlTask.Text,
|
||||||
MinuterPerWorkDay = minuterPerWorkDay,
|
MinuterPerWorkDay = minuterPerWorkDay,
|
||||||
RandomWorkMinutes = randomWorkMinutes
|
RandomWorkMinutes = randomWorkMinutes,
|
||||||
|
PullBeforeProcess = chkPullBeforeProcess.Checked
|
||||||
};
|
};
|
||||||
|
|
||||||
//LockUnlock(false);
|
//LockUnlock(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user