Fix qute://history SQL bug.
The javascript history page was requesting the new start_time in ms, but the python code was expecting seconds. This is fixed by removing all the millisecond translations in the python code and only translating to milliseconds in the javascript code that formats dates.
This commit is contained in:
parent
1aed2470e5
commit
8745f80d90
@ -192,6 +192,8 @@ def history_data(start_time, offset=None):
|
||||
start_time: select history starting from this timestamp.
|
||||
offset: number of items to skip
|
||||
"""
|
||||
# history atimes are stored as ints, ensure start_time is not a float
|
||||
start_time = int(start_time)
|
||||
hist = objreg.get('web-history')
|
||||
if offset is not None:
|
||||
entries = hist.entries_before(start_time, limit=1000, offset=offset)
|
||||
@ -200,7 +202,7 @@ def history_data(start_time, offset=None):
|
||||
end_time = start_time - 24*60*60
|
||||
entries = hist.entries_between(end_time, start_time)
|
||||
|
||||
return [{"url": e.url, "title": e.title or e.url, "time": e.atime * 1000}
|
||||
return [{"url": e.url, "title": e.title or e.url, "time": e.atime}
|
||||
for e in entries]
|
||||
|
||||
|
||||
@ -252,7 +254,7 @@ def qute_history(url):
|
||||
start_time = time.mktime(next_date.timetuple()) - 1
|
||||
history = [
|
||||
(i["url"], i["title"],
|
||||
datetime.datetime.fromtimestamp(i["time"]/1000),
|
||||
datetime.datetime.fromtimestamp(i["time"]),
|
||||
QUrl(i["url"]).host())
|
||||
for i in history_data(start_time)
|
||||
]
|
||||
|
@ -174,7 +174,8 @@ window.loadHistory = (function() {
|
||||
|
||||
for (var i = 0, len = history.length; i < len; i++) {
|
||||
var item = history[i];
|
||||
var currentItemDate = new Date(item.time);
|
||||
// python's time.time returns seconds, but js Date expects ms
|
||||
var currentItemDate = new Date(item.time * 1000);
|
||||
getSessionNode(currentItemDate).appendChild(makeHistoryRow(
|
||||
item.url, item.title, currentItemDate.toLocaleTimeString()
|
||||
));
|
||||
|
@ -129,8 +129,8 @@ class TestHistoryHandler:
|
||||
# test times
|
||||
end_time = start_time - 24*60*60
|
||||
for item in items:
|
||||
assert item['time'] <= start_time * 1000
|
||||
assert item['time'] > end_time * 1000
|
||||
assert item['time'] <= start_time
|
||||
assert item['time'] > end_time
|
||||
|
||||
def test_qute_history_benchmark(self, fake_web_history, benchmark, now):
|
||||
r = range(100000)
|
||||
|
Loading…
Reference in New Issue
Block a user