-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from hackathone-prosept-team2/feat/backup
Feat/backup
- Loading branch information
Showing
20 changed files
with
247 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
# YANDEX & PROSEPT HACKATHON: Сервис сопоставления товаров Просепт и наименований дилеров. Команда 2. | ||
http://81.31.246.5/ <br> | ||
http://81.31.246.5/backup/ - временный вход <br> | ||
http://81.31.246.5/<br> | ||
http://81.31.246.5/backup/ - прототип на Django-templates, пока не закончен основной фронтенд<br> | ||
данные для пробного входа на сайт и в админ-панель | ||
``` | ||
email: [email protected] | ||
password: Password-123 | ||
``` | ||
## Архивы и фото приложения | ||
## Описание | ||
Заказчик предоставил файлы csv: список своих товаров, список дилеров и результаты ежедневного парсинга сайтов дилеров с ценами.<br> | ||
*Проблема:*<br> | ||
Заказчику необходимо контролировать цены на свою продукцию на сайтах дилеров, но наименования на сайтах значительно отличаются от оригиналльных, и их приходится сопоставлять вручную, что очень трудоемко. Необходимо разработать сервис сопоставления наименований и подбора рекомендаций для операторов - вывод наиболее вероятных подходящих наименований.<br> | ||
*Решение:*<br> | ||
Бэкенд загружает данных цен; составляет список уникальных пар ключ(артикул)-дилер; проверяет, есть ли уже подтвержденные оператором товары; ключи без продукта отправляются на обработку в ML-сервис рекомендаций, который возвращает топ-10 наиболее вероятных совпадений.<br> | ||
Оператор может просмотреть список ключей, отфильтровать их по артикулу/наименованию, статусу и дилеру; открыть нужный ключ, выбрать подходящий товар и создать связь ключ-товар, либо пометить все товары как неподходящие.<br> | ||
Доступен отчет в разрезе дилеров со статистикой загрузки цен, уникальных ключей, с кол-вом ключей, которые надо проверить и количеством принятых решений (подошло/не подошло).<br> | ||
API позволяет выгрузить все пары ключ-товар с опциями "все новые"/"за период"/"в дату". | ||
|
||
## Фото приложения | ||
[Фото основных страниц](https://github.com/hackathone-prosept-team2/backend_django/tree/main/presentation) | ||
|
||
## FRONTEND: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from django.db.models import QuerySet, Q | ||
from django.http import HttpRequest | ||
|
||
from config.constants import MATCH_NUMBER | ||
|
||
from .models import DealerKey, Match | ||
|
||
|
||
def filter_keys( | ||
qs: QuerySet[DealerKey], request: HttpRequest | ||
) -> QuerySet[DealerKey]: | ||
"""Фильтрация списка ключей по наименованию/артикулу/статусу/дилеру.""" | ||
text = request.GET.get("text") | ||
status = request.GET.get("status") | ||
dealer = request.GET.get("dealer") | ||
|
||
if text: | ||
qs = qs.filter(Q(name__icontains=text) | Q(key__icontains=text)) | ||
if dealer: | ||
qs = qs.filter(dealer=dealer) | ||
if status: | ||
if status == Match.MatchStatus.YES: | ||
return qs.filter(product_id__isnull=False) | ||
if status == Match.MatchStatus.NO: | ||
return qs.filter(declined=MATCH_NUMBER) | ||
else: | ||
return qs.filter( | ||
product_id__isnull=True, declined__lt=MATCH_NUMBER | ||
) | ||
return qs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django import forms | ||
|
||
from .crud import list_dealers | ||
from .models import Match | ||
|
||
STATUS_CHOICES = [("", "---------")] + Match.MatchStatus.choices | ||
|
||
|
||
class FilterForm(forms.Form): | ||
text = forms.CharField(required=False) | ||
status = forms.ChoiceField(choices=STATUS_CHOICES, required=False) | ||
dealer = forms.ModelChoiceField(queryset=list_dealers(), required=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.urls import path | ||
|
||
from .views import DeleteAllPrices, ImportPrices | ||
|
||
app_name = "prices" | ||
|
||
urlpatterns = [ | ||
path("prices/import/", ImportPrices.as_view(), name="import_prices"), | ||
path("prices/delete/", DeleteAllPrices.as_view(), name="delete_prices"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from django.http import ( | ||
HttpRequest, | ||
HttpResponsePermanentRedirect, | ||
) | ||
from django.shortcuts import redirect | ||
from django.views import View | ||
|
||
from .crud import there_are_prices_in_db | ||
from .services import create_prices, delete_prices_and_relations | ||
|
||
|
||
class ImportPrices(View): | ||
"""Загрузка всех цен из стартового файла.""" | ||
|
||
def get( | ||
self, request: HttpRequest, *args, **kwargs | ||
) -> HttpResponsePermanentRedirect: | ||
if not there_are_prices_in_db(): | ||
create_prices() | ||
return redirect("dealers:index") | ||
|
||
|
||
class DeleteAllPrices(View): | ||
"""Удаление всех загруженных цен и принятых решений по подбору.""" | ||
|
||
def get( | ||
self, request: HttpRequest, *args, **kwargs | ||
) -> HttpResponsePermanentRedirect: | ||
delete_prices_and_relations() | ||
return redirect("dealers:index") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.