--- a/handlers.py Tue Feb 10 01:05:35 2009 +0200
+++ b/handlers.py Tue Feb 10 01:24:59 2009 +0200
@@ -87,8 +87,8 @@
lines = lines,
)
-@preferences.handler(prefs.formatter, prefs.timezone)
-def channel_link (request, channel, timestamp, formatter, timezone) :
+@preferences.handler(prefs.formatter, prefs.timezone, prefs.count)
+def channel_link (request, channel, timestamp, formatter, timezone, count) :
"""
Display channel_date for specific UTC timestamp
"""
@@ -96,8 +96,8 @@
# convert timestamp to user's timezone
timestamp = timestamp.astimezone(timezone)
- # get latest events
- lines = channel.source.get_date(timestamp)
+ # get correct day's correct page of lines
+ page, max, lines = channel.source.get_date_paged(timestamp, count)
# lines
lines = formatter.format_html(lines)
@@ -108,6 +108,9 @@
prefs = request.prefs,
channel = channel,
date = timestamp,
+ page = page,
+ count = count,
+ max = max,
lines = lines,
)
@@ -149,7 +152,7 @@
# fix date timezone
date = date.replace(tzinfo=timezone)
- # get latest events
+ # get that day's events, either paged or not
if page :
page, max, lines = channel.source.get_date_paged(date, count, page)
--- a/log_source.py Tue Feb 10 01:05:35 2009 +0200
+++ b/log_source.py Tue Feb 10 01:24:59 2009 +0200
@@ -42,6 +42,15 @@
else :
skip = None
+ # go through the logs a page at a time
+ this_page = 1
+
+ # last line's timestamp
+ last_ts = None
+
+ # found it yet?
+ found = False
+
# count the full number of lines
line_count = 0
@@ -57,11 +66,31 @@
if skip :
skip -= 1
continue
-
- # already full?
- if len(lines) > count :
- continue
-
+
+ # is this page all that we want/need?
+ if page or found :
+ # already full?
+ if len(lines) >= count :
+ continue
+
+ # specfic timestamp
+ else :
+ # didn't find it in this page?
+ if len(lines) >= count :
+ # reset to next page
+ lines = []
+ this_page += 1
+
+ # is dt between these two timestamps?
+ if (not last_ts or last_ts <= dt) and (dt <= line.timestamp) :
+ # found!
+ found = True
+ page = this_page
+
+ else :
+ # keep looking
+ last_ts = line.timestamp
+
# store line
lines.append(line)