public async Task <IActionResult> GetDays(MetricsQuery query) { var user = await _userRepository.GetUser(User.ParseAllClaims().User.Id); if (_sysAdminService.IsUserSysAdmin(user)) { var routes = await _apiLogRepository.SearchApiLogs(query.From, query.To, query.UserId, query.Route); var grouped = routes.GroupBy(x => new { x.StartedAt.Year, x.StartedAt.Month, x.StartedAt.Day }) .Select(x => new DateCount { Day = new DateTime(x.First().StartedAt.Year, x.First().StartedAt.Month, x.First().StartedAt.Day), Count = x.Count() }) .ToList(); for (var x = query.From; x < query.To; x = x + new TimeSpan(1, 0, 0, 0)) { if (!grouped.Any(y => y.Day.Year == x.Value.Year && y.Day.Month == x.Value.Month && y.Day.Day == x.Value.Day)) { grouped.Add(new DateCount() { Day = x.Value, Count = 0 }); } } grouped = grouped.OrderBy(x => x.Day).ToList(); return(Ok(grouped)); } else { return(Forbid()); } }
public async Task <MetricsModel> Metrics([FromBody] MetricsQuery query) { query.User = this.user; query.Key = this.password; return(await this.historicalPerformanceService.Metrics(query)); }
public virtual MetricsResultDto sum(UriInfo uriInfo) { MetricsQuery query = processEngine.ManagementService.createMetricsQuery().name(metricsName); applyQueryParams(query, uriInfo); return(new MetricsResultDto(query.sum())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUpRuntimeData() public virtual void setUpRuntimeData() { managementServiceMock = mock(typeof(ManagementService)); when(processEngine.ManagementService).thenReturn(managementServiceMock); meterQueryMock = MockProvider.createMockMeterQuery(); when(managementServiceMock.createMetricsQuery()).thenReturn(meterQueryMock); }
public async Task <IActionResult> GetRouteMetrics(MetricsQuery query) { var user = await _userRepository.GetUser(User.ParseAllClaims().User.Id); if (_sysAdminService.IsUserSysAdmin(user)) { var metrics = await _apiLogRepository.GetRouteMetrics(query.From, query.To, query.UserId, query.Route); return(Ok(metrics)); } else { return(Forbid()); } }
// VALUE ////////////////////////////////////////////////////////////////////// //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testMeterQueryDefaultIntervalCalculatedValue() public virtual void testMeterQueryDefaultIntervalCalculatedValue() { //given metric data created for 15 min intervals //when query metric interval data with custom interval, start and end date in where clause DateTime endDate = firstInterval.plusMinutes(DEFAULT_INTERVAL); DateTime startDate = firstInterval; MetricsQuery metricQuery = managementService.createMetricsQuery().startDate(startDate.toDate()).endDate(endDate.toDate()).name(ACTIVTY_INSTANCE_START); IList <MetricIntervalValue> metrics = metricQuery.interval(); long sum = metricQuery.sum(); //then result contains 1 entries //sum should be equal to the sum which is calculated by the metric query assertEquals(1, metrics.Count); assertEquals(sum, metrics[0].Value); }
public async Task <IActionResult> GetUsers(MetricsQuery query) { var user = await _userRepository.GetUser(User.ParseAllClaims().User.Id); if (_sysAdminService.IsUserSysAdmin(user)) { var routes = await _apiLogRepository.SearchApiLogs(query.From, query.To, query.UserId, query.Route); var grouped = routes.GroupBy(x => x.UserId) .Select(x => new { User = x.First().User, Count = x.Count() }) .OrderBy(x => x.Count) .ToList(); return(Ok(grouped)); } else { return(Forbid()); } }
public async Task <MetricsModel> Metrics(MetricsQuery query) { var byteArray = Encoding.ASCII.GetBytes($"{query.User}:{query.Key}"); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue( "Basic", Convert.ToBase64String(byteArray)); var content = new StringContent(query.ToJson(new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }), Encoding.UTF8, "application/json"); // return ReadFile<MetricsModel>.GetFromJson(@"~/../../Data/HspMetrics.json"); var results = await httpClient.PostAsync(query.Url, content); return((await results.Content.ReadAsStringAsync()) .DeserialiseJson <MetricsModel>()); }
protected internal virtual void applyQueryParams(MetricsQuery query, UriInfo uriInfo) { MultivaluedMap <string, string> queryParameters = uriInfo.QueryParameters; DateConverter dateConverter = new DateConverter(); dateConverter.ObjectMapper = objectMapper; if (queryParameters.getFirst("startDate") != null) { DateTime startDate = dateConverter.convertQueryParameterToType(queryParameters.getFirst("startDate")); query.startDate(startDate); } if (queryParameters.getFirst("endDate") != null) { DateTime endDate = dateConverter.convertQueryParameterToType(queryParameters.getFirst("endDate")); query.endDate(endDate); } }
public override void execute(PerfTestRunContext context) { MetricsQuery metricsQuery = this.processEngine.ManagementService.createMetricsQuery(); if (!string.ReferenceEquals(name, null)) { metricsQuery.name(name); } if (startDate != null) { metricsQuery.startDate(startDate); } if (endDate != null) { metricsQuery.endDate(endDate); } metricsQuery.sum(); }
protected internal virtual void applyQueryParams(MetricsQuery query, MultivaluedMap <string, string> queryParameters) { DateConverter dateConverter = new DateConverter(); dateConverter.ObjectMapper = objectMapper; if (queryParameters.getFirst(QUERY_PARAM_START_DATE) != null) { DateTime startDate = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_START_DATE)); query.startDate(startDate); } if (queryParameters.getFirst(QUERY_PARAM_END_DATE) != null) { DateTime endDate = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_END_DATE)); query.endDate(endDate); } IntegerConverter intConverter = new IntegerConverter(); intConverter.ObjectMapper = objectMapper; if (queryParameters.getFirst(QUERY_PARAM_FIRST_RESULT) != null) { int firstResult = intConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_FIRST_RESULT)).Value; query.offset(firstResult); } if (queryParameters.getFirst(QUERY_PARAM_MAX_RESULTS) != null) { int maxResults = intConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_MAX_RESULTS)).Value; query.limit(maxResults); } if (queryParameters.getFirst(QUERY_PARAM_AGG_BY_REPORTER) != null) { query.aggregateByReporter(); } }
public virtual IList <MetricsIntervalResultDto> interval(UriInfo uriInfo) { MultivaluedMap <string, string> queryParameters = uriInfo.QueryParameters; MetricsQuery query = processEngine.ManagementService.createMetricsQuery().name(queryParameters.getFirst(QUERY_PARAM_NAME)).reporter(queryParameters.getFirst(QUERY_PARAM_REPORTER)); applyQueryParams(query, queryParameters); IList <MetricIntervalValue> metrics; LongConverter longConverter = new LongConverter(); longConverter.ObjectMapper = objectMapper; if (queryParameters.getFirst(QUERY_PARAM_INTERVAL) != null) { long interval = longConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_INTERVAL)).Value; metrics = query.interval(interval); } else { metrics = query.interval(); } return(convertToDtos(metrics)); }
public void Setup() { _query = new MetricsQuery(); }
public MetricsQueryTests() { _query = new MetricsQuery(); _mapper = new DataMapper("v1"); }
public void Setup() { _query = new MetricsQuery(); _mapper = new DataMapper("v1"); }
public MetricsQueryTests() { _query = new MetricsQuery(); }