fix response

This commit is contained in:
Bartosz Karwacki 2022-01-23 12:15:33 +01:00
parent fa8c039f49
commit 0133f5dbae
5 changed files with 19219 additions and 20 deletions

View File

@ -1,3 +1,5 @@
from django.contrib import admin
from .models import Car
admin.site.register(Car)
# Register your models here.

View File

@ -30,18 +30,18 @@ def get_fuzzy_response(request_params, objects_list):
# Obliczanie przynaleznosci danego obiektu do podanych danych kwerendy i tworzenie przefiltrowanej listy
end_object_list = []
for i in objects_list:
for car in objects_list:
comparator = []
if 'production_year' in request_params:
comparator.append(fuzz.interp_membership(production_year.universe, production_year[str(request_params['production_year'])].mf, i['production_year']))
comparator.append(fuzz.interp_membership(production_year.universe, production_year[str(request_params['production_year'])].mf, car.production_year))
if 'mileage' in request_params:
comparator.append(fuzz.interp_membership(mileage.universe, mileage[str(request_params['mileage'])].mf, i['mileage']))
comparator.append(fuzz.interp_membership(mileage.universe, mileage[str(request_params['mileage'])].mf, car.mileage))
if 'engine_capacity' in request_params:
comparator.append(fuzz.interp_membership(engine_capacity.universe, engine_capacity[str(request_params['engine_capacity'])].mf, i['engine_capacity']))
comparator.append(fuzz.interp_membership(engine_capacity.universe, engine_capacity[str(request_params['engine_capacity'])].mf, car.engine_capacity))
if 'combustion' in request_params:
comparator.append(fuzz.interp_membership(combustion.universe, combustion[str(request_params['combustion'])].mf, i['combustion']))
comparator.append(fuzz.interp_membership(combustion.universe, combustion[str(request_params['combustion'])].mf, car.combustion))
if min(comparator) > 0.75:
end_object_list.append(object)
end_object_list.append(car)
return end_object_list

View File

@ -11,8 +11,6 @@ class CarList(generics.ListAPIView):
def list(self, request):
values = map_query_params(request.query_params)
response = get_fuzzy_response(values, queryset)
print(response)
queryset = self.get_queryset()
serializer = CarSerializer(queryset, many=True)
response = get_fuzzy_response(values, self.get_queryset())
serializer = CarSerializer(response, many=True)
return Response(serializer.data)

19216
frontend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,3 +5,6 @@ django-environ==0.4.5
django-filter==21.1
djangorestframework==3.12.4
psycopg2-binary==2.9.1
numpy==1.22.1
scikit-fuzzy==0.4.2
matplotlib==3.5.1