summaryrefslogtreecommitdiff
path: root/src/lq/ImportQuotes.java
diff options
context:
space:
mode:
authorJohn H. Anthony <johnhant@gmail.com>2010-09-04 07:18:07 +0200
committerJohn H. Anthony <johnhant@gmail.com>2010-09-04 07:21:03 +0200
commitb504b5fe05410bc259cd4349d1b51dc355eb0d90 (patch)
tree6bb722c781c4c244234a0b36fcb28f54c0ab417b /src/lq/ImportQuotes.java
parentdaa5375585d276e53aadcff670a4eba3ecf2279e (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/ImportQuotes.java')
-rw-r--r--src/lq/ImportQuotes.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lq/ImportQuotes.java b/src/lq/ImportQuotes.java
index 30ad811..d750b7b 100644
--- a/src/lq/ImportQuotes.java
+++ b/src/lq/ImportQuotes.java
@@ -148,9 +148,10 @@ public class ImportQuotes extends HttpServlet {
Date timestamp = lq.DateUtil.timestampFormat.parse(getChildWithName("time", voteRow));
String ip = getChildWithName("ip", voteRow);
- Vote vote = new Vote(rating, ip);
+ Vote vote = new Vote(quoteId, rating, ip);
vote.setTimestamp(timestamp);
- quote.getVotes().add(vote);
+ quote.setSumVotes(quote.getSumVotes() + rating);
+ quote.setNumVotes(quote.getNumVotes() + 1);
return vote;
}