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:
|
2022-10-22 18:21:42 +03:00
|
|
|
category = "All"
|
2022-10-21 23:37:26 +03:00
|
|
|
if content in list(map(lambda product: product.name, Product.objects.all())):
|
2022-10-22 05:07:25 +03:00
|
|
|
category = "Name"
|
2022-10-21 23:57:39 +03:00
|
|
|
elif content in list(map(lambda category: category.name, Category.objects.all())):
|
2022-10-22 05:07:25 +03:00
|
|
|
category = "Category"
|
2022-10-21 23:57:39 +03:00
|
|
|
elif content in list(map(lambda char: char.value, Characteristic.objects.all())):
|
2022-10-22 11:43:30 +03:00
|
|
|
category = Characteristic.objects.filter(value=content).first().name
|
2022-10-21 23:37:26 +03:00
|
|
|
return category
|