Skip to content

Commit 309db6e

Browse files
authored
enhance: slightly improve statistics (#711)
* use preference MaxHistoryCommits * use current culture to adjust first days of the week
1 parent 5b55e35 commit 309db6e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Commands/Statistics.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using SourceGit.ViewModels;
23

34
namespace SourceGit.Commands
45
{
@@ -8,7 +9,7 @@ public Statistics(string repo)
89
{
910
WorkingDirectory = repo;
1011
Context = repo;
11-
Args = $"log --date-order --branches --remotes -40000 --pretty=format:\"%ct$%aN\"";
12+
Args = $"log --date-order --branches --remotes -{Preference.Instance.MaxHistoryCommits} --pretty=format:\"%ct$%aN\"";
1213
}
1314

1415
public Models.Statistics Result()

src/Models/Statistics.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3-
3+
using System.Globalization;
44
using LiveChartsCore;
55
using LiveChartsCore.Defaults;
66
using LiveChartsCore.SkiaSharpView;
@@ -138,7 +138,7 @@ public class Statistics
138138
public Statistics()
139139
{
140140
_today = DateTime.Now.ToLocalTime().Date;
141-
_thisWeekStart = _today.AddSeconds(-(int)_today.DayOfWeek * 3600 * 24);
141+
_thisWeekStart = _today.AddDays(((int)_today.DayOfWeek + (int)CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek) % 7 - 7);
142142
_thisMonthStart = _today.AddDays(1 - _today.Day);
143143

144144
All = new StatisticsReport(StaticsticsMode.All, DateTime.MinValue);

0 commit comments

Comments
 (0)