Skip to content

Commit 064c53b

Browse files
committed
Introduced the "New" state which is used for incidents that have not been viewed yet by someone in the application team.
1 parent 1d5254b commit 064c53b

File tree

69 files changed

+907
-744
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+907
-744
lines changed

src/Server/Coderr.Server.Api.Client/OneTrueClient.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,15 @@ public class ServerApiClient : IMessageBus, IQueryBus
1818
private readonly JsonSerializerSettings _jsonSerializerSettings = new JsonSerializerSettings
1919
{
2020
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
21-
Formatting = Formatting.Indented
21+
Formatting = Formatting.Indented,
22+
NullValueHandling = NullValueHandling.Ignore,
23+
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
24+
ContractResolver = new IncludeNonPublicMembersContractResolver()
2225
};
23-
2426
private string _apiKey;
25-
2627
private string _sharedSecret;
2728
private Uri _uri;
2829

29-
30-
/// <summary>
31-
/// Creates a new instance of <see cref="ServerApiClient" />.
32-
/// </summary>
33-
public ServerApiClient()
34-
{
35-
_jsonSerializerSettings.ContractResolver = new IncludeNonPublicMembersContractResolver();
36-
}
37-
38-
3930
async Task<TResult> IQueryBus.QueryAsync<TResult>(ClaimsPrincipal user, Query<TResult> query)
4031
{
4132
//TODO: Unwrap the cqs object to query parameters instead

src/Server/Coderr.Server.Api.Client/codeRR.Server.Api.Client.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>net452;netstandard2.0</TargetFrameworks>
4-
<Version>1.0.0.0</Version>
4+
<Version>1.1.0</Version>
55
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6-
<DocumentationFile>bin\$(Configuration)\net452\codeRR.Api.Client.xml</DocumentationFile>
6+
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Coderr.Server.Api.Client.xml</DocumentationFile>
77
</PropertyGroup>
88
<PropertyGroup>
99
<PackageId>codeRR.Server.Api.Client</PackageId>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace codeRR.Server.Api
2+
{
3+
public class CommandAttribute : MessageAttribute
4+
{
5+
6+
}
7+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
3+
namespace codeRR.Server.Api.Core.Incidents.Commands
4+
{
5+
/// <summary>
6+
/// Start working on an incident.
7+
/// </summary>
8+
[Command]
9+
public class AssignIncident
10+
{
11+
/// <summary>
12+
/// Creates new instance of <see cref="AssignIncident" />.
13+
/// </summary>
14+
/// <param name="incidentId">Incident being assigned</param>
15+
/// <param name="assignedTo">Id of the user that got assigned to this incident</param>
16+
/// <param name="assignedBy">Id of the user that assigned this incident, 0 for system requests</param>
17+
public AssignIncident(int incidentId, int assignedTo, int assignedBy)
18+
{
19+
if (assignedTo <= 0) throw new ArgumentOutOfRangeException(nameof(assignedTo));
20+
if (incidentId <= 0) throw new ArgumentOutOfRangeException(nameof(incidentId));
21+
if (assignedBy < 0) throw new ArgumentOutOfRangeException(nameof(assignedBy));
22+
23+
IncidentId = incidentId;
24+
AssignedTo = assignedTo;
25+
AssignedBy = assignedBy;
26+
}
27+
28+
/// <summary>
29+
/// Id of the user that assigned this incident.
30+
/// </summary>
31+
public int AssignedBy { get; private set; }
32+
33+
/// <summary>
34+
/// Id of the user that got assigned to this incident.
35+
/// </summary>
36+
public int AssignedTo { get; private set; }
37+
38+
/// <summary>
39+
/// Incident being assigned.
40+
/// </summary>
41+
public int IncidentId { get; private set; }
42+
}
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
3+
namespace codeRR.Server.Api.Core.Incidents.Events
4+
{
5+
/// <summary>
6+
/// Someone was assigned to an incident
7+
/// </summary>
8+
[Event]
9+
public class IncidentAssigned
10+
{
11+
/// <summary>
12+
/// Creates a new instance of <see cref="IncidentAssigned" />.
13+
/// </summary>
14+
/// <param name="incidentId">Incident being assigned</param>
15+
/// <param name="assignedById">User assigning the incident</param>
16+
/// <param name="assignedToId">User that should start working with the incident</param>
17+
public IncidentAssigned(int incidentId, int assignedById, int assignedToId)
18+
{
19+
if (incidentId <= 0) throw new ArgumentOutOfRangeException(nameof(incidentId));
20+
if (assignedById <= 0) throw new ArgumentOutOfRangeException(nameof(assignedById));
21+
if (assignedToId <= 0) throw new ArgumentOutOfRangeException(nameof(assignedToId));
22+
23+
IncidentId = incidentId;
24+
AssignedById = assignedById;
25+
AssignedToId = assignedToId;
26+
}
27+
28+
/// <summary>
29+
/// User assigning the incident (delegate work)
30+
/// </summary>
31+
public int AssignedById { get; private set; }
32+
33+
/// <summary>
34+
/// User that should start working with the incident
35+
/// </summary>
36+
public int AssignedToId { get; private set; }
37+
38+
/// <summary>
39+
/// Incident being assigned
40+
/// </summary>
41+
public int IncidentId { get; private set; }
42+
}
43+
}

src/Server/Coderr.Server.Api/Core/Incidents/IncidentSummaryDTO.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ protected IncidentSummaryDTO()
5555
/// </summary>
5656
public bool IsReOpened { get; set; }
5757

58+
/// <summary>
59+
/// someone is assigned to this incident
60+
/// </summary>
61+
public int? AssignedToUserId { get; set; }
62+
5863
/// <summary>
5964
/// Update is both when the incident was open/closed and when we received a new report. TODO: Should be refactored into
6065
/// two fields.

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class FindIncidents : Query<FindIncidentsResult>
2020
public FindIncidents()
2121
{
2222
MaxDate = DateTime.MaxValue;
23-
Open = true;
2423
ItemsPerPage = 20;
2524
}
2625

@@ -33,19 +32,29 @@ public FindIncidents()
3332
public int ApplicationId { get; set; }
3433

3534
/// <summary>
36-
/// Include closed incidents
35+
/// Will be searched in incident.message and report.stacktrace.
3736
/// </summary>
38-
public bool Closed { get; set; }
37+
public string FreeText { get; set; }
3938

4039
/// <summary>
41-
/// Will be searched in incident.message and report.stacktrace.
40+
/// Been assigned to someone
4241
/// </summary>
43-
public string FreeText { get; set; }
42+
public bool IsAssigned { get; set; }
43+
44+
/// <summary>
45+
/// Include closed incidents
46+
/// </summary>
47+
public bool IsClosed { get; set; }
4448

4549
/// <summary>
4650
/// Include ignored incidents
4751
/// </summary>
48-
public bool Ignored { get; set; }
52+
public bool IsIgnored { get; set; }
53+
54+
/// <summary>
55+
/// Incidents that have not been assigned to someone (or closed/ignored).
56+
/// </summary>
57+
public bool IsNew { get; set; }
4958

5059
/// <summary>
5160
/// Number of items per page.
@@ -62,11 +71,6 @@ public FindIncidents()
6271
/// </summary>
6372
public DateTime MinDate { get; set; }
6473

65-
/// <summary>
66-
/// Include open incidents
67-
/// </summary>
68-
public bool Open { get; set; }
69-
7074
/// <summary>
7175
/// Page to fetch (one based index)
7276
/// </summary>

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ public class GetIncidentResult
1515
/// </summary>
1616
public int ApplicationId { get; private set; }
1717

18+
/// <summary>
19+
/// When it was assigned to the person.
20+
/// </summary>
21+
public DateTime? AssignedAtUtc { get; set; }
22+
23+
/// <summary>
24+
/// User name of the person that this incident is assigned to.
25+
/// </summary>
26+
public string AssignedTo { get; set; }
27+
28+
/// <summary>
29+
/// User assigned to the incident.
30+
/// </summary>
31+
public int? AssignedToId { get; set; }
32+
1833
/// <summary>
1934
/// Context collection names.
2035
/// </summary>
@@ -42,7 +57,7 @@ public string Description
4257

4358
return _description;
4459
}
45-
set { _description = value; }
60+
set => _description = value;
4661
}
4762

4863
/// <summary>
@@ -66,6 +81,12 @@ public string Description
6681
/// </summary>
6782
public int Id { get; private set; }
6883

84+
/// <summary>
85+
/// Stores the state temporary to be able to assigned the bool fields
86+
/// </summary>
87+
[IgnoreField]
88+
public int IncidentState { get; set; }
89+
6990
/// <summary>
7091
/// Ignore future reports for this incident (i.e. no notifications, do not store new reports etc).
7192
/// </summary>
@@ -74,7 +95,7 @@ public string Description
7495
/// Report counter will still be updated.
7596
/// </para>
7697
/// </remarks>
77-
public bool IsIgnored { get; set; }
98+
public bool IsIgnored => IncidentState == 2;
7899

79100
/// <summary>
80101
/// If the incident was closed and then received error reports again.
@@ -89,7 +110,7 @@ public string Description
89110
/// <summary>
90111
/// Incident has been marked as solved (i.e. closed)
91112
/// </summary>
92-
public bool IsSolved { get; set; }
113+
public bool IsSolved => IncidentState == 3;
93114

94115
/// <summary>
95116
/// Solution written last time (if <see cref="IsReOpened" /> is <c>true</c>).
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace codeRR.Server.Api
2+
{
3+
public class EventAttribute : MessageAttribute
4+
{
5+
6+
}
7+
}

src/Server/Coderr.Server.Api/IgnoreFieldAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22

3-
namespace codeRR.Server.Api.Core.Accounts.Requests
3+
namespace codeRR.Server.Api
44
{
55
/// <summary>
66
/// Used to make the typescript compiler ignore certain properties and types.

0 commit comments

Comments
 (0)