sort tiles on the dashboard
This commit is contained in:
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -24,8 +25,8 @@ import org.lucares.pdbui.domain.AutocompleteProposalByValue;
|
||||
import org.lucares.pdbui.domain.AutocompleteResponse;
|
||||
import org.lucares.pdbui.domain.PlotRequest;
|
||||
import org.lucares.pdbui.domain.PlotResponse;
|
||||
import org.lucares.pdbui.domain.PlotResponseStats;
|
||||
import org.lucares.performance.db.PerformanceDb;
|
||||
import org.lucares.recommind.logs.DataSeries;
|
||||
import org.lucares.recommind.logs.InternalPlottingException;
|
||||
import org.lucares.recommind.logs.NoDataPointsException;
|
||||
import org.lucares.recommind.logs.PlotResult;
|
||||
@@ -94,7 +95,7 @@ public class PdbController implements HardcodedValues {
|
||||
|
||||
// TODO the UI should cancel requests that are in flight before sending a plot
|
||||
// request
|
||||
if (plotterLock.tryLock()) {
|
||||
if (plotterLock.tryLock(5, TimeUnit.SECONDS)) {
|
||||
try {
|
||||
final PlotResult result = plotter.plot(plotSettings);
|
||||
|
||||
@@ -105,7 +106,8 @@ public class PdbController implements HardcodedValues {
|
||||
? WEB_IMAGE_OUTPUT_PATH + "/" + result.getThumbnailName()
|
||||
: imageUrl;
|
||||
|
||||
return new PlotResponse(DataSeries.toMap(result.getDataSeries()), imageUrl, thumbnailUrl);
|
||||
final PlotResponseStats stats = PlotResponseStats.fromDataSeries(result.getDataSeries());
|
||||
return new PlotResponse(stats, imageUrl, thumbnailUrl);
|
||||
} catch (final NoDataPointsException e) {
|
||||
throw new NotFoundException(e);
|
||||
} finally {
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class PlotResponse {
|
||||
private String imageUrl = "";
|
||||
private Map<String, Integer> dataSeries;
|
||||
private final String thumbnailUrl;
|
||||
private PlotResponseStats stats;
|
||||
private String thumbnailUrl;
|
||||
|
||||
public PlotResponse(final Map<String, Integer> dataSeries, final String imageUrl, final String thumbnailUrl) {
|
||||
this.dataSeries = dataSeries;
|
||||
public PlotResponse(final PlotResponseStats stats, final String imageUrl, final String thumbnailUrl) {
|
||||
this.stats = stats;
|
||||
this.imageUrl = imageUrl;
|
||||
this.thumbnailUrl = thumbnailUrl;
|
||||
}
|
||||
@@ -25,16 +23,21 @@ public class PlotResponse {
|
||||
return thumbnailUrl;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getDataSeries() {
|
||||
return dataSeries;
|
||||
public PlotResponseStats getStats() {
|
||||
return stats;
|
||||
}
|
||||
|
||||
public void setDataSeries(final Map<String, Integer> dataSeries) {
|
||||
this.dataSeries = dataSeries;
|
||||
public void setStats(final PlotResponseStats stats) {
|
||||
this.stats = stats;
|
||||
}
|
||||
|
||||
public void setThumbnailUrl(final String thumbnailUrl) {
|
||||
this.thumbnailUrl = thumbnailUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return imageUrl + " " + dataSeries + " " + thumbnailUrl;
|
||||
return "PlotResponse [imageUrl=" + imageUrl + ", stats=" + stats + ", thumbnailUrl=" + thumbnailUrl + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.lucares.recommind.logs.DataSeries;
|
||||
|
||||
public class PlotResponseStats {
|
||||
private long maxValue;
|
||||
|
||||
private int values;
|
||||
|
||||
public PlotResponseStats() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PlotResponseStats(final long maxValue, final int values) {
|
||||
|
||||
this.maxValue = maxValue;
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public long getMaxValue() {
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
public void setMaxValue(final long maxValue) {
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public int getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(final int values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PlotResponseStats [maxValue=" + maxValue + ", values=" + values + "]";
|
||||
}
|
||||
|
||||
public static PlotResponseStats fromDataSeries(final List<DataSeries> dataSeries) {
|
||||
|
||||
int values = 0;
|
||||
long maxValue = 0;
|
||||
|
||||
for (final DataSeries dataSerie : dataSeries) {
|
||||
values += dataSerie.getValues();
|
||||
maxValue = Math.max(maxValue, dataSerie.getMaxValue());
|
||||
}
|
||||
|
||||
return new PlotResponseStats(maxValue, values);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user