mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
feature<Statistics>: add statistics for current year
This commit is contained in:
parent
90eaf484fb
commit
1ad5ff1bd8
7 changed files with 185 additions and 163 deletions
|
@ -3,6 +3,10 @@
|
||||||
/// 统计图表样品
|
/// 统计图表样品
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class StatisticSample {
|
public class StatisticSample {
|
||||||
|
/// <summary>
|
||||||
|
/// 在图表中的顺序
|
||||||
|
/// </summary>
|
||||||
|
public int Index { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 样品名
|
/// 样品名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -491,6 +491,7 @@
|
||||||
<sys:String x:Key="Text.Statistics">Statistics</sys:String>
|
<sys:String x:Key="Text.Statistics">Statistics</sys:String>
|
||||||
<sys:String x:Key="Text.Statistics.ThisWeek">WEEK</sys:String>
|
<sys:String x:Key="Text.Statistics.ThisWeek">WEEK</sys:String>
|
||||||
<sys:String x:Key="Text.Statistics.ThisMonth">MONTH</sys:String>
|
<sys:String x:Key="Text.Statistics.ThisMonth">MONTH</sys:String>
|
||||||
|
<sys:String x:Key="Text.Statistics.ThisYear">YEAR</sys:String>
|
||||||
<sys:String x:Key="Text.Statistics.TotalCommitterCount">Total Committers: {0}</sys:String>
|
<sys:String x:Key="Text.Statistics.TotalCommitterCount">Total Committers: {0}</sys:String>
|
||||||
<sys:String x:Key="Text.Statistics.TotalCommitsCount">Total Commits:{0}</sys:String>
|
<sys:String x:Key="Text.Statistics.TotalCommitsCount">Total Commits:{0}</sys:String>
|
||||||
<sys:String x:Key="Text.Statistics.CommitterName">COMMITTER</sys:String>
|
<sys:String x:Key="Text.Statistics.CommitterName">COMMITTER</sys:String>
|
||||||
|
@ -504,6 +505,19 @@
|
||||||
<sys:String x:Key="Text.Weekday.5">FRI</sys:String>
|
<sys:String x:Key="Text.Weekday.5">FRI</sys:String>
|
||||||
<sys:String x:Key="Text.Weekday.6">SAT</sys:String>
|
<sys:String x:Key="Text.Weekday.6">SAT</sys:String>
|
||||||
|
|
||||||
|
<sys:String x:Key="Text.Month.1">Jan</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.2">Feb</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.3">Mar</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.4">Apr</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.5">May</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.6">Jun</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.7">Jul</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.8">Aug</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.9">Sep</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.10">Oct</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.11">Nov</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.12">Dec</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.NotConfigured">Git has NOT been configured. Please to go [Preference] and configure it first.</sys:String>
|
<sys:String x:Key="Text.NotConfigured">Git has NOT been configured. Please to go [Preference] and configure it first.</sys:String>
|
||||||
<sys:String x:Key="Text.PathNotFound">Path[{0}] not exists!</sys:String>
|
<sys:String x:Key="Text.PathNotFound">Path[{0}] not exists!</sys:String>
|
||||||
<sys:String x:Key="Text.MissingBash">Can NOT locate bash.exe. Make sure bash.exe exists under the same folder with git.exe</sys:String>
|
<sys:String x:Key="Text.MissingBash">Can NOT locate bash.exe. Make sure bash.exe exists under the same folder with git.exe</sys:String>
|
||||||
|
|
|
@ -490,6 +490,7 @@
|
||||||
<sys:String x:Key="Text.Statistics">提交统计</sys:String>
|
<sys:String x:Key="Text.Statistics">提交统计</sys:String>
|
||||||
<sys:String x:Key="Text.Statistics.ThisWeek">本周</sys:String>
|
<sys:String x:Key="Text.Statistics.ThisWeek">本周</sys:String>
|
||||||
<sys:String x:Key="Text.Statistics.ThisMonth">本月</sys:String>
|
<sys:String x:Key="Text.Statistics.ThisMonth">本月</sys:String>
|
||||||
|
<sys:String x:Key="Text.Statistics.ThisYear">本年</sys:String>
|
||||||
<sys:String x:Key="Text.Statistics.TotalCommitterCount">提交者人数:{0}</sys:String>
|
<sys:String x:Key="Text.Statistics.TotalCommitterCount">提交者人数:{0}</sys:String>
|
||||||
<sys:String x:Key="Text.Statistics.TotalCommitsCount">总计提交次数:{0}</sys:String>
|
<sys:String x:Key="Text.Statistics.TotalCommitsCount">总计提交次数:{0}</sys:String>
|
||||||
<sys:String x:Key="Text.Statistics.CommitterName">提交者</sys:String>
|
<sys:String x:Key="Text.Statistics.CommitterName">提交者</sys:String>
|
||||||
|
@ -503,6 +504,19 @@
|
||||||
<sys:String x:Key="Text.Weekday.5">星期五</sys:String>
|
<sys:String x:Key="Text.Weekday.5">星期五</sys:String>
|
||||||
<sys:String x:Key="Text.Weekday.6">星期六</sys:String>
|
<sys:String x:Key="Text.Weekday.6">星期六</sys:String>
|
||||||
|
|
||||||
|
<sys:String x:Key="Text.Month.1">1月</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.2">2月</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.3">3月</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.4">4月</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.5">5月</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.6">6月</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.7">7月</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.8">8月</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.9">9月</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.10">10月</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.11">11月</sys:String>
|
||||||
|
<sys:String x:Key="Text.Month.12">12月</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.NotConfigured">GIT尚未配置。请打开【偏好设置】配置GIT路径。</sys:String>
|
<sys:String x:Key="Text.NotConfigured">GIT尚未配置。请打开【偏好设置】配置GIT路径。</sys:String>
|
||||||
<sys:String x:Key="Text.PathNotFound">路径({0})不存在或不可读取!</sys:String>
|
<sys:String x:Key="Text.PathNotFound">路径({0})不存在或不可读取!</sys:String>
|
||||||
<sys:String x:Key="Text.MissingBash">无法找到bash.exe,请确保其在git.exe同目录中!</sys:String>
|
<sys:String x:Key="Text.MissingBash">无法找到bash.exe,请确保其在git.exe同目录中!</sys:String>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||||
|
xmlns:widgets="clr-namespace:SourceGit.Views.Widgets"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Statistics"
|
Title="Statistics"
|
||||||
Height="450" Width="600"
|
Height="450" Width="600"
|
||||||
|
@ -50,142 +51,13 @@
|
||||||
Margin="8"
|
Margin="8"
|
||||||
Style="{DynamicResource Style.TabControl.MiddleSwitch}">
|
Style="{DynamicResource Style.TabControl.MiddleSwitch}">
|
||||||
<TabItem Header="{DynamicResource Text.Statistics.ThisWeek}">
|
<TabItem Header="{DynamicResource Text.Statistics.ThisWeek}">
|
||||||
<Grid>
|
<widgets:StatisticsPage x:Name="pageWeek"/>
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="32"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
<ColumnDefinition Width="8"/>
|
|
||||||
<ColumnDefinition Width="2*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
|
|
||||||
<DataGrid
|
|
||||||
x:Name="lstCommitterWeek"
|
|
||||||
Grid.Row="0" Grid.Column="0"
|
|
||||||
Margin="0,8,0,0"
|
|
||||||
Background="{DynamicResource Brush.Contents}"
|
|
||||||
GridLinesVisibility="All"
|
|
||||||
HorizontalGridLinesBrush="{DynamicResource Brush.Border0}"
|
|
||||||
VerticalGridLinesBrush="{DynamicResource Brush.Border0}"
|
|
||||||
VerticalScrollBarVisibility="Auto"
|
|
||||||
HorizontalScrollBarVisibility="Disabled"
|
|
||||||
HeadersVisibility="Column"
|
|
||||||
RowHeight="24"
|
|
||||||
ColumnHeaderHeight="24"
|
|
||||||
CanUserAddRows="False"
|
|
||||||
CanUserDeleteRows="False"
|
|
||||||
CanUserResizeColumns="False"
|
|
||||||
CanUserResizeRows="False"
|
|
||||||
CanUserReorderColumns="False"
|
|
||||||
BorderThickness="1"
|
|
||||||
BorderBrush="{DynamicResource Brush.Border0}">
|
|
||||||
<DataGrid.ColumnHeaderStyle>
|
|
||||||
<Style TargetType="{x:Type DataGridColumnHeader}">
|
|
||||||
<Setter Property="Template">
|
|
||||||
<Setter.Value>
|
|
||||||
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
|
|
||||||
<Border BorderThickness="0,0,1,1" BorderBrush="{DynamicResource Brush.Border0}" Background="{DynamicResource Brush.Window}">
|
|
||||||
<TextBlock
|
|
||||||
Text="{TemplateBinding Content}"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
FontWeight="DemiBold"/>
|
|
||||||
</Border>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
</Style>
|
|
||||||
</DataGrid.ColumnHeaderStyle>
|
|
||||||
|
|
||||||
<DataGrid.Columns>
|
|
||||||
<DataGridTextColumn Width="*" Header="{DynamicResource Text.Statistics.CommitterName}" IsReadOnly="True" Binding="{Binding .Name}" ElementStyle="{StaticResource Style.TextBlock.LineContent}"/>
|
|
||||||
<DataGridTextColumn Width="*" Header="{DynamicResource Text.Statistics.CommitAmount}" IsReadOnly="True" Binding="{Binding .Count}" ElementStyle="{StaticResource Style.TextBlock.LineContent}"/>
|
|
||||||
</DataGrid.Columns>
|
|
||||||
</DataGrid>
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="1" Grid.Column="0" x:Name="txtMemberCountWeek" Text="Total Committers: -"/>
|
|
||||||
|
|
||||||
<controls:Chart
|
|
||||||
Grid.Row="0"
|
|
||||||
Grid.Column="2"
|
|
||||||
Margin="8,16,0,0"
|
|
||||||
x:Name="chartWeek"
|
|
||||||
LineBrush="{DynamicResource Brush.FG1}"
|
|
||||||
ChartBrush="{DynamicResource Brush.Accent1}"/>
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="1" Grid.Column="2" x:Name="txtCommitCountWeek" HorizontalAlignment="Right" Text="Total Commits: -"/>
|
|
||||||
</Grid>
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="{DynamicResource Text.Statistics.ThisMonth}">
|
<TabItem Header="{DynamicResource Text.Statistics.ThisMonth}">
|
||||||
<Grid>
|
<widgets:StatisticsPage x:Name="pageMonth"/>
|
||||||
<Grid.RowDefinitions>
|
</TabItem>
|
||||||
<RowDefinition Height="*"/>
|
<TabItem Header="{DynamicResource Text.Statistics.ThisYear}">
|
||||||
<RowDefinition Height="32"/>
|
<widgets:StatisticsPage x:Name="pageYear"/>
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
<ColumnDefinition Width="8"/>
|
|
||||||
<ColumnDefinition Width="2*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
|
|
||||||
<DataGrid
|
|
||||||
x:Name="lstCommitterMonth"
|
|
||||||
Grid.Row="0" Grid.Column="0"
|
|
||||||
Margin="0,8,0,0"
|
|
||||||
Background="{DynamicResource Brush.Contents}"
|
|
||||||
GridLinesVisibility="All"
|
|
||||||
HorizontalGridLinesBrush="{DynamicResource Brush.Border0}"
|
|
||||||
VerticalGridLinesBrush="{DynamicResource Brush.Border0}"
|
|
||||||
VerticalScrollBarVisibility="Auto"
|
|
||||||
HorizontalScrollBarVisibility="Disabled"
|
|
||||||
HeadersVisibility="Column"
|
|
||||||
RowHeight="24"
|
|
||||||
ColumnHeaderHeight="24"
|
|
||||||
CanUserAddRows="False"
|
|
||||||
CanUserDeleteRows="False"
|
|
||||||
CanUserResizeColumns="False"
|
|
||||||
CanUserResizeRows="False"
|
|
||||||
CanUserReorderColumns="False"
|
|
||||||
BorderThickness="1"
|
|
||||||
BorderBrush="{DynamicResource Brush.Border0}">
|
|
||||||
<DataGrid.ColumnHeaderStyle>
|
|
||||||
<Style TargetType="{x:Type DataGridColumnHeader}">
|
|
||||||
<Setter Property="Template">
|
|
||||||
<Setter.Value>
|
|
||||||
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
|
|
||||||
<Border BorderThickness="0,0,1,1" BorderBrush="{DynamicResource Brush.Border0}" Background="{DynamicResource Brush.Window}">
|
|
||||||
<TextBlock
|
|
||||||
Text="{TemplateBinding Content}"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
FontWeight="DemiBold"/>
|
|
||||||
</Border>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
</Style>
|
|
||||||
</DataGrid.ColumnHeaderStyle>
|
|
||||||
|
|
||||||
<DataGrid.Columns>
|
|
||||||
<DataGridTextColumn Width="*" Header="{DynamicResource Text.Statistics.CommitterName}" IsReadOnly="True" Binding="{Binding .Name}" ElementStyle="{StaticResource Style.TextBlock.LineContent}"/>
|
|
||||||
<DataGridTextColumn Width="*" Header="{DynamicResource Text.Statistics.CommitAmount}" IsReadOnly="True" Binding="{Binding .Count}" ElementStyle="{StaticResource Style.TextBlock.LineContent}"/>
|
|
||||||
</DataGrid.Columns>
|
|
||||||
</DataGrid>
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="1" Grid.Column="0" x:Name="txtMemberCountMonth" Text="Total Committers: -"/>
|
|
||||||
|
|
||||||
<controls:Chart
|
|
||||||
Grid.Row="0"
|
|
||||||
Grid.Column="2"
|
|
||||||
Margin="8,16,0,0"
|
|
||||||
x:Name="chartMonth"
|
|
||||||
LineBrush="{DynamicResource Brush.FG1}"
|
|
||||||
ChartBrush="{DynamicResource Brush.Accent1}"/>
|
|
||||||
|
|
||||||
<TextBlock Grid.Row="1" Grid.Column="2" x:Name="txtCommitCountMonth" HorizontalAlignment="Right" Text="Total Commits: -"/>
|
|
||||||
</Grid>
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</TabControl>
|
</TabControl>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ namespace SourceGit.Views {
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
mapsWeek.Add(i, new Models.StatisticSample {
|
mapsWeek.Add(i, new Models.StatisticSample {
|
||||||
Name = App.Text($"Weekday.{i}"),
|
Name = App.Text($"Weekday.{i}"),
|
||||||
|
Index = i,
|
||||||
Count = 0,
|
Count = 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -35,23 +37,39 @@ namespace SourceGit.Views {
|
||||||
for (int i = 1; i <= maxDays; i++) {
|
for (int i = 1; i <= maxDays; i++) {
|
||||||
mapsMonth.Add(i, new Models.StatisticSample {
|
mapsMonth.Add(i, new Models.StatisticSample {
|
||||||
Name = $"{i}",
|
Name = $"{i}",
|
||||||
|
Index = i,
|
||||||
|
Count = 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var mapsYear = new Dictionary<int, Models.StatisticSample>();
|
||||||
|
for (int i = 1; i <= 12; i++) {
|
||||||
|
mapsYear.Add(i, new Models.StatisticSample {
|
||||||
|
Name = App.Text($"Month.{i}"),
|
||||||
|
Index = i,
|
||||||
Count = 0,
|
Count = 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var mapCommitterWeek = new Dictionary<string, Models.StatisticSample>();
|
var mapCommitterWeek = new Dictionary<string, Models.StatisticSample>();
|
||||||
var mapCommitterMonth = new Dictionary<string, Models.StatisticSample>();
|
var mapCommitterMonth = new Dictionary<string, Models.StatisticSample>();
|
||||||
|
var mapCommitterYear = new Dictionary<string, Models.StatisticSample>();
|
||||||
|
|
||||||
var weekStart = today.AddSeconds(-(int)today.DayOfWeek * 3600 * 24 - today.Hour * 3600 - today.Minute * 60 - today.Second);
|
var weekStart = today.AddSeconds(-(int)today.DayOfWeek * 3600 * 24 - today.Hour * 3600 - today.Minute * 60 - today.Second);
|
||||||
var weekEnd = weekStart.AddDays(7);
|
var weekEnd = weekStart.AddDays(7);
|
||||||
|
var month = today.Month;
|
||||||
|
|
||||||
var limits = $"--branches --remotes --since=\"{today.ToString("yyyy-MM-01 00:00:00")}\"";
|
var limits = $"--branches --remotes --since=\"{today.ToString("yyyy-01-01 00:00:00")}\"";
|
||||||
var commits = new Commands.Commits(repo, limits).Result();
|
var commits = new Commands.Commits(repo, limits).Result();
|
||||||
var totalCommitsMonth = commits.Count;
|
|
||||||
var totalCommitsWeek = 0;
|
var totalCommitsWeek = 0;
|
||||||
|
var totalCommitsMonth = 0;
|
||||||
|
var totalCommitsYear = commits.Count;
|
||||||
foreach (var c in commits) {
|
foreach (var c in commits) {
|
||||||
var commitTime = DateTime.Parse(c.Committer.Time);
|
var commitTime = DateTime.Parse(c.Committer.Time);
|
||||||
if (commitTime.CompareTo(weekStart) >= 0 && commitTime.CompareTo(weekEnd) < 0) {
|
if (commitTime.CompareTo(weekStart) >= 0 && commitTime.CompareTo(weekEnd) < 0) {
|
||||||
mapsWeek[(int)commitTime.DayOfWeek].Count++;
|
mapsWeek[(int)commitTime.DayOfWeek].Count++;
|
||||||
|
totalCommitsWeek++;
|
||||||
|
|
||||||
if (mapCommitterWeek.ContainsKey(c.Committer.Name)) {
|
if (mapCommitterWeek.ContainsKey(c.Committer.Name)) {
|
||||||
mapCommitterWeek[c.Committer.Name].Count++;
|
mapCommitterWeek[c.Committer.Name].Count++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -60,11 +78,11 @@ namespace SourceGit.Views {
|
||||||
Count = 1,
|
Count = 1,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
totalCommitsWeek++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (commitTime.Month == month) {
|
||||||
mapsMonth[commitTime.Day].Count++;
|
mapsMonth[commitTime.Day].Count++;
|
||||||
|
totalCommitsMonth++;
|
||||||
|
|
||||||
if (mapCommitterMonth.ContainsKey(c.Committer.Name)) {
|
if (mapCommitterMonth.ContainsKey(c.Committer.Name)) {
|
||||||
mapCommitterMonth[c.Committer.Name].Count++;
|
mapCommitterMonth[c.Committer.Name].Count++;
|
||||||
|
@ -76,37 +94,39 @@ namespace SourceGit.Views {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var samplesChartWeek = new List<Models.StatisticSample>();
|
mapsYear[commitTime.Month].Count++;
|
||||||
var samplesChartMonth = new List<Models.StatisticSample>();
|
if (mapCommitterYear.ContainsKey(c.Committer.Name)) {
|
||||||
var samplesCommittersWeek = new List<Models.StatisticSample>();
|
mapCommitterYear[c.Committer.Name].Count++;
|
||||||
var samplesCommittersMonth = new List<Models.StatisticSample>();
|
} else {
|
||||||
for (int i = 0; i < 7; i++) samplesChartWeek.Add(mapsWeek[i]);
|
mapCommitterYear[c.Committer.Name] = new Models.StatisticSample {
|
||||||
for (int i = 1; i <= maxDays; i++) samplesChartMonth.Add(mapsMonth[i]);
|
Name = c.Committer.Name,
|
||||||
foreach (var kv in mapCommitterWeek) samplesCommittersWeek.Add(kv.Value);
|
Count = 1,
|
||||||
foreach (var kv in mapCommitterMonth) samplesCommittersMonth.Add(kv.Value);
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetPage(pageWeek, mapCommitterWeek.Values.ToList(), mapsWeek.Values.ToList(), totalCommitsWeek);
|
||||||
|
SetPage(pageMonth, mapCommitterMonth.Values.ToList(), mapsMonth.Values.ToList(), totalCommitsMonth);
|
||||||
|
SetPage(pageYear, mapCommitterYear.Values.ToList(), mapsYear.Values.ToList(), totalCommitsYear);
|
||||||
|
|
||||||
mapsMonth.Clear();
|
mapsMonth.Clear();
|
||||||
mapsWeek.Clear();
|
mapsWeek.Clear();
|
||||||
|
mapsYear.Clear();
|
||||||
mapCommitterMonth.Clear();
|
mapCommitterMonth.Clear();
|
||||||
mapCommitterWeek.Clear();
|
mapCommitterWeek.Clear();
|
||||||
|
mapCommitterYear.Clear();
|
||||||
commits.Clear();
|
commits.Clear();
|
||||||
samplesCommittersWeek.Sort((x, y) => y.Count - x.Count);
|
|
||||||
samplesCommittersMonth.Sort((x, y) => y.Count - x.Count);
|
|
||||||
|
|
||||||
Dispatcher.Invoke(() => {
|
Dispatcher.Invoke(() => {
|
||||||
loading.IsAnimating = false;
|
loading.IsAnimating = false;
|
||||||
loading.Visibility = Visibility.Collapsed;
|
loading.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
chartWeek.SetData(samplesChartWeek);
|
|
||||||
chartMonth.SetData(samplesChartMonth);
|
|
||||||
|
|
||||||
lstCommitterWeek.ItemsSource = samplesCommittersWeek;
|
|
||||||
lstCommitterMonth.ItemsSource = samplesCommittersMonth;
|
|
||||||
|
|
||||||
txtMemberCountWeek.Text = App.Text("Statistics.TotalCommitterCount", samplesCommittersWeek.Count);
|
|
||||||
txtMemberCountMonth.Text = App.Text("Statistics.TotalCommitterCount", samplesCommittersMonth.Count);
|
|
||||||
txtCommitCountWeek.Text = App.Text("Statistics.TotalCommitsCount", totalCommitsWeek);
|
|
||||||
txtCommitCountMonth.Text = App.Text("Statistics.TotalCommitsCount", totalCommitsMonth);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetPage(Widgets.StatisticsPage page, List<Models.StatisticSample> committers, List<Models.StatisticSample> commits, int total) {
|
||||||
|
committers.Sort((x, y) => y.Count - x.Count);
|
||||||
|
commits.Sort((x, y) => x.Index - y.Index);
|
||||||
|
page.SetData(committers, commits, total);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
74
src/Views/Widgets/StatisticsPage.xaml
Normal file
74
src/Views/Widgets/StatisticsPage.xaml
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
<UserControl x:Class="SourceGit.Views.Widgets.StatisticsPage"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
|
<Grid>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="32"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="8"/>
|
||||||
|
<ColumnDefinition Width="2*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<DataGrid
|
||||||
|
x:Name="lstCommitters"
|
||||||
|
Grid.Row="0" Grid.Column="0"
|
||||||
|
Margin="0,8,0,0"
|
||||||
|
Background="{DynamicResource Brush.Contents}"
|
||||||
|
GridLinesVisibility="All"
|
||||||
|
HorizontalGridLinesBrush="{DynamicResource Brush.Border0}"
|
||||||
|
VerticalGridLinesBrush="{DynamicResource Brush.Border0}"
|
||||||
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
HorizontalScrollBarVisibility="Disabled"
|
||||||
|
HeadersVisibility="Column"
|
||||||
|
RowHeight="24"
|
||||||
|
ColumnHeaderHeight="24"
|
||||||
|
CanUserAddRows="False"
|
||||||
|
CanUserDeleteRows="False"
|
||||||
|
CanUserResizeColumns="False"
|
||||||
|
CanUserResizeRows="False"
|
||||||
|
CanUserReorderColumns="False"
|
||||||
|
BorderThickness="1"
|
||||||
|
BorderBrush="{DynamicResource Brush.Border0}">
|
||||||
|
<DataGrid.ColumnHeaderStyle>
|
||||||
|
<Style TargetType="{x:Type DataGridColumnHeader}">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
|
||||||
|
<Border BorderThickness="0,0,1,1" BorderBrush="{DynamicResource Brush.Border0}" Background="{DynamicResource Brush.Window}">
|
||||||
|
<TextBlock Text="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="DemiBold"/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.ColumnHeaderStyle>
|
||||||
|
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Width="*" Header="{DynamicResource Text.Statistics.CommitterName}" IsReadOnly="True" Binding="{Binding .Name}" ElementStyle="{StaticResource Style.TextBlock.LineContent}"/>
|
||||||
|
<DataGridTextColumn Width="*" Header="{DynamicResource Text.Statistics.CommitAmount}" IsReadOnly="True" Binding="{Binding .Count}" ElementStyle="{StaticResource Style.TextBlock.LineContent}"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="0" x:Name="txtMemberCount" Text="Total Committers: -"/>
|
||||||
|
|
||||||
|
<controls:Chart
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="2"
|
||||||
|
Margin="8,16,0,0"
|
||||||
|
x:Name="chartCommits"
|
||||||
|
LineBrush="{DynamicResource Brush.FG1}"
|
||||||
|
ChartBrush="{DynamicResource Brush.Accent1}"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="2" x:Name="txtCommitCount" HorizontalAlignment="Right" Text="Total Commits: -"/>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
24
src/Views/Widgets/StatisticsPage.xaml.cs
Normal file
24
src/Views/Widgets/StatisticsPage.xaml.cs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace SourceGit.Views.Widgets {
|
||||||
|
/// <summary>
|
||||||
|
/// 统计内容
|
||||||
|
/// </summary>
|
||||||
|
public partial class StatisticsPage : UserControl {
|
||||||
|
|
||||||
|
public StatisticsPage() {
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetData(List<Models.StatisticSample> committers, List<Models.StatisticSample> commits, int totalCommits) {
|
||||||
|
Dispatcher.Invoke(() => {
|
||||||
|
txtMemberCount.Text = App.Text("Statistics.TotalCommitterCount", committers.Count);
|
||||||
|
txtCommitCount.Text = App.Text("Statistics.TotalCommitsCount", totalCommits);
|
||||||
|
|
||||||
|
lstCommitters.ItemsSource = committers;
|
||||||
|
chartCommits.SetData(commits);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue