Minor python optimisation

pull/4682/head
Karl Hobley 2018-07-05 12:11:48 +01:00 zatwierdzone przez Matt Westcott
rodzic 0b85b3a4eb
commit bd4729144e
2 zmienionych plików z 10 dodań i 8 usunięć

Wyświetl plik

@ -189,6 +189,10 @@ class Index:
class PostgresSearchQueryCompiler(BaseSearchQueryCompiler):
DEFAULT_OPERATOR = 'and'
OPERATORS = {
'and': AND,
'or': OR,
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@ -237,10 +241,7 @@ class PostgresSearchQueryCompiler(BaseSearchQueryCompiler):
if isinstance(query, PlainText):
self.check_boost(query, boost=boost)
operator = {
'and': AND,
'or': OR,
}[query.operator]
operator = self.OPERATORS[query.operator]
return operator([
PostgresSearchQuery(unidecode(term), config=config)

Wyświetl plik

@ -13,6 +13,10 @@ from wagtail.search.utils import AND, OR
class DatabaseSearchQueryCompiler(BaseSearchQueryCompiler):
DEFAULT_OPERATOR = 'and'
OPERATORS = {
'and': AND,
'or': OR,
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@ -64,10 +68,7 @@ class DatabaseSearchQueryCompiler(BaseSearchQueryCompiler):
if isinstance(query, PlainText):
self.check_boost(query, boost=boost)
operator = {
'and': AND,
'or': OR,
}[query.operator]
operator = self.OPERATORS[query.operator]
return operator([
self.build_single_term_filter(term)