Browse Source

response time

master
gsd 2 years ago
parent
commit
2cbcaf7b47
  1. 2
      src/main/java/app/entities/PlayerProfile.java
  2. 13
      src/main/java/app/services/ProfileService.java

2
src/main/java/app/entities/PlayerProfile.java

@ -14,7 +14,7 @@ public class PlayerProfile {
HashMap<String, HashMap<String, BigDecimal>> gametime;
HashMap<String, HashMap<String, Long>> lastplay;
Object permition;
HashMap<String, Long> response_time;
HashMap<String, Double> response_time;
SteamData steam_data;
SteamID steamids;
}

13
src/main/java/app/services/ProfileService.java

@ -8,7 +8,9 @@ import app.utils.SteamIDConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.Instant;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@Service
@ -24,19 +26,30 @@ public class ProfileService {
public PlayerProfile GetProfile(String steam64, List<String> requests) {
PlayerProfile profile = new PlayerProfile();
profile.setResponse_time(new HashMap<>());
SteamID steamID = SteamIDConverter.getSteamID(steam64);
profile.setSteamids(steamID);
Long start_time, end_time;
if(requests.contains("steam_data")){
start_time = Instant.now().toEpochMilli();
profile.setSteam_data(steamWebApi.getSteamData(steamID.steam64));
end_time = Instant.now().toEpochMilli() - start_time;
profile.getResponse_time().put("steam_data", Double.valueOf(end_time) / 1000);
}
if(requests.contains("lastplay")){
start_time = Instant.now().toEpochMilli();
profile.setLastplay(usertimeService.getPlayerLastplay(profile.getSteamids()));
end_time = Instant.now().toEpochMilli() - start_time;
profile.getResponse_time().put("lastplay", Double.valueOf(end_time) / 1000);
}
if(requests.contains("usertime")){
start_time = Instant.now().toEpochMilli();
profile.setGametime(usertimeService.getPlayerUsertime(profile.getSteamids()));
end_time = Instant.now().toEpochMilli() - start_time;
profile.getResponse_time().put("usertime", Double.valueOf(end_time) / 1000);
}
return profile;

Loading…
Cancel
Save