Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_karma
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv870/serendipity_event_karma
Modified Files:
serendipity_event_karma.php
Log Message:
fix karma entries - when link-click-tracking was enabled there could be more
than 1 entry in the table. should hopefully work now to never insert more
than 1 entry for a single id -- for BC of already counted entries the query
has been adjusted to a SUM/GROUP-query.
Index: serendipity_event_karma.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_karma/serendipity_event_karma.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- serendipity_event_karma.php 22 Jun 2004 13:45:44 -0000 1.8
+++ serendipity_event_karma.php 23 Jun 2004 15:55:57 -0000 1.9
@@ -289,7 +289,7 @@
return;
}
- if (($row['timestamp'] > ($now - $max_entrytime)) || ($row['lastvote'] + $max_votetime < $now)) {
+ if (($row['timestamp'] > ($now - $max_entrytime)) || ($row['lastvote'] + $max_votetime < $now) || $row['lastvote'] == 0) {
// Update votes
$q = sprintf(
"UPDATE {$serendipity['dbPrefix']}karma
@@ -522,10 +522,11 @@
return;
}
- $q = 'SELECT *
+ $q = 'SELECT SUM(votes) AS votes, SUM(points) AS points, SUM(visits) AS visits
FROM ' . $serendipity['dbPrefix'] . 'karma AS k
- WHERE k.entryid = ' . $entryid . ' LIMIT 1';
+ WHERE k.entryid = ' . $entryid . ' GROUP BY k.entryid LIMIT 1';
$row = serendipity_db_query($q, true);
+
if (empty($row['votes'])) {
$row['votes'] = 0;
}
@@ -555,6 +556,10 @@
}
// Fetch votes for all entry IDs. Store them in an array for later usage.
+ $q = 'SELECT SUM(votes) AS votes, SUM(points) AS points, SUM(visits) AS visits
+ FROM ' . $serendipity['dbPrefix'] . 'karma AS k
+ WHERE k.entryid IN (' . implode(', ', $entries) . ' GROUP BY k.entryid';
+
$q = 'SELECT *
FROM ' . $serendipity['dbPrefix'] . 'karma AS k
WHERE k.entryid IN (' . implode(', ', $entries) . ')';
|