From 8efe7036d26d25d63de4acfec4cd52441ab1fcf7 Mon Sep 17 00:00:00 2001 From: minghansun1 Date: Sat, 23 Nov 2024 11:25:33 -0500 Subject: [PATCH] deleted unused apply_filters function --- backend/market/views.py | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/backend/market/views.py b/backend/market/views.py index d22a14a6..97740158 100644 --- a/backend/market/views.py +++ b/backend/market/views.py @@ -24,7 +24,6 @@ ItemSerializerRead, OfferSerializer, SubletSerializer, - TagSerializer, ) from pennmobile.analytics import Metric, record_analytics @@ -64,40 +63,6 @@ def get_queryset(self): return Offer.objects.filter(user=user) -def apply_filters( - queryset, params, filter_mappings, user=None, is_sublet=False, tag_field="tags__name" -): - # Build dynamic filters based on filter mappings - filters = {} - for param, field in filter_mappings.items(): - if param_value := params.get(param): - filters[field] = param_value - - - # Apply tag filtering iteratively if "tags" parameter is provided - for tag in params.getlist("tags"): - queryset = queryset.filter(**{tag_field: tag}) - - # Handle seller/owner filtering based on user ownership - if not is_sublet: - queryset = queryset.exclude(category__name__in=["Sublet"]) - if params.get("seller", "false").lower() == "true" and user: - filters["seller"] = user - else: - filters["expires_at__gte"] = timezone.now() - else: - queryset = queryset.filter(item__category__name__in=["Sublet"]) - if params.get("seller", "false").lower() == "true" and user: - filters["item__seller"] = user - else: - filters["item__expires_at__gte"] = timezone.now() - - # Apply all filters to the queryset - queryset = queryset.filter(**filters) - - return queryset - - class Items(viewsets.ModelViewSet): """ list: