Commit 608b6f10 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

get() method supports reading entries from multiple days

If days_ago argument is undefined (as is the case when performing
a "last few callers" query/list), then pull upto the maximum last
number of callers from previous days as necessary.

Part of fix for issue #371
parent 0df5ae92
...@@ -51,7 +51,24 @@ function get(num, days_ago) ...@@ -51,7 +51,24 @@ function get(num, days_ago)
if(!this.json_lines) if(!this.json_lines)
this.json_lines = load({}, "json_lines.js"); this.json_lines = load({}, "json_lines.js");
return json_lines.get(filename(days_ago), num); var result = json_lines.get(filename(days_ago), num);
if(days_ago !== undefined || typeof result !== 'object')
return result;
if(num < 0)
num += result.length;
else
num -= result.length;
for(days_ago = 1; num != 0; days_ago++) {
var more = json_lines.get(filename(days_ago), num);
if(typeof more !== 'object')
break;
result.push.apply(result, more);
if(num < 0)
num += more.length;
else
num -= more.length;
}
return result;
} }
function maint(backup_level) function maint(backup_level)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment