Browse Source

preview fix

master
gsd 1 year ago
parent
commit
67fc107a82
  1. 5
      src/main/java/app/entities/server/Server.java
  2. 14
      src/main/java/app/updates/PreviewUpdater.java

5
src/main/java/app/entities/server/Server.java

@ -63,6 +63,11 @@ public class Server extends ExternalValveClient {
} }
} }
@JsonIgnore
public String getMapCleared() {
return map == null || map.isEmpty() ? "" : map.replace("workshop/","").split(".ugc")[0];
}
@Override @Override
public String toString() { public String toString() {
return "SERVER> %s | %s\nSTATS > %d/%d | %s\nCONFIG> grab limit: %d".formatted( return "SERVER> %s | %s\nSTATS > %d/%d | %s\nCONFIG> grab limit: %d".formatted(

14
src/main/java/app/updates/PreviewUpdater.java

@ -22,8 +22,8 @@ public class PreviewUpdater extends BaseUpdater{
private String domain = "tf2.pblr-nyk.pro"; private String domain = "tf2.pblr-nyk.pro";
private String preview = "https://%s/site_content/images/preview/%s.%s"; private String preview = "https://%s/site_content/images/preview/%s.%s";
@Value("${backend.updates.a2s}") //@Value("${backend.updates.a2s}")
private boolean update = false; private boolean update = true;
private HashMap<String, String> preview_cache; private HashMap<String, String> preview_cache;
@Autowired @Autowired
@ -53,16 +53,16 @@ public class PreviewUpdater extends BaseUpdater{
return; return;
} }
if (preview_cache.containsKey(server.getMap())) { if (preview_cache.containsKey(server.getMapCleared())) {
if (preview_cache.get(server.getMap()).equals(server.getPreview())) return; if (preview_cache.get(server.getMapCleared()).equals(server.getPreview())) return;
} }
String url = getPreview(server.getMap()); String url = getPreview(server.getMapCleared());
if (url != null) { if (url != null) {
server.setPreview(url); server.setPreview(url);
preview_cache.put(server.getMap(), server.getPreview()); preview_cache.put(server.getMapCleared(), server.getPreview());
} else { } else {
logger.warn("Not found preview for {}", server.getMap()); logger.warn("Not found preview for {}", server.getMapCleared());
server.setPreview(not_found()); server.setPreview(not_found());
} }
} }

Loading…
Cancel
Save