Skip to content

Commit 1ff1102

Browse files
committed
Updates
1 parent 972e8a3 commit 1ff1102

File tree

16 files changed

+67
-58
lines changed

16 files changed

+67
-58
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/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
}

src/Integrations/MicrosoftTeamsIntegration.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ internal override void Send(ChangeLog changeLog)
6262
Notify(values);
6363
}
6464

65-
private string GetText(ChangeLog changeLog)
65+
private static string GetText(ChangeLog changeLog)
6666
{
6767
if (changeLog is null || !changeLog.ChangeLogItems.Any()) return string.Empty;
6868

@@ -74,7 +74,7 @@ private string GetText(ChangeLog changeLog)
7474
return text.ToString();
7575
}
7676

77-
private string GetWorkItemsDescriptionSection(string sectionName, IEnumerable<ChangeLogItem> changeLogItems)
77+
private static string GetWorkItemsDescriptionSection(string sectionName, IEnumerable<ChangeLogItem> changeLogItems)
7878
{
7979
StringBuilder text = new();
8080
if (!changeLogItems.Any()) return string.Empty;
@@ -87,18 +87,18 @@ private string GetWorkItemsDescriptionSection(string sectionName, IEnumerable<Ch
8787
return text.ToString();
8888
}
8989

90-
private string GetWorkItemDescriptionLine(ChangeLogItem workItem)
90+
private static string GetWorkItemDescriptionLine(ChangeLogItem workItem)
9191
{
9292
var description = GetDescription(workItem.Description);
9393
return $"<em>**{workItem.WorkItemId}**</em> - {description} <br>";
9494
}
9595

96-
private string GetDescription(string description)
96+
private static string GetDescription(string description)
9797
{
9898
return description.Replace("<div>", "").Replace("</div>", "").Replace("<br>", "");
9999
}
100100

101-
private string GetFooter()
101+
private static string GetFooter()
102102
{
103103
return $"<br><sup> <img style='width: 16px; height: 16px;' src='{GetLogoTypingHard16x16Url()}' /> {GetNugetVersion()}</sup>";
104104
}

0 commit comments

Comments
 (0)