Skip to content

Commit

Permalink
fix: fix time query 400 in zh-cn i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
Qinyouzeng committed Mar 13, 2024
1 parent 4ba983c commit 59c86dd
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ public static bool IsRawQuery([NotNull] this string text, bool isElasticsearch =

return false;
}

public static DateTime ParseTime(this string str)
{
return DateTime.TryParse(str, out var time) ? time : DateTime.MinValue;
}
}
58 changes: 30 additions & 28 deletions src/Services/Masa.Tsc.Service.Admin/Services/ApmService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

using Masa.Tsc.Service.Admin.Extensions;

namespace Masa.Tsc.Service.Admin.Services;

public class ApmService : ServiceBase
Expand All @@ -9,13 +11,13 @@ public class ApmService : ServiceBase
public ApmService(IApmService apmService) : base("/api/apm")
{
this.apmService = apmService;
}
}

public async Task<PaginatedListBase<ServiceListDto>> GetServices(int page, int pageSize, DateTime start, DateTime end, string? env, ComparisonTypes? comparisonType, string? queries, string? orderField, bool? isDesc)
public async Task<PaginatedListBase<ServiceListDto>> GetServices(int page, int pageSize, string start, string end, string? env, ComparisonTypes? comparisonType, string? queries, string? orderField, bool? isDesc)
=> await apmService.ServicePageAsync(new BaseApmRequestDto
{
Start = start,
End = end,
Start = start.ParseTime(),
End = end.ParseTime(),
Env = GetEnv(env),
ComparisonType = comparisonType,
Queries = queries,
Expand All @@ -26,11 +28,11 @@ public async Task<PaginatedListBase<ServiceListDto>> GetServices(int page, int p
StatusCodes = string.Join(',', ConfigConst.TraceErrorStatus)
});

public async Task<PaginatedListBase<EndpointListDto>> GetEndpoints(int page, int pageSize, DateTime start, DateTime end, string? env, string? service, ComparisonTypes? comparisonType, string? queries, string? orderField, bool? isDesc)
public async Task<PaginatedListBase<EndpointListDto>> GetEndpoints(int page, int pageSize, string start, string end, string? env, string? service, ComparisonTypes? comparisonType, string? queries, string? orderField, bool? isDesc)
=> await apmService.EndpointPageAsync(new BaseApmRequestDto
{
Start = start,
End = end,
Start = start.ParseTime(),
End = end.ParseTime(),
Env = GetEnv(env),
ComparisonType = comparisonType,
Queries = queries,
Expand All @@ -42,34 +44,34 @@ public async Task<PaginatedListBase<EndpointListDto>> GetEndpoints(int page, int
StatusCodes = string.Join(',', ConfigConst.TraceErrorStatus)
});

public async Task<IEnumerable<ChartLineDto>> GetCharts(DateTime start, DateTime end, string? env, string? service, ComparisonTypes? comparisonType, string? queries)
public async Task<IEnumerable<ChartLineDto>> GetCharts(string start, string end, string? env, string? service, ComparisonTypes? comparisonType, string? queries)
=> await apmService.ChartDataAsync(new BaseApmRequestDto
{
Start = start,
End = end,
Start = start.ParseTime(),
End = end.ParseTime(),
Env = GetEnv(env),
ComparisonType = comparisonType,
Queries = queries,
Service = service,
StatusCodes = string.Join(',', ConfigConst.TraceErrorStatus)
});

public async Task<EndpointLatencyDistributionDto> GetLatencyDistributions(DateTime start, DateTime end, string? env, string? service, string endpoint)
public async Task<EndpointLatencyDistributionDto> GetLatencyDistributions(string start, string end, string? env, string? service, string endpoint)
=> await apmService.EndpointLatencyDistributionAsync(new ApmEndpointRequestDto
{
Start = start,
End = end,
Start = start.ParseTime(),
End = end.ParseTime(),
Env = GetEnv(env),
Service = service,
Endpoint = endpoint,
StatusCodes = string.Join(',', ConfigConst.TraceErrorStatus)
});

public async Task<PaginatedListBase<ErrorMessageDto>> GetErrors(int page, int pageSize, DateTime start, DateTime end, string? env, string? service, ComparisonTypes? comparisonType, string? queries, string? orderField, bool? isDesc)
public async Task<PaginatedListBase<ErrorMessageDto>> GetErrors(int page, int pageSize, string start, string end, string? env, string? service, ComparisonTypes? comparisonType, string? queries, string? orderField, bool? isDesc)
=> await apmService.ErrorMessagePageAsync(new ApmEndpointRequestDto
{
Start = start,
End = end,
Start = start.ParseTime(),
End = end.ParseTime(),
Env = GetEnv(env),
Queries = queries,
OrderField = orderField,
Expand All @@ -79,11 +81,11 @@ public async Task<PaginatedListBase<ErrorMessageDto>> GetErrors(int page, int pa
Service = service
});

public Task<IEnumerable<ChartPointDto>> GetSpanErrors(int page, int pageSize, DateTime start, DateTime end, string? env, string? service, ComparisonTypes? comparisonType, string? queries, string? orderField, bool? isDesc)
public Task<IEnumerable<ChartPointDto>> GetSpanErrors(int page, int pageSize, string start, string end, string? env, string? service, ComparisonTypes? comparisonType, string? queries, string? orderField, bool? isDesc)
=> apmService.GetTraceErrorsAsync(new ApmEndpointRequestDto
{
Start = start,
End = end,
Start = start.ParseTime(),
End = end.ParseTime(),
Env = GetEnv(env),
Queries = queries,
OrderField = orderField,
Expand All @@ -93,11 +95,11 @@ public Task<IEnumerable<ChartPointDto>> GetSpanErrors(int page, int pageSize, Da
Service = service
});

public async Task<PaginatedListBase<TraceResponseDto>> GetTraceDetail(int page, DateTime start, DateTime end, string? env, string? service, string endpoint, long? latMin, long? latMax)
public async Task<PaginatedListBase<TraceResponseDto>> GetTraceDetail(int page, string start, string end, string? env, string? service, string endpoint, long? latMin, long? latMax)
=> await apmService.TraceLatencyDetailAsync(new ApmTraceLatencyRequestDto
{
Start = start,
End = end,
Start = start.ParseTime(),
End = end.ParseTime(),
Env = GetEnv(env),
Page = page,
Service = service,
Expand All @@ -106,11 +108,11 @@ public async Task<PaginatedListBase<TraceResponseDto>> GetTraceDetail(int page,
LatMin = latMin
});

public async Task<IEnumerable<ChartLineCountDto>> GetErrorChart(DateTime start, DateTime end, string? env, string? service, string? endpoint, ComparisonTypes? comparisonType, string? queries)
public async Task<IEnumerable<ChartLineCountDto>> GetErrorChart(string start, string end, string? env, string? service, string? endpoint, ComparisonTypes? comparisonType, string? queries)
=> await apmService.GetErrorChartAsync(new ApmEndpointRequestDto
{
Start = start,
End = end,
Start = start.ParseTime(),
End = end.ParseTime(),
Env = GetEnv(env),
ComparisonType = comparisonType,
Queries = queries,
Expand All @@ -119,11 +121,11 @@ public async Task<IEnumerable<ChartLineCountDto>> GetErrorChart(DateTime start,
StatusCodes = string.Join(',', ConfigConst.TraceErrorStatus)
});

public async Task<IEnumerable<ChartLineCountDto>> GetLogChart(DateTime start, DateTime end, string? env, string? service, ComparisonTypes? comparisonType, string? queries)
public async Task<IEnumerable<ChartLineCountDto>> GetLogChart(string start, string end, string? env, string? service, ComparisonTypes? comparisonType, string? queries)
=> await apmService.GetLogChartAsync(new ApmEndpointRequestDto
{
Start = start,
End = end,
Start = start.ParseTime(),
End = end.ParseTime(),
Env = GetEnv(env),
ComparisonType = comparisonType,
Queries = queries,
Expand Down
4 changes: 2 additions & 2 deletions src/Services/Masa.Tsc.Service.Admin/Services/AppService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public async Task<List<AppDto>> GetListAsync([FromServices] IEventBus eventBus,
return query.Result;
}

public async Task<long> GetErrorCountAsync([FromServices] IEventBus eventBus, string appid, DateTime start, DateTime end)
public async Task<long> GetErrorCountAsync([FromServices] IEventBus eventBus, string appid, string start, string end)
{
var query = new AppErrorCountQuery(appid, start, end);
var query = new AppErrorCountQuery(appid, start.ParseTime(), end.ParseTime());
await eventBus.PublishAsync(query);
return query.Result;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

using Masa.Tsc.Service.Admin.Extensions;

namespace Masa.Tsc.Service.Admin.Services;

public class DirectoryService : ServiceBase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

using Masa.Tsc.Service.Admin.Extensions;

namespace Masa.Tsc.Service.Admin.Services.Instruments;

public class InstrumentService : ServiceBase
Expand Down
4 changes: 2 additions & 2 deletions src/Services/Masa.Tsc.Service.Admin/Services/LogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ private async Task<PaginatedListBase<LogResponseDto>> GetPageAsync([FromServices
return query.Result;
}

public async Task<List<LogErrorDto>> GetErrorTypesAsync([FromServices] IEventBus eventBus, string service, DateTime start, DateTime end)
public async Task<List<LogErrorDto>> GetErrorTypesAsync([FromServices] IEventBus eventBus, string service, string start, string end)
{
var query = new LogErrorTypesQuery(service, start, end);
var query = new LogErrorTypesQuery(service, start.ParseTime(), end.ParseTime());
await eventBus.PublishAsync(query);
return query.Result;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Services/Masa.Tsc.Service.Admin/Services/MetricService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ private async Task<string> GetRangeValuesAsync([FromServices] IEventBus eventBus
return query.Result ?? string.Empty;
}

public async Task<QueryResultDataResponse> GetQueryAsync([FromServices] IEventBus eventBus, [FromQuery] string query, [FromQuery] DateTime time)
public async Task<QueryResultDataResponse> GetQueryAsync([FromServices] IEventBus eventBus, [FromQuery] string query, [FromQuery] string time)
{
var result = new InstantQuery(query, time);
var result = new InstantQuery(query, time.ParseTime());
await eventBus.PublishAsync(result);
return result.Result;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Services/Masa.Tsc.Service.Admin/Services/TraceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ private async Task<IEnumerable<TraceResponseDto>> GetAsync([FromServices] IEvent
return query.Result;
}

private async Task<string> GetTraceIdByMetricAsync([FromServices] IEventBus eventBus, string service, string url, DateTime start, DateTime end)
private async Task<string> GetTraceIdByMetricAsync([FromServices] IEventBus eventBus, string service, string url, string start, string end)
{
var query = new TraceIdByMetricQuery(service, url, start, end);
var query = new TraceIdByMetricQuery(service, url, start.ParseTime(), end.ParseTime());
await eventBus.PublishAsync(query);
return query.Result;
}
Expand All @@ -49,9 +49,9 @@ private async Task<object> AggregateAsync([FromServices] IEventBus eventBus, [Fr
return query.Result!;
}

public async Task<IEnumerable<TraceResponseDto>> GetNextAsync([FromServices] IEventBus eventBus, string service, string traceId, DateTime time, string url, bool isNext)
public async Task<IEnumerable<TraceResponseDto>> GetNextAsync([FromServices] IEventBus eventBus, string service, string traceId, string time, string url, bool isNext)
{
var query = new TraceDetailNextQuery(service, traceId, time, url, isNext);
var query = new TraceDetailNextQuery(service, traceId, time.ParseTime(), url, isNext);
await eventBus.PublishAsync(query);
return query.Result;
}
Expand Down
3 changes: 0 additions & 3 deletions src/Web/Masa.Tsc.Web.Admin.Rcl/Pages/Apm/Service.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ private async Task OnPageChange((int page, int pageSize) pageData)

private async Task LoadASync(SearchData data = null!)
{
var d = 1.7343;
var t = (int)d;

isTableLoading = true;
if (data != null)
Search = data;
Expand Down

0 comments on commit 59c86dd

Please sign in to comment.