Skip to content

Commit

Permalink
[IT-2798] Add connectivity profile to time series endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSteger authored and j0weiss committed Sep 23, 2019
1 parent d1571f6 commit b57679a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class LineChartTimeSeriesService {
if (cmd.browsers) {
browsers = Browser.findAllByIdInList(cmd.browsers)
}
List<ConnectivityProfile> connectivityProfiles = null
if (cmd.connectivities) {
connectivityProfiles = ConnectivityProfile.findAllByIdInList(cmd.connectivities)
}
List<SelectedMeasurand> measurands = null
if (cmd.measurands) {
measurands = cmd.measurands.collect { new SelectedMeasurand(it, CachedView.UNCACHED) }.unique()
Expand All @@ -53,11 +57,8 @@ class LineChartTimeSeriesService {
performanceAspectTypes = cmd.performanceAspectTypes.collect{it.toString().toUpperCase() as PerformanceAspectType}.unique()
}


print(performanceAspectTypes)

List<EventResultProjection> eventResultProjections = getResultProjections(cmd, from, to, measurands, performanceAspectTypes)
return buildDTO(eventResultProjections, jobGroups, measuredEvents, pages, locations, browsers, measurands, performanceAspectTypes)
return buildDTO(eventResultProjections, jobGroups, measuredEvents, pages, locations, browsers, connectivityProfiles, measurands, performanceAspectTypes)
}

private List<EventResultProjection> getResultProjections(GetLinechartCommand cmd, Date from, Date to, List<SelectedMeasurand> measurands, List<PerformanceAspectType> performanceAspectTypes) {
Expand All @@ -69,7 +70,7 @@ class LineChartTimeSeriesService {
.withPageIdsIn(cmd.pages as List)
.withLocationIdsIn(cmd.locations as List)
.withBrowserIdsIn(cmd.browsers as List)
// .withConnectivity()
.withConnectivity(cmd.connectivities as List, null, false)
.withSelectedMeasurands(measurands)
}
if (performanceAspectTypes) {
Expand All @@ -86,8 +87,8 @@ class LineChartTimeSeriesService {

private TimeSeriesChartDTO buildDTO(List<EventResultProjection> eventResultProjections, List<JobGroup> jobGroups,
List<MeasuredEvent> measuredEvents, List<Page> pages, List<Location> locations,
List<Browser> browsers, List<SelectedMeasurand> measurands,
List<PerformanceAspectType> performanceAspectTypes) {
List<Browser> browsers, List<ConnectivityProfile> connectivityProfiles,
List<SelectedMeasurand> measurands, List<PerformanceAspectType> performanceAspectTypes) {
TimeSeriesChartDTO timeSeriesChartDTO = new TimeSeriesChartDTO()
performanceLoggingService.logExecutionTime(DEBUG, "create DTO for TimeSeriesChart", 1) {
eventResultProjections.each { EventResultProjection eventResultProjection ->
Expand All @@ -111,20 +112,24 @@ class LineChartTimeSeriesService {
identifier += " | ${location?.uniqueIdentifierForServer}"
}
ConnectivityProfile connectivity
if (connectivityProfiles) {
connectivity = (ConnectivityProfile) connectivityProfiles.find { connectivityProfile -> connectivityProfile.name == eventResultProjection.connectivityProfile }
identifier += " | ${connectivity?.name}"
}

measurands.each { measurand ->
String dataBaseRelevantName = measurand.getDatabaseRelevantName()
String measurandName = measurand.getName()
Double value = (Double) eventResultProjection.projectedProperties."$dataBaseRelevantName"
String identifierMeasurand = "$measurandName | " + identifier
buildSeries(value, identifierMeasurand, date, jobGroup, measuredEvent, location, timeSeriesChartDTO)
Double value = (Double) eventResultProjection."$dataBaseRelevantName"
String identifierMeasurand = identifier + " | $measurandName"
buildSeries(value, identifierMeasurand, date, jobGroup, measuredEvent, location, connectivity, timeSeriesChartDTO)
timeSeriesChartDTO.series.find{ it.identifier == identifierMeasurand }.measurand = measurandName
}

performanceAspectTypes.each { performanceAspectType ->
Double value = (Double) eventResultProjection.projectedProperties."$performanceAspectType"
String identifierAspect = "$performanceAspectType | " + identifier
buildSeries(value, identifierAspect, date, jobGroup, measuredEvent, location, timeSeriesChartDTO)
Double value = (Double) eventResultProjection."$performanceAspectType"
String identifierAspect = identifier + " | $performanceAspectType"
buildSeries(value, identifierAspect, date, jobGroup, measuredEvent, location, connectivity, timeSeriesChartDTO)
timeSeriesChartDTO.series.find{ it.identifier == identifierAspect }.performanceAspectType = performanceAspectType.toString()
}
}
Expand All @@ -138,7 +143,7 @@ class LineChartTimeSeriesService {
}

private void buildSeries(Double value, String identifier, Date date, JobGroup jobGroup, MeasuredEvent measuredEvent,
Location location, TimeSeriesChartDTO timeSeriesChartDTO){
Location location, ConnectivityProfile connectivity, TimeSeriesChartDTO timeSeriesChartDTO) {
TimeSeries timeSeries = timeSeriesChartDTO.series.find({ it.identifier == identifier })
if (!timeSeries) {
timeSeries = new TimeSeries(
Expand All @@ -151,6 +156,9 @@ class LineChartTimeSeriesService {
if (location) {
timeSeries.setLocation(location.label)
}
if (connectivity) {
timeSeries.setConnectivity(connectivity.name)
}
timeSeriesChartDTO.series.add(timeSeries)
}
TimeSeriesDataPoint timeSeriesDataPoint = new TimeSeriesDataPoint(date: date, value: value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class TimeSeries {
String jobGroup = ""
String measuredEvent = ""
String location = ""
String connectivity = ""
String measurand = ""
String performanceAspectType = ""
List<TimeSeriesDataPoint> data = []
Expand Down

0 comments on commit b57679a

Please sign in to comment.