changeset 3467:d62fd466d810

macro.PageHits: fixes multiple call of PageHits (MoinMoinBugs/ClickOnNavibarIncreasesHitsByMultiplicator)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 04 Apr 2008 23:09:44 +0200
parents 7bf716a48fc6
children ab35449c4708
files MoinMoin/macro/PageHits.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/PageHits.py	Fri Apr 04 23:05:53 2008 +0200
+++ b/MoinMoin/macro/PageHits.py	Fri Apr 04 23:09:44 2008 +0200
@@ -44,14 +44,14 @@
     def addHitsFromLog(self, hits, cacheDate):
         """ Parse the log, add hits after cacheDate and update the cache """
         event_log = eventlog.EventLog(self.request)
-        try:
-            logDate = event_log.date()
-        except logfile.LogMissing:
-            return
+        event_log.set_filter(['VIEWPAGE'])
 
         changed = False
-        event_log.set_filter(['VIEWPAGE'])
+        # don't use event_log.date()
+        latest = None
         for event in event_log.reverse():
+            if latest is None:
+                latest = event[0]
             if event[0] <= cacheDate:
                 break
             page = event[2].get('pagename', None)
@@ -60,7 +60,7 @@
                 changed = True
 
         if changed:
-            self.updateCache(logDate, hits)
+            self.updateCache(latest, hits)
 
     def updateCache(self, date, hits):
         try: