backend/app/search/services/hints.py

13 lines
520 B
Python
Raw Normal View History

2022-10-21 23:57:39 +03:00
from search.models import Product, Category, Characteristic
2022-10-21 23:37:26 +03:00
def get_hints(content: str) -> str:
category = 'Unknown'
if content in list(map(lambda product: product.name, Product.objects.all())):
category = 'Name'
2022-10-21 23:57:39 +03:00
elif content in list(map(lambda category: category.name, Category.objects.all())):
category = 'Category'
elif content in list(map(lambda char: char.value, Characteristic.objects.all())):
category = Characteristic.objects.get(value=content).name
2022-10-21 23:37:26 +03:00
return category