Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e40f0a07c | ||
|
|
64723248a5 | ||
|
|
c97ab59b96 | ||
|
|
4e8fa0b801 | ||
|
|
61e53c3698 | ||
|
|
6f6f7c3424 | ||
|
|
364b23dbca | ||
|
|
c95f228ef0 | ||
|
|
72f9ccfd5e | ||
|
|
3e0b3960b5 | ||
|
|
38633352d9 | ||
|
|
5f75691668 | ||
|
|
087c4f1909 | ||
|
|
1b7b56f63d |
+1
-1
@@ -1 +1 @@
|
|||||||
1.0.56
|
1.0.66
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# JiraTimeBot [](https://ci.appveyor.com/project/Monster1025/JiraTimeBot)
|
# JiraTimeBot [](https://ci.appveyor.com/project/monster1025/jiratimebot/branch/master)
|
||||||
Приложение для автоматического добавления Jira Worklog'ов исходя из количества коммитов в ветку.
|
Приложение для автоматического добавления Jira Worklog'ов исходя из количества коммитов в ветку. Возможна работа по JQL-запросу JIRA.
|
||||||
|
|
||||||
# Ограничения
|
# Ограничения
|
||||||
- Предполагается что все Ваши репозитории находятся в одной папке (к которой вы указываете путь в настройках).
|
- Предполагается что все Ваши репозитории находятся в одной папке (к которой вы указываете путь в настройках).
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
- Время запуска - время автоматического запуска бота. Если была установлена галочка "тестовый прогон" - она будет снята.
|
- Время запуска - время автоматического запуска бота. Если была установлена галочка "тестовый прогон" - она будет снята.
|
||||||
- Минут в рабочем дне - количество распределяемых минут (оыбчно 8 * 60).
|
- Минут в рабочем дне - количество распределяемых минут (оыбчно 8 * 60).
|
||||||
- Рандомных минут - если > 0, то будет прибавлено рандомное количество минут к рабочему времени (но кратное значению округления).
|
- Рандомных минут - если > 0, то будет прибавлено рандомное количество минут к рабочему времени (но кратное значению округления).
|
||||||
- Добавлять описание (Режим Mercurial) - добавлять ли в описание CommitMessage, если не установлено - добавляются стандартные фразы программистов (типа "написание кода").
|
- Добавлять описание (Режим Mercurial) - добавлять ли в описание CommitMessage, если не установлено - описание не заполняются.
|
||||||
- Автозагрузка - загружать ли программу при старте ОС.
|
- Автозагрузка - загружать ли программу при старте ОС.
|
||||||
# Скачать
|
# Скачать
|
||||||
Скачать актуальную версию можно тут: https://github.com/monster1025/JiraTimeBot/releases/latest
|
Скачать актуальную версию можно тут: https://github.com/monster1025/JiraTimeBot/releases/latest
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,13 @@
|
|||||||
using JiraTimeBot.Configuration;
|
using JiraTimeBot.Configuration;
|
||||||
using JiraTimeBot.TaskTime.Objects;
|
using JiraTimeBot.TaskTime.Objects;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace JiraTimeBot.JiraIntegration.Comments
|
namespace JiraTimeBot.JiraIntegration.Comments
|
||||||
{
|
{
|
||||||
public class JiraDescriptionSource : IJiraDescriptionSource
|
public class JiraDescriptionSource : IJiraDescriptionSource
|
||||||
{
|
{
|
||||||
private readonly List<string> _dummyComments = new List<string>
|
|
||||||
{
|
|
||||||
"Написание кода", "написание кода", "программирование", "реализация задачи", "кодинг", "код + тесты",
|
|
||||||
"кодинг", "написание кода и тестов"
|
|
||||||
};
|
|
||||||
|
|
||||||
public string GetDescription(TaskTimeItem taskTimeItem, bool addCommentsToWorklog, Settings settings)
|
public string GetDescription(TaskTimeItem taskTimeItem, bool addCommentsToWorklog, Settings settings)
|
||||||
{
|
{
|
||||||
if (addCommentsToWorklog)
|
return addCommentsToWorklog ? taskTimeItem.Description : "";
|
||||||
{
|
|
||||||
return taskTimeItem.Description;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (settings.WorkType == WorkType.Mercurial)
|
|
||||||
{
|
|
||||||
return _dummyComments.OrderBy(f => Guid.NewGuid()).FirstOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
@@ -68,7 +76,7 @@ namespace JiraTimeBot.JiraIntegration
|
|||||||
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(CancellationToken))
|
||||||
{
|
{
|
||||||
var alreadyLoggedToday = GetWorkloggedIssuesByDate(settings, date);
|
var alreadyLoggedToday = GetWorkloggedIssuesByDate(settings, date);
|
||||||
foreach (var issue in alreadyLoggedToday)
|
foreach (var issue in alreadyLoggedToday)
|
||||||
@@ -107,9 +115,9 @@ namespace JiraTimeBot.JiraIntegration
|
|||||||
{
|
{
|
||||||
issue = jira.Issues.Queryable.FirstOrDefault(f => f.Key == taskTimeItem.Branch);
|
issue = jira.Issues.Queryable.FirstOrDefault(f => f.Key == taskTimeItem.Branch);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
_log.Error($"Ошибка получения задачи из JIRA: {ex.Message} - {ex.InnerException?.Message}");
|
||||||
}
|
}
|
||||||
if (issue == null)
|
if (issue == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,28 +46,30 @@ 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),
|
issue.Project,
|
||||||
Description = issue.Summary,
|
issue.Updated.GetValueOrDefault(date.Value),
|
||||||
Branch = issue.Key.Value,
|
TimeSpan.Zero,
|
||||||
FilesAffected = 1,
|
1,
|
||||||
Commits = 1,
|
1,
|
||||||
Type = CommitType.Task
|
"",
|
||||||
});
|
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),
|
issue.Project,
|
||||||
Description = issue.Summary,
|
issue.Updated.GetValueOrDefault(date.Value),
|
||||||
Branch = issue.Key.Value,
|
TimeSpan.Zero,
|
||||||
FilesAffected = 1,
|
1,
|
||||||
Commits = 1,
|
1,
|
||||||
Type = CommitType.Task
|
"",
|
||||||
});
|
CommitType.Task);
|
||||||
|
workTasks.Add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
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(CancellationToken));
|
||||||
|
}
|
||||||
|
|
||||||
|
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(CancellationToken))
|
||||||
|
{
|
||||||
|
var tasks = _jiraApi.GetIssuesByJQL("status changed by '%USER%' during (\"%DATE%\",\"%DATE%\")", settings, date, cancellationToken);
|
||||||
|
List<TaskTimeItem> resultItems = new List<TaskTimeItem>();
|
||||||
|
foreach (var issue in tasks)
|
||||||
|
{
|
||||||
|
var workLogs = issue.GetWorklogsAsync(cancellationToken).Result;
|
||||||
|
var user = settings.JiraUserName;
|
||||||
|
//user = "Zoya.Aleksandridi";
|
||||||
|
var userWorklogs = workLogs.Where(w =>
|
||||||
|
w.CreateDate.GetValueOrDefault().Date == date && w.Author.Equals(user,
|
||||||
|
StringComparison.InvariantCultureIgnoreCase)).ToList();
|
||||||
|
if (!userWorklogs.Any())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstWorklog = userWorklogs.First();
|
||||||
|
|
||||||
|
var description = string.Join("\r\n", 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'));
|
||||||
|
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" />
|
||||||
@@ -92,6 +94,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>
|
||||||
|
|||||||
+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 = null;
|
||||||
|
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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ namespace JiraTimeBot.Mercurial
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var directoryInfo = new DirectoryInfo(repoDirectory);
|
||||||
|
|
||||||
var repo = new Repository(repoDirectory);
|
var repo = new Repository(repoDirectory);
|
||||||
var logCommand = new LogCommand
|
var logCommand = new LogCommand
|
||||||
{
|
{
|
||||||
@@ -72,23 +74,29 @@ 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,
|
directoryInfo.Name,
|
||||||
Description = commitMessage,
|
changeset.Timestamp,
|
||||||
Branch = changeset.Branch,
|
TimeSpan.Zero,
|
||||||
FilesAffected = changeset.PathActions.Count,
|
1,
|
||||||
Commits = 1,
|
changeset.PathActions.Count,
|
||||||
TimeSpent = TimeSpan.Zero,
|
"",
|
||||||
Type = 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))
|
||||||
{
|
{
|
||||||
var branch = task.Description.Replace("Merge with", "").Replace(" ", "");
|
var description = task.Description;
|
||||||
|
if (description.Contains("\n"))
|
||||||
|
{
|
||||||
|
description = description.Split('\n')[0];
|
||||||
|
}
|
||||||
|
var branch = description.Replace("Merge with", "").Replace(" ", "");
|
||||||
var release = task.Branch.Replace("release", "");
|
var release = task.Branch.Replace("release", "");
|
||||||
|
|
||||||
task.Branch = branch;
|
task.Branch = branch;
|
||||||
task.Description = $"Подготовка и публикация версии {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.56")]
|
[assembly: AssemblyVersion("1.0.66")]
|
||||||
[assembly: AssemblyFileVersion("1.0.56")]
|
[assembly: AssemblyFileVersion("1.0.66")]
|
||||||
[assembly: AssemblyInformationalVersion("1.0.56")]
|
[assembly: AssemblyInformationalVersion("1.0.66")]
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace JiraTimeBot.TaskTime.Objects
|
||||||
|
{
|
||||||
|
[Flags]
|
||||||
|
public enum CommitType {
|
||||||
|
Task = 1,
|
||||||
|
Release = 2
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,10 +11,29 @@ 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 string Project { get; set; }
|
||||||
|
public string ReleaseVersion { get; set; }
|
||||||
|
|
||||||
public enum CommitType {
|
public TaskTimeItem(string branch, string description, string project, DateTime startTime, TimeSpan timeSpent, int commits,
|
||||||
Task = 0,
|
int filesAffected = 1, string releaseVersion = "", CommitType type = CommitType.Task)
|
||||||
Release = 1
|
{
|
||||||
|
Branch = branch;
|
||||||
|
Description = description;
|
||||||
|
Project = project;
|
||||||
|
Commits = commits;
|
||||||
|
TimeSpent = timeSpent;
|
||||||
|
StartTime = startTime;
|
||||||
|
FilesAffected = filesAffected;
|
||||||
|
ReleaseVersion = releaseVersion;
|
||||||
|
Type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MergeWith(TaskTimeItem toMerge)
|
||||||
|
{
|
||||||
|
Commits += toMerge.Commits;
|
||||||
|
TimeSpent += toMerge.TimeSpent;
|
||||||
|
Description += "\r\n" + toMerge.Description;
|
||||||
|
Type |= toMerge.Type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,17 @@ namespace JiraTimeBot.TaskTime
|
|||||||
}
|
}
|
||||||
|
|
||||||
var workTasks = _spreadHelper.SpreadTime(taskCommits, remainMinutes, settings.RoundToMinutes);
|
var workTasks = _spreadHelper.SpreadTime(taskCommits, remainMinutes, settings.RoundToMinutes);
|
||||||
workTimeItems.AddRange(workTasks);
|
foreach (var workTask in workTasks)
|
||||||
|
{
|
||||||
|
TaskTimeItem existingItem = workTimeItems.FirstOrDefault(f => f.Branch == workTask.Branch);
|
||||||
|
if (existingItem != null)
|
||||||
|
{
|
||||||
|
existingItem.MergeWith(workTask);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
workTimeItems.Add(workTask);
|
||||||
|
}
|
||||||
workTimeItems = workTimeItems.OrderByDescending(f => f.TimeSpent).ToList();
|
workTimeItems = workTimeItems.OrderByDescending(f => f.TimeSpent).ToList();
|
||||||
|
|
||||||
remainMinutes = minutesPerWorkDay - (int) workTimeItems.Sum(f => f.TimeSpent.TotalMinutes);
|
remainMinutes = minutesPerWorkDay - (int) workTimeItems.Sum(f => f.TimeSpent.TotalMinutes);
|
||||||
@@ -82,19 +92,21 @@ namespace JiraTimeBot.TaskTime
|
|||||||
//Если указана задача контроля времени - то спишем туда 30 минут и вычеркнем их из общего рабочего времени.
|
//Если указана задача контроля времени - то спишем туда 30 минут и вычеркнем их из общего рабочего времени.
|
||||||
if (!string.IsNullOrEmpty(timeControlTask))
|
if (!string.IsNullOrEmpty(timeControlTask))
|
||||||
{
|
{
|
||||||
return new TaskTimeItem
|
return new TaskTimeItem(timeControlTask,
|
||||||
{
|
"Ведение учета времени",
|
||||||
TimeSpent = TimeSpan.FromMinutes(minutes),
|
"Service",
|
||||||
Branch = timeControlTask,
|
DateTime.Now,
|
||||||
Commits = 1,
|
TimeSpan.FromMinutes(minutes),
|
||||||
Description = "Ведение учета времени"
|
1,
|
||||||
};
|
1,
|
||||||
|
"",
|
||||||
|
CommitType.Task);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixTooBigInterval(Settings settings, int totalCommitsCount, int workHours)
|
private void FixTooBigInterval(Settings settings, int workHours, int totalCommitsCount)
|
||||||
{
|
{
|
||||||
//если кол-во коммитов более чем кол-во интервалов - то уменьшим интервал вдвое.
|
//если кол-во коммитов более чем кол-во интервалов - то уменьшим интервал вдвое.
|
||||||
while (totalCommitsCount > (workHours * (60.0 / settings.RoundToMinutes)))
|
while (totalCommitsCount > (workHours * (60.0 / settings.RoundToMinutes)))
|
||||||
|
|||||||
@@ -19,34 +19,35 @@ 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 taskTimeItem = new TaskTimeItem
|
|
||||||
{
|
var timeSpent = appendTime
|
||||||
Branch = taskGroup.Key,
|
? TimeSpan.FromMinutes(taskGroup.Sum(f => f.TimeSpent.TotalMinutes)) +
|
||||||
TimeSpent = appendTime ?
|
TimeSpan.FromMinutes(currentTaskTime)
|
||||||
TimeSpan.FromMinutes(taskGroup.Sum(f=>f.TimeSpent.TotalMinutes)) + TimeSpan.FromMinutes(currentTaskTime):
|
: TimeSpan.FromMinutes(currentTaskTime);
|
||||||
TimeSpan.FromMinutes(currentTaskTime)
|
|
||||||
,
|
var taskTimeItem = new TaskTimeItem(
|
||||||
Commits = taskGroup.Sum(f=>f.Commits),
|
taskGroup.Key,
|
||||||
Description = sb.ToString(),
|
sb.ToString(),
|
||||||
StartTime = taskGroup.Min(f=>f.StartTime),
|
taskGroup.First().Project,
|
||||||
FilesAffected = taskGroup.Sum(f=>f.FilesAffected),
|
taskGroup.Min(f => f.StartTime),
|
||||||
Type = taskGroup.First().Type
|
timeSpent,
|
||||||
};
|
taskGroup.Sum(f => f.Commits),
|
||||||
|
taskGroup.Sum(f => f.FilesAffected),
|
||||||
|
taskGroup.First().ReleaseVersion,
|
||||||
|
taskGroup.First().Type);
|
||||||
|
|
||||||
newList.Add(taskTimeItem);
|
newList.Add(taskTimeItem);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ namespace JiraTimeBot.TasksProcessors
|
|||||||
{
|
{
|
||||||
_log.Trace($"На реальную дату {realDate:dd.MM.yyyy} распределение по задачам:");
|
_log.Trace($"На реальную дату {realDate:dd.MM.yyyy} распределение по задачам:");
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user