|
|
@ -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; |
|
|
|