Skip to content

Commit 570fc9d

Browse files
authored
6.0.0 update (#19)
* Update framework to .net6 * Updates
1 parent a82aee0 commit 570fc9d

17 files changed

+70
-60
lines changed

src/Adapters/WorkItemAdapter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public List<WorkItemDto> ToWorkItemsDto(List<WorkItem> workItems)
5151
.ToList();
5252
}
5353

54-
public WorkItemChangeDto ToWorkItemChangeDto(WorkItemChange workIteChange)
54+
public static WorkItemChangeDto ToWorkItemChangeDto(WorkItemChange workIteChange)
5555
{
5656
if (workIteChange is null) return null;
5757

@@ -65,7 +65,7 @@ public WorkItemChangeDto ToWorkItemChangeDto(WorkItemChange workIteChange)
6565
};
6666
}
6767

68-
public List<WorkItemChangeDto> ToWorkItemsChangeDto(List<WorkItemChange> workItemsChanges)
68+
public static List<WorkItemChangeDto> ToWorkItemsChangeDto(List<WorkItemChange> workItemsChanges)
6969
{
7070
var workItemsChangeDto = new List<WorkItemChangeDto>();
7171

@@ -80,7 +80,7 @@ public List<WorkItemChangeDto> ToWorkItemsChangeDto(List<WorkItemChange> workIte
8080
.ToList();
8181
}
8282

83-
public TimeByStateDto ToTimeByStateDto(TimeByState workItemStatusTime)
83+
public static TimeByStateDto ToTimeByStateDto(TimeByState workItemStatusTime)
8484
{
8585
if (workItemStatusTime is null) return null;
8686

@@ -93,7 +93,7 @@ public TimeByStateDto ToTimeByStateDto(TimeByState workItemStatusTime)
9393
};
9494
}
9595

96-
public List<TimeByStateDto> ToTimeByStatesDto(List<TimeByState> workItemStatusTimes)
96+
public static List<TimeByStateDto> ToTimeByStatesDto(List<TimeByState> workItemStatusTimes)
9797
{
9898
var workItemStatusTimeDto = new List<TimeByStateDto>();
9999

src/AzureDevopsTracker.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@
2626

2727
<ItemGroup>
2828
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
29-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
29+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.28" />
3030
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
31-
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
32-
<PackageReference Include="System.Net.Http.Json" Version="6.0.0" />
31+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
32+
<PackageReference Include="System.Net.Http.Json" Version="6.0.1" />
3333
</ItemGroup>
3434

3535
<ItemGroup>
3636
<None Include="..\LICENSE.md.txt">
3737
<Pack>True</Pack>
3838
<PackagePath></PackagePath>
39+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3940
</None>
4041
</ItemGroup>
4142

src/Configurations/Configuration.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ namespace AzureDevopsTracker.Configurations
1515
{
1616
public static class Configuration
1717
{
18-
public static IServiceCollection AddAzureDevopsTracker(this IServiceCollection services, DataBaseConfig configurations, MessageConfig messageConfig = null)
18+
public static IServiceCollection AddAzureDevopsTracker(this IServiceCollection services,
19+
DataBaseConfig configurations,
20+
MessageConfig messageConfig = null)
1921
{
2022
services.AddDbContext<AzureDevopsTrackerContext>(options =>
2123
options.UseSqlServer(DataBaseConfig.ConnectionsString));
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
using AzureDevopsTracker.Data.Context;
22
using AzureDevopsTracker.Entities;
33
using AzureDevopsTracker.Interfaces.Internals;
4+
using Microsoft.EntityFrameworkCore;
45
using System.Collections.Generic;
56
using System.Linq;
7+
using System.Threading.Tasks;
68

79
namespace AzureDevopsTracker.Data
810
{
911
internal class ChangeLogItemRepository : Repository<ChangeLogItem>, IChangeLogItemRepository
1012
{
1113
public ChangeLogItemRepository(AzureDevopsTrackerContext context) : base(context) { }
1214

13-
public int CountItemsForRelease()
15+
public async Task<int> CountItemsForRelease()
1416
{
15-
return DbSet.Count(x => string.IsNullOrEmpty(x.ChangeLogId));
17+
return await DbSet.CountAsync(x => string.IsNullOrEmpty(x.ChangeLogId));
1618
}
1719

18-
public IEnumerable<ChangeLogItem> ListWaitingForRelease()
20+
public async Task<IEnumerable<ChangeLogItem>> ListWaitingForRelease()
1921
{
20-
return DbSet.Where(x => string.IsNullOrEmpty(x.ChangeLogId));
22+
return await DbSet.Where(x => string.IsNullOrEmpty(x.ChangeLogId)).ToListAsync();
2123
}
2224
}
2325
}

src/Data/ChangeLogRepository.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
using AzureDevopsTracker.Data.Context;
22
using AzureDevopsTracker.Entities;
33
using AzureDevopsTracker.Interfaces.Internals;
4+
using Microsoft.EntityFrameworkCore;
45
using System;
5-
using System.Linq;
6+
using System.Threading.Tasks;
67

78
namespace AzureDevopsTracker.Data
89
{
910
internal class ChangeLogRepository : Repository<ChangeLog>, IChangeLogRepository
1011
{
1112
public ChangeLogRepository(AzureDevopsTrackerContext context) : base(context) { }
1213

13-
public int CountChangeLogsCreatedToday()
14+
public async Task<int> CountChangeLogsCreatedToday()
1415
{
15-
return DbSet.Count(x => x.CreatedAt.Date == DateTime.Now.Date);
16+
return await DbSet.CountAsync(x => x.CreatedAt.Date == DateTime.Now.Date);
1617
}
1718
}
1819
}

src/Entities/ChangeLogItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class ChangeLogItem : Entity
1010
public string Description { get; private set; }
1111
public string WorkItemType { get; private set; }
1212
public string ChangeLogId { get; private set; }
13-
public bool WasReleased => string.IsNullOrEmpty(ChangeLogId?.Trim());
13+
public bool WasReleased => string.IsNullOrWhiteSpace(ChangeLogId);
1414
public ChangeLog ChangeLog { get; private set; }
1515

1616
private ChangeLogItem() { }

src/Entities/WorkItem.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ public IEnumerable<TimeByState> CalculateTotalTimeByState()
142142
if (!_workItemsChanges.Any())
143143
return timesByStateList;
144144

145-
foreach (var workItemChange in _workItemsChanges.OrderBy(x => x.CreatedAt).GroupBy(x => x.OldState).Where(x => x.Key is not null))
145+
foreach (var workItemChange in _workItemsChanges.OrderBy(x => x.CreatedAt)
146+
.GroupBy(x => x.OldState)
147+
.Where(x => x.Key is not null))
146148
{
147149
var totalTime = TimeSpan.Zero;
148150
var totalWorkedTime = TimeSpan.Zero;

src/Entities/WorkItemChange.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public double CalculateTotalWorkedTime()
139139
}
140140

141141
#region Private Methods
142-
private TimeSpan SubtractDates(DateTime biger, DateTime minor)
142+
private static TimeSpan SubtractDates(DateTime biger, DateTime minor)
143143
{
144144
if (biger.Hour == minor.Hour)
145145
{

src/Integrations/DiscordIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public class Field
9797
public bool IsInline { get; set; }
9898
}
9999

100-
private IEnumerable<Field> GetText(ChangeLog changeLog)
100+
private static IEnumerable<Field> GetText(ChangeLog changeLog)
101101
{
102102
var changeLogItemsAgrupado = changeLog.ChangeLogItems.GroupBy(d => d.WorkItemType);
103103

src/Integrations/MessageIntegration.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,46 @@ public abstract class MessageIntegration
1313
private static readonly string MEGAFONE_GIF = "megafone.gif";
1414
private static readonly string LOGO_TYPINGHARD_16X16 = "logo-typinghard-16x16.png";
1515

16-
protected internal string GetTitle()
16+
protected internal static string GetTitle()
1717
{
1818
return $"Nova atualização da plataforma";
1919
}
2020

21-
protected internal string GetVersion(ChangeLog changeLog)
21+
protected internal static string GetVersion(ChangeLog changeLog)
2222
{
2323
return $"Versão: {changeLog.Number}";
2424
}
2525

26-
protected internal string GetAnnouncementImageUrl()
26+
protected internal static string GetAnnouncementImageUrl()
2727
{
2828
return $"{CDN_URL}{MEGAFONE_GIF}";
2929
}
3030

31-
protected internal string GetLogoTypingHard16x16Url()
31+
protected internal static string GetLogoTypingHard16x16Url()
3232
{
3333
return $"{CDN_URL}{LOGO_TYPINGHARD_16X16}";
3434
}
3535

36-
protected internal string GetFileVersion()
36+
protected internal static string GetFileVersion()
3737
{
3838
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
3939
System.Diagnostics.FileVersionInfo fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
4040
return fileVersionInfo.FileVersion;
4141
}
4242

43-
protected internal string GetNugetVersion()
43+
protected internal static string GetNugetVersion()
4444
{
4545
return $"Powered by **Typing Hard** • nuget version {GetFileVersion()}";
4646
}
4747

48-
protected internal HttpResponseMessage Notify(object body)
48+
protected internal static HttpResponseMessage Notify(object body)
4949
{
5050
var json = Newtonsoft.Json.JsonConvert.SerializeObject(body);
5151
var content = new StringContent(json,
5252
Encoding.UTF8,
5353
MIMETYPE);
54-
HttpClient client = new HttpClient();
55-
return client.PostAsync(new Uri(MessageConfig.URL),
56-
content).Result;
57-
54+
using HttpClient client = new();
55+
return client.PostAsync(new Uri(MessageConfig.URL), content).Result;
5856
}
5957
}
6058
}

0 commit comments

Comments
 (0)