Skip to content

Commit d1694ac

Browse files
committed
Introduced plugin interfaces.
1 parent c3188e9 commit d1694ac

File tree

23 files changed

+424
-98
lines changed

23 files changed

+424
-98
lines changed

src/Server/Coderr.Server.Api/Core/Incidents/Queries/GetIncidentResult.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ public string Description
6161
}
6262

6363
/// <summary>
64-
/// Number of users that have written what they did when the error occurred.
64+
/// facts
6565
/// </summary>
66-
public int FeedbackCount { get; set; }
66+
public QuickFact[] Facts { get; set; }
6767

6868
/// <summary>
6969
/// Full name of the exception message.
@@ -112,6 +112,11 @@ public string Description
112112
/// </summary>
113113
public bool IsSolved => IncidentState == 3;
114114

115+
/// <summary>
116+
/// When we received the last report for this incident.
117+
/// </summary>
118+
public DateTime LastReportReceivedAtUtc { get; set; }
119+
115120
/// <summary>
116121
/// Solution written last time (if <see cref="IsReOpened" /> is <c>true</c>).
117122
/// </summary>
@@ -122,15 +127,11 @@ public string Description
122127
/// </summary>
123128
public DateTime ReOpenedAtUtc { get; set; }
124129

125-
/// <summary>
126-
/// Number of received reports.
127-
/// </summary>
128-
public int ReportCount { get; set; }
129130

130131
/// <summary>
131-
/// When we received the last report for this incident.
132+
/// Number of reports received to date.
132133
/// </summary>
133-
public DateTime LastReportReceivedAtUtc { get; set; }
134+
public int ReportCount { get; set; }
134135

135136
/// <summary>
136137
/// Generated hash code
@@ -162,9 +163,7 @@ public string Description
162163
/// </summary>
163164
public DateTime UpdatedAtUtc { get; private set; }
164165

165-
/// <summary>
166-
/// Number of users that have supplied their email address
167-
/// </summary>
168-
public int WaitingUserCount { get; set; }
166+
public SuggestedIncidentSolution[] SuggestedSolutions { get; set; }
167+
public HighlightedContextData[] HighlightedContextData { get; set; }
169168
}
170169
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
namespace codeRR.Server.Api.Core.Incidents.Queries
2+
{
3+
/// <summary>
4+
/// Context data that can help the developer to directly understand why the exception happened.
5+
/// </summary>
6+
/// <remarks>
7+
/// <para>
8+
/// For instance for Page Not Found this is the URL and the Referrer.
9+
/// </para>
10+
/// </remarks>
11+
public class HighlightedContextData
12+
{
13+
/// <summary>
14+
/// Why this data helps and what it means.
15+
/// </summary>
16+
public string Description { get; set; }
17+
18+
/// <summary>
19+
/// Name ("UrlReferrer", "Url", "HttpCode" etc).
20+
/// </summary>
21+
public string Name { get; set; }
22+
23+
/// <summary>
24+
/// Optional url that the user can click on to get more information
25+
/// </summary>
26+
public string Url { get; set; }
27+
28+
/// <summary>
29+
/// Value to show
30+
/// </summary>
31+
/// <remarks>
32+
/// Values should be sorted i priority order (first item will be displayed directly)
33+
/// </remarks>
34+
public string[] Value { get; set; }
35+
}
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
namespace codeRR.Server.Api.Core.Incidents.Queries
2+
{
3+
/// <summary>
4+
/// Quick fact for incidents.
5+
/// </summary>
6+
/// <remarks>
7+
/// <para>
8+
/// For instance number of reports, when the incident was created, number of affected users etc.
9+
/// </para>
10+
/// </remarks>
11+
public class QuickFact
12+
{
13+
/// <summary>
14+
/// what this fact displays
15+
/// </summary>
16+
public string Description { get; set; }
17+
18+
/// <summary>
19+
/// Fact title (heading)
20+
/// </summary>
21+
public string Title { get; set; }
22+
23+
/// <summary>
24+
/// Optional url to get more information.
25+
/// </summary>
26+
public string Url { get; set; }
27+
28+
/// <summary>
29+
/// Value to show
30+
/// </summary>
31+
/// <remarks>
32+
/// For multiple values; separate them with semi colons.
33+
/// </remarks>
34+
public string Value { get; set; }
35+
}
36+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace codeRR.Server.Api.Core.Incidents.Queries
2+
{
3+
/// <summary>
4+
/// A suggested solution for the incident
5+
/// </summary>
6+
public class SuggestedIncidentSolution
7+
{
8+
/// <summary>
9+
/// Common reasons to why this exception is thrown.
10+
/// </summary>
11+
public string Reason { get; set; }
12+
13+
14+
/// <summary>
15+
/// How the incident can be solved.
16+
/// </summary>
17+
public string SuggestedSolution { get; set; }
18+
}
19+
}

src/Server/Coderr.Server.App/Modules/Versions/IVersionRepository.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public interface IVersionRepository
2929
Task CreateAsync(ApplicationVersion entity);
3030

3131
/// <summary>
32-
/// Get monhtly exception report
32+
/// Get monthly exception report
3333
/// </summary>
3434
/// <param name="applicationId">Application id</param>
3535
/// <param name="year">Year, four digits</param>
@@ -41,7 +41,7 @@ public interface IVersionRepository
4141
Task<ApplicationVersionMonth> FindMonthForApplicationAsync(int applicationId, int year, int month);
4242

4343
/// <summary>
44-
/// Hämta version
44+
/// Get version
4545
/// </summary>
4646
/// <param name="applicationId">id for the application that we want to fetch a version for</param>
4747
/// <param name="version">Version (<c>"1.0.0"</c>)</param>
@@ -50,6 +50,16 @@ public interface IVersionRepository
5050
/// <exception cref="DbException">Failed to query DB</exception>
5151
Task<ApplicationVersion> FindVersionAsync(int applicationId, string version);
5252

53+
/// <summary>
54+
/// Get version
55+
/// </summary>
56+
/// <param name="incidentId">Incident to get versions for</param>
57+
/// <returns>version if found; otherwise <c>null</c></returns>
58+
/// <exception cref="ArgumentNullException">applicationId;version</exception>
59+
/// <exception cref="DbException">Failed to query DB</exception>
60+
Task<IList<ApplicationVersion>> FindForIncidentAsync(int incidentId);
61+
62+
5363
/// <summary>
5464
/// Update an existing monthly report
5565
/// </summary>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using codeRR.Server.Api.Core.Incidents.Queries;
7+
using Coderr.Server.PluginApi;
8+
using Griffin.Container;
9+
10+
namespace codeRR.Server.App.Modules.Versions
11+
{
12+
[Component]
13+
class QuickFactsProvider : IQuickfactProvider
14+
{
15+
private IVersionRepository _repository;
16+
17+
public QuickFactsProvider(IVersionRepository repository)
18+
{
19+
_repository = repository;
20+
}
21+
22+
public async Task AssignAsync(int incidentId, ICollection<QuickFact> facts)
23+
{
24+
var versions = await _repository.FindForIncidentAsync(incidentId);
25+
if (!versions.Any())
26+
{
27+
facts.Add(new QuickFact
28+
{
29+
Title = "Versions",
30+
Value = "<em class=\"text-muted\">(This feature is activated in admin)</em>"
31+
});
32+
return;
33+
}
34+
35+
facts.Add(new QuickFact
36+
{
37+
Title = "Versions",
38+
Description = "Application versions that this incident have been detected in.",
39+
Value = string.Join(", ", versions.Select(x => "v" + x.Version))
40+
});
41+
}
42+
}
43+
}

src/Server/Coderr.Server.App/codeRR.Server.App.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<ItemGroup>
1919
<ProjectReference Include="..\Coderr.Server.Api\codeRR.Server.Api.csproj" />
2020
<ProjectReference Include="..\Coderr.Server.Infrastructure\codeRR.Server.Infrastructure.csproj" />
21+
<ProjectReference Include="..\Coderr.Server.PluginApi\Coderr.Server.PluginApi.csproj" />
2122
</ItemGroup>
2223
<ItemGroup>
2324
<Reference Include="System.Management" />
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<ProjectReference Include="..\Coderr.Server.Api\codeRR.Server.Api.csproj" />
9+
</ItemGroup>
10+
11+
</Project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using codeRR.Server.Api.Core.Incidents.Queries;
4+
5+
namespace Coderr.Server.PluginApi
6+
{
7+
public interface IHighlightedContextDataProvider
8+
{
9+
Task CollectAsync(int incidentId, ICollection<HighlightedContextData> data);
10+
}
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
using codeRR.Server.Api.Core.Incidents.Queries;
5+
6+
namespace Coderr.Server.PluginApi
7+
{
8+
public interface IQuickfactProvider
9+
{
10+
Task AssignAsync(int incidentId, ICollection<QuickFact> facts);
11+
}
12+
}

0 commit comments

Comments
 (0)