diff options
author | John H. Anthony <johnhant@gmail.com> | 2010-09-04 07:18:07 +0200 |
---|---|---|
committer | John H. Anthony <johnhant@gmail.com> | 2010-09-04 07:21:03 +0200 |
commit | b504b5fe05410bc259cd4349d1b51dc355eb0d90 (patch) | |
tree | 6bb722c781c4c244234a0b36fcb28f54c0ab417b /src/lq/Vote.java | |
parent | daa5375585d276e53aadcff670a4eba3ecf2279e (diff) |
store sum and number of votes in each quote
This seems to improve the response time. We don't store a list of
votes for each quote, which mean we don't have to retrieve every vote
when we get the list of quotes. The only time we need to access the
vote table is when we add a new vote.
Diffstat (limited to 'src/lq/Vote.java')
-rw-r--r-- | src/lq/Vote.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lq/Vote.java b/src/lq/Vote.java index 830b0cc..ee7c18d 100644 --- a/src/lq/Vote.java +++ b/src/lq/Vote.java @@ -15,6 +15,9 @@ public class Vote { private Key key; @Persistent + private Long quoteId; + + @Persistent private Long rating; @Persistent @@ -23,9 +26,10 @@ public class Vote { @Persistent private String ip; - public Vote(Long rating, String ip) { + public Vote(Long quoteId, Long rating, String ip) { this.ip = ip; this.rating = rating; + this.quoteId = quoteId; timestamp = new Date(); } @@ -33,9 +37,11 @@ public class Vote { public Date getTimestamp() { return timestamp; } public String getIp() { return ip; } public Long getRating() { return rating; } + public Long getQuoteId() { return quoteId; } public void setKey(Key key) { this.key = key; } public void setTimestamp(Date timestamp) { this.timestamp = timestamp; } public void setIp(String ip) { this.ip = ip; } public void setRating(Long rating) { this.rating = rating; } + public void setQuote(Long quoteId) { this.quoteId = quoteId; } } |