fix 'all' filter failing
This commit is contained in:
parent
a9c08dea4d
commit
ca2037528d
@ -117,7 +117,7 @@ class ContentFilter(DjangoDataModel):
|
|||||||
|
|
||||||
def _match_all(self, matching_against: str):
|
def _match_all(self, matching_against: str):
|
||||||
for word in self.cleaned_matching_pattern:
|
for word in self.cleaned_matching_pattern:
|
||||||
if re.search(rf"\b{word}\b", matching_against, self._regex_flags):
|
if not re.search(rf"\b{word}\b", matching_against, self._regex_flags):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -170,14 +170,17 @@ class ContentFilter(DjangoDataModel):
|
|||||||
if not self.matching_pattern.strip():
|
if not self.matching_pattern.strip():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
algorithm_func = self._get_algorithm_func()
|
if self.matching_algorithm == MatchingAlgorithm.ALL:
|
||||||
if not algorithm_func:
|
match_found = self._match_all(content.item_title + " " + content.item_description)
|
||||||
log.error(f"Bad algorithm function: {self.matching_algorithm}")
|
else:
|
||||||
return False
|
algorithm_func = self._get_algorithm_func()
|
||||||
|
if not algorithm_func:
|
||||||
|
log.error(f"Bad algorithm function: {self.matching_algorithm}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
match_found = algorithm_func(content.item_title) or algorithm_func(content.item_description)
|
||||||
|
|
||||||
match_found = algorithm_func(content.item_title) or algorithm_func(content.item_description)
|
|
||||||
log.debug(f"filter match found: {match_found}")
|
log.debug(f"filter match found: {match_found}")
|
||||||
|
|
||||||
return not match_found if self.is_whitelist else match_found
|
return not match_found if self.is_whitelist else match_found
|
||||||
|
|
||||||
|
|
||||||
@ -356,6 +359,8 @@ class Content(DjangoDataModel):
|
|||||||
"subscription": self.subscription_id
|
"subscription": self.subscription_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.debug(f"params: {params}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = await client.get(
|
response = await client.get(
|
||||||
url=url,
|
url=url,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user