List knows whether it is last list in the history
authorMartin Rexa <martin.rexa@centrum.cz>
Wed, 13 Jan 2010 14:35:01 +0100
changeset 21092d4dbc49d7e
parent 209 bbb7d4f4e862
child 211 f861f40cabc3
List knows whether it is last list in the history
statistics/src/main/java/cz/xelfi/quoridor/statistics/resources/Elo.java
     1.1 --- a/statistics/src/main/java/cz/xelfi/quoridor/statistics/resources/Elo.java	Wed Jan 13 14:33:55 2010 +0100
     1.2 +++ b/statistics/src/main/java/cz/xelfi/quoridor/statistics/resources/Elo.java	Wed Jan 13 14:35:01 2010 +0100
     1.3 @@ -59,11 +59,11 @@
     1.4          GameStatus status = gId.getStatus();
     1.5          long modified = gId.getModified();
     1.6          if(current==0){
     1.7 -            current = modified;
     1.8 +            current = (modified / day) * day;
     1.9          }else if(modified - current > day){
    1.10              list = new EloList(list);
    1.11              listHistory.add(0,list);
    1.12 -            current = modified;
    1.13 +            current = (modified / day) * day;
    1.14          }
    1.15  
    1.16          if(status.equals(GameStatus.whiteWon)){
    1.17 @@ -84,7 +84,10 @@
    1.18      @Path("list/{id}")
    1.19      @Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
    1.20      public EloList getHistoryList(@PathParam("id") Integer id){
    1.21 -        EloList el = listHistory.get(id);
    1.22 +        if(id == null)
    1.23 +            return null;
    1.24 +        if(id >= listHistory.size())
    1.25 +            return null;
    1.26          return listHistory.get(id);
    1.27      }
    1.28