http-service: change pbs from int to double

This commit is contained in:
Hydrox6
2021-02-24 17:31:15 +00:00
committed by Adam
parent 02025f9d8f
commit 33cdd85ee7
3 changed files with 11 additions and 11 deletions

View File

@@ -179,14 +179,14 @@ public class ChatClient
} }
} }
public boolean submitPb(String username, String boss, int pb) throws IOException public boolean submitPb(String username, String boss, double pb) throws IOException
{ {
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("chat") .addPathSegment("chat")
.addPathSegment("pb") .addPathSegment("pb")
.addQueryParameter("name", username) .addQueryParameter("name", username)
.addQueryParameter("boss", boss) .addQueryParameter("boss", boss)
.addQueryParameter("pb", Integer.toString(pb)) .addQueryParameter("pb", Double.toString(pb))
.build(); .build();
Request request = new Request.Builder() Request request = new Request.Builder()
@@ -200,7 +200,7 @@ public class ChatClient
} }
} }
public int getPb(String username, String boss) throws IOException public double getPb(String username, String boss) throws IOException
{ {
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("chat") .addPathSegment("chat")
@@ -219,7 +219,7 @@ public class ChatClient
{ {
throw new IOException("Unable to look up personal best!"); throw new IOException("Unable to look up personal best!");
} }
return Integer.parseInt(response.body().string()); return Double.parseDouble(response.body().string());
} }
} }

View File

@@ -173,7 +173,7 @@ public class ChatController
} }
@PostMapping("/pb") @PostMapping("/pb")
public void submitPb(@RequestParam String name, @RequestParam String boss, @RequestParam int pb) public void submitPb(@RequestParam String name, @RequestParam String boss, @RequestParam double pb)
{ {
if (pb < 0) if (pb < 0)
{ {
@@ -184,9 +184,9 @@ public class ChatController
} }
@GetMapping("/pb") @GetMapping("/pb")
public int getPb(@RequestParam String name, @RequestParam String boss) public double getPb(@RequestParam String name, @RequestParam String boss)
{ {
Integer pb = chatService.getPb(name, boss); Double pb = chatService.getPb(name, boss);
if (pb == null) if (pb == null)
{ {
throw new NotFoundException(); throw new NotFoundException();

View File

@@ -127,21 +127,21 @@ public class ChatService
} }
} }
public Integer getPb(String name, String boss) public Double getPb(String name, String boss)
{ {
String value; String value;
try (Jedis jedis = jedisPool.getResource()) try (Jedis jedis = jedisPool.getResource())
{ {
value = jedis.get("pb." + boss + "." + name); value = jedis.get("pb." + boss + "." + name);
} }
return value == null ? null : Integer.parseInt(value); return value == null ? null : Double.parseDouble(value);
} }
public void setPb(String name, String boss, int pb) public void setPb(String name, String boss, double pb)
{ {
try (Jedis jedis = jedisPool.getResource()) try (Jedis jedis = jedisPool.getResource())
{ {
jedis.setex("pb." + boss + "." + name, (int) EXPIRE.getSeconds(), Integer.toString(pb)); jedis.setex("pb." + boss + "." + name, (int) EXPIRE.getSeconds(), Double.toString(pb));
} }
} }