kopia lustrzana https://github.com/wagtail/wagtail
Minor python optimisation
rodzic
0b85b3a4eb
commit
bd4729144e
|
@ -189,6 +189,10 @@ class Index:
|
||||||
|
|
||||||
class PostgresSearchQueryCompiler(BaseSearchQueryCompiler):
|
class PostgresSearchQueryCompiler(BaseSearchQueryCompiler):
|
||||||
DEFAULT_OPERATOR = 'and'
|
DEFAULT_OPERATOR = 'and'
|
||||||
|
OPERATORS = {
|
||||||
|
'and': AND,
|
||||||
|
'or': OR,
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
@ -237,10 +241,7 @@ class PostgresSearchQueryCompiler(BaseSearchQueryCompiler):
|
||||||
if isinstance(query, PlainText):
|
if isinstance(query, PlainText):
|
||||||
self.check_boost(query, boost=boost)
|
self.check_boost(query, boost=boost)
|
||||||
|
|
||||||
operator = {
|
operator = self.OPERATORS[query.operator]
|
||||||
'and': AND,
|
|
||||||
'or': OR,
|
|
||||||
}[query.operator]
|
|
||||||
|
|
||||||
return operator([
|
return operator([
|
||||||
PostgresSearchQuery(unidecode(term), config=config)
|
PostgresSearchQuery(unidecode(term), config=config)
|
||||||
|
|
|
@ -13,6 +13,10 @@ from wagtail.search.utils import AND, OR
|
||||||
|
|
||||||
class DatabaseSearchQueryCompiler(BaseSearchQueryCompiler):
|
class DatabaseSearchQueryCompiler(BaseSearchQueryCompiler):
|
||||||
DEFAULT_OPERATOR = 'and'
|
DEFAULT_OPERATOR = 'and'
|
||||||
|
OPERATORS = {
|
||||||
|
'and': AND,
|
||||||
|
'or': OR,
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
@ -64,10 +68,7 @@ class DatabaseSearchQueryCompiler(BaseSearchQueryCompiler):
|
||||||
if isinstance(query, PlainText):
|
if isinstance(query, PlainText):
|
||||||
self.check_boost(query, boost=boost)
|
self.check_boost(query, boost=boost)
|
||||||
|
|
||||||
operator = {
|
operator = self.OPERATORS[query.operator]
|
||||||
'and': AND,
|
|
||||||
'or': OR,
|
|
||||||
}[query.operator]
|
|
||||||
|
|
||||||
return operator([
|
return operator([
|
||||||
self.build_single_term_filter(term)
|
self.build_single_term_filter(term)
|
||||||
|
|
Ładowanie…
Reference in New Issue