Skip to content

Commit d58e81e

Browse files
authored
Stack and Events API improvements (#1794)
* Stack Controller Improvements * Added const for event index search error field * Doc fixes * Fixed incorrect response type * Fixed docs * Added ability to return total from event controller aggs.
1 parent 07c068e commit d58e81e

File tree

12 files changed

+34
-42
lines changed

12 files changed

+34
-42
lines changed

src/Exceptionless.Core/Configuration/AppOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Diagnostics;
1+
using System.Diagnostics;
22
using Exceptionless.Core.Configuration;
33
using Exceptionless.Core.Extensions;
44
using Microsoft.Extensions.Configuration;
@@ -22,7 +22,7 @@ public class AppOptions
2222
public string? ExceptionlessApiKey { get; internal set; }
2323

2424
/// <summary>
25-
/// Configures the exceptionless client server url, which logs all internal errors and log messages.
25+
/// Configures the Exceptionless client server url, which logs all internal errors and log messages.
2626
/// </summary>
2727
public string? ExceptionlessServerUrl { get; internal set; }
2828

src/Exceptionless.Core/Extensions/IdentityUtils.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ public static bool IsUserAuthType(this ClaimsPrincipal principal)
130130
/// Gets the token id that authenticated the current user. If null, user logged in via oauth.
131131
/// </summary>
132132
/// <param name="principal"></param>
133-
/// <returns></returns>
134133
public static string? GetLoggedInUsersTokenId(this ClaimsPrincipal principal)
135134
{
136135
return IsUserAuthType(principal) ? GetClaimValue(principal, LoggedInUsersTokenId) : null;

src/Exceptionless.Core/Repositories/Configuration/Indexes/EventIndex.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ public sealed class Alias
307307
public const string LocationLevel2 = "level2";
308308
public const string LocationLocality = "locality";
309309

310+
public const string Error = "error";
310311
public const string ErrorCode = "error.code";
311312
public const string ErrorType = "error.type";
312313
public const string ErrorMessage = "error.message";
@@ -322,7 +323,7 @@ public static PropertiesDescriptor<PersistentEvent> AddCopyToMappings(this Prope
322323
return descriptor
323324
.Text(f => f.Name(EventIndex.Alias.IpAddress).Analyzer(EventIndex.COMMA_WHITESPACE_ANALYZER))
324325
.Text(f => f.Name(EventIndex.Alias.OperatingSystem).Analyzer(EventIndex.WHITESPACE_LOWERCASE_ANALYZER).AddKeywordField())
325-
.Object<object>(f => f.Name("error").Properties(p1 => p1
326+
.Object<object>(f => f.Name(EventIndex.Alias.Error).Properties(p1 => p1
326327
.Keyword(f3 => f3.Name("code").IgnoreAbove(1024))
327328
.Text(f3 => f3.Name("message").AddKeywordField())
328329
.Text(f3 => f3.Name("type").Analyzer(EventIndex.TYPENAME_ANALYZER).SearchAnalyzer(EventIndex.WHITESPACE_LOWERCASE_ANALYZER).AddKeywordField())

src/Exceptionless.Core/Repositories/EventRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public EventRepository(ExceptionlessElasticConfiguration configuration, AppOptio
2626
// copy to fields
2727
AddDefaultExclude(EventIndex.Alias.IpAddress);
2828
AddDefaultExclude(EventIndex.Alias.OperatingSystem);
29-
AddDefaultExclude("error");
29+
AddDefaultExclude(EventIndex.Alias.Error);
3030

3131
AddPropertyRequiredForRemove(e => e.Date);
3232
}

src/Exceptionless.Core/Repositories/StackRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public Task<FindResults<Stack>> GetSoftDeleted()
4949
public async Task<bool> IncrementEventCounterAsync(string organizationId, string projectId, string stackId, DateTime minOccurrenceDateUtc, DateTime maxOccurrenceDateUtc, int count, bool sendNotifications = true)
5050
{
5151
// If total occurrences are zero (stack data was reset), then set first occurrence date
52-
// Only update the LastOccurrence if the new date is greater then the existing date.
52+
// Only update the LastOccurrence if the new date is greater than the existing date.
5353
const string script = @"
5454
Instant parseDate(def dt) {
5555
if (dt != null) {

src/Exceptionless.Web/Controllers/Base/ModelActionResults.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
namespace Exceptionless.Web.Controllers;
22

3-
public class ModelActionResults : WorkInProgressResult
3+
public record ModelActionResults : WorkInProgressResult
44
{
5-
public List<string> Success { get; set; } = new();
6-
public List<PermissionResult> Failure { get; set; } = new();
5+
public List<string> Success { get; } = new();
6+
public List<PermissionResult> Failure { get; } = new();
77

88
public void AddNotFound(IEnumerable<string> ids)
99
{
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
namespace Exceptionless.Web.Controllers;
22

3-
public class WorkInProgressResult
3+
public record WorkInProgressResult
44
{
55
public WorkInProgressResult()
66
{
7-
Workers = new List<string>();
87
}
98

109
public WorkInProgressResult(IEnumerable<string> workers) : this()
1110
{
12-
Workers.AddRange(workers ?? new List<string>());
11+
Workers.AddRange(workers);
1312
}
1413

15-
public List<string> Workers { get; set; }
14+
public List<string> Workers { get; } = new();
1615
}

src/Exceptionless.Web/Controllers/EventController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,9 @@ private async Task<ActionResult<ICollection<PersistentEvent>>> GetInternalAsync(
346346
var stacks = (await _stackRepository.GetByIdsAsync(stackIds)).Select(s => s.ApplyOffset(ti.Offset)).ToList();
347347

348348
var summaries = await GetStackSummariesAsync(stacks, stackTerms.Buckets, sf, ti);
349-
return OkWithResourceLinks(summaries.Take(limit).ToList(), summaries.Count > limit, resolvedPage);
349+
350+
long total = (stackTerms.Data?.GetValueOrDefault("SumOtherDocCount") as long? ?? 0L) + stackTerms.Buckets.Count;
351+
return OkWithResourceLinks(summaries.Take(limit).ToList(), summaries.Count > limit && !NextPageExceedsSkipLimit(resolvedPage, limit), resolvedPage, total);
350352
default:
351353
events = await GetEventsInternalAsync(sf, ti, filter, sort, page, limit, before, after);
352354
return OkWithResourceLinks(events.Documents.ToArray(), events.HasMore && !NextPageExceedsSkipLimit(page, limit), page, events.Total, events.Hits.FirstOrDefault()?.GetSortToken(), events.Hits.LastOrDefault()?.GetSortToken());

src/Exceptionless.Web/Controllers/OrganizationController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ public async Task<ActionResult<ViewOrganization>> GetAsync(string id, string? mo
140140
/// Create
141141
/// </summary>
142142
/// <param name="organization">The organization.</param>
143-
/// <returns></returns>
144143
/// <response code="400">An error occurred while creating the organization.</response>
145144
/// <response code="409">The organization already exists.</response>
146145
[HttpPost]

src/Exceptionless.Web/Controllers/ProjectController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ public async Task<ActionResult<ViewProject>> GetAsync(string id, string? mode =
152152
/// Create
153153
/// </summary>
154154
/// <param name="project">The project.</param>
155-
/// <returns></returns>
156155
/// <response code="400">An error occurred while creating the project.</response>
157156
/// <response code="409">The project already exists.</response>
158157
[HttpPost]

0 commit comments

Comments
 (0)