Remove web-history-max-items.

This was a performance optimization that shouldn't be needed with the new SQL
history backend. This also removes support for the LIMIT feature from SqlTable
as it only existed to support web-history-max-items.
This commit is contained in:
Ryan Roden-Corrent 2017-02-22 21:12:23 -05:00
parent 99c9b2d396
commit 921211bbaa
6 changed files with 10 additions and 32 deletions

View File

@ -31,7 +31,7 @@ from qutebrowser.misc import sql
class _SqlCompletionCategory(QSqlQueryModel):
"""Wraps a SqlQuery for use as a completion category."""
def __init__(self, name, *, sort_by, sort_order, limit, select, where,
def __init__(self, name, *, sort_by, sort_order, select, where,
columns_to_filter, parent=None):
super().__init__(parent=parent)
self.tablename = name
@ -52,9 +52,6 @@ class _SqlCompletionCategory(QSqlQueryModel):
assert sort_order == 'asc' or sort_order == 'desc'
querystr += ' order by {} {}'.format(sort_by, sort_order)
if limit:
querystr += ' limit {}'.format(limit)
self._querystr = querystr
self.set_pattern('%')
@ -106,7 +103,7 @@ class SqlCompletionModel(QAbstractItemModel):
return None
def new_category(self, name, *, select='*', where=None, sort_by=None,
sort_order=None, limit=None):
sort_order=None):
"""Create a new completion category and add it to this model.
Args:
@ -115,12 +112,11 @@ class SqlCompletionModel(QAbstractItemModel):
where: An optional clause to filter out some rows.
sort_by: The name of the field to sort by, or None for no sorting.
sort_order: Either 'asc' or 'desc', if sort_by is non-None
limit: Maximum row count to return on a query.
Return: A new CompletionCategory.
"""
cat = _SqlCompletionCategory(name, parent=self, sort_by=sort_by,
sort_order=sort_order, limit=limit,
sort_order=sort_order,
select=select, where=where,
columns_to_filter=self.columns_to_filter)
self._categories.append(cat)

View File

@ -64,13 +64,12 @@ def url():
model = sqlmodel.SqlCompletionModel(column_widths=(40, 50, 10),
columns_to_filter=[_URLCOL, _TEXTCOL],
delete_cur_item=_delete_url)
limit = config.get('completion', 'web-history-max-items')
timefmt = config.get('completion', 'timestamp-format')
select_time = "strftime('{}', atime, 'unixepoch')".format(timefmt)
model.new_category('Quickmarks', select='url, name')
model.new_category('Bookmarks')
model.new_category('History',
limit=limit, sort_order='desc', sort_by='atime',
sort_order='desc', sort_by='atime',
select='url, title, {}'.format(select_time),
where='not redirect')
return model

View File

@ -414,6 +414,7 @@ class ConfigManager(QObject):
('storage', 'offline-storage-default-quota'),
('storage', 'offline-web-application-cache-quota'),
('content', 'css-regions'),
('completion', 'web-history-max-items'),
]
CHANGED_OPTIONS = {
('content', 'cookies-accept'):

View File

@ -506,11 +506,6 @@ def data(readonly=False):
"How many commands to save in the command history.\n\n"
"0: no history / -1: unlimited"),
('web-history-max-items',
SettingValue(typ.Int(minval=-1), '1000'),
"How many URLs to show in the web history.\n\n"
"0: no history / -1: unlimited"),
('quick-complete',
SettingValue(typ.Bool(), 'true'),
"Whether to move on to the next part when there's only one "

View File

@ -274,13 +274,10 @@ def test_url_completion(qtmodeltester, config_stub, web_history, quickmarks,
Verify that:
- quickmarks, bookmarks, and urls are included
- no more than 'web-history-max-items' items are included (TODO)
- the most recent entries are included
- entries are sorted by access time
- redirect entries are not included
"""
# TODO: time formatting and item limiting
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d',
'web-history-max-items': 2}
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d'}
model = urlmodel.url()
qtmodeltester.data_display_may_return_none = True
qtmodeltester.check(model)
@ -299,6 +296,7 @@ def test_url_completion(qtmodeltester, config_stub, web_history, quickmarks,
"History": [
('https://github.com', 'https://github.com', '2016-05-01'),
('https://python.org', 'Welcome to Python.org', '2016-03-08'),
('http://qutebrowser.org', 'qutebrowser', '2015-09-05'),
],
})
@ -307,8 +305,7 @@ def test_url_completion_delete_bookmark(qtmodeltester, config_stub,
web_history, quickmarks, bookmarks,
qtbot):
"""Test deleting a bookmark from the url completion model."""
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d',
'web-history-max-items': 2}
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d'}
model = urlmodel.url()
qtmodeltester.data_display_may_return_none = True
qtmodeltester.check(model)
@ -325,8 +322,7 @@ def test_url_completion_delete_quickmark(qtmodeltester, config_stub,
web_history, quickmarks, bookmarks,
qtbot):
"""Test deleting a bookmark from the url completion model."""
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d',
'web-history-max-items': 2}
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d'}
model = urlmodel.url()
qtmodeltester.data_display_may_return_none = True
qtmodeltester.check(model)

View File

@ -206,15 +206,6 @@ def test_first_last_item(data, first, last):
assert model.data(model.last_item()) == last
def test_limit():
table = sql.SqlTable('test_limit', ['a'], primary_key='a')
for i in range(5):
table.insert([i])
model = sqlmodel.SqlCompletionModel()
model.new_category('test_limit', limit=3)
assert model.count() == 3
def test_select():
table = sql.SqlTable('test_select', ['a', 'b', 'c'], primary_key='a')
table.insert(['foo', 'bar', 'baz'])