Commit dab25bc4 authored by Drahomír Karchňák's avatar Drahomír Karchňák

Fixed provider name on exported banner images.

parent 36366cc5
......@@ -31,6 +31,8 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
......@@ -154,19 +156,16 @@ public class ImageExport extends ServerResource {
final double download = ((double) rs.getInt("download_kbit")) / 1000;
final double upload = ((double) rs.getInt("upload_kbit")) / 1000;
final double ping = rs.getFloat("ping_ms");
final String isp = rs.getString("provider_name");
final String typ = rs.getString("network_type");
final String signal = rs.getString("signal_strength");
final String os = rs.getString("platform");
final Timestamp time = rs.getTimestamp("time");
final String networkName = rs.getString("network_name");
final String publicName = rs.getString("public_name");
final String providerName = rs.getString("provider_name");
final String networkName = rs.getString("network_name");
final String publicName = rs.getString("public_name");
final StringBuilder test = new StringBuilder();
test.append(isp).append(", ");
test.append(networkName).append(", ");
test.append(publicName);
final String isp = getProviderName(providerName, networkName, publicName);
final OutputRepresentation result = new OutputRepresentation(MediaType.IMAGE_PNG) {
@Override
......@@ -192,7 +191,7 @@ public class ImageExport extends ServerResource {
upload,
download,
ping,
test.toString(),
isp,
typ,
signal,
os,
......@@ -213,6 +212,25 @@ public class ImageExport extends ServerResource {
return new StringRepresentation("invalid uuid");
}
}
private String getProviderName(String providerName, String networkName, String publicName) {
if(providerName != null) return providerName;
if(networkName != null) return networkName;
if(publicName != null){
//publicName example: TMOBILE-CZ T-Mobile Czech Republic a.s.,CZ
Pattern pattern = Pattern.compile("\\S+\\s(.+),");
Matcher matcher = pattern.matcher(publicName);
if(matcher.find()) {
return matcher.group();
} else {
return publicName;
}
}
return null;
}
public class ForumBannerSmallGenerator extends AbstractImageGenerator {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment