first commit

This commit is contained in:
2026-07-14 13:38:43 +07:00
commit 8b0e1ffffa
19 changed files with 836 additions and 0 deletions

32
app/filters.py Normal file
View File

@@ -0,0 +1,32 @@
from __future__ import annotations
from app.models import Offer
def get_offer_skip_reason(
offer: Offer,
include_keywords: list[str],
exclude_keywords: list[str],
min_price_amount: int | None,
) -> str | None:
haystack = f"{offer.title}\n{offer.description}".lower()
if exclude_keywords and any(keyword in haystack for keyword in exclude_keywords):
return "exclude_keyword"
if min_price_amount is not None and (offer.price_amount is None or offer.price_amount < min_price_amount):
return "min_price_amount"
if include_keywords and not any(keyword in haystack for keyword in include_keywords):
return "include_keyword"
return None
def is_relevant_offer(
offer: Offer,
include_keywords: list[str],
exclude_keywords: list[str],
min_price_amount: int | None,
) -> bool:
return get_offer_skip_reason(offer, include_keywords, exclude_keywords, min_price_amount) is None