Skip to content

Commit

Permalink
Merge pull request #29 from Prosept-4/feature/fix-problem-filter
Browse files Browse the repository at this point in the history
fix filter
  • Loading branch information
KirillShirokov authored Dec 9, 2023
2 parents 35b5c9e + d0c90d7 commit fa331f5
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions backend/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,23 +620,19 @@ def analyze(self, request, *args, **kwargs):
return Response('Задача анализа запущена.', status=HTTP_200_OK)


class StatisticViewSet(viewsets.ViewSet):
"""
ViewSet для сбора статистики парсинга дилеров.
Атрибуты:
- queryset: Набор данных, предоставляющий все объекты DealerParsing.
"""
class StatisticViewSet(viewsets.ReadOnlyModelViewSet):
"""Сбор статистики парсинга дилеров"""
queryset = DealerParsing.objects.all()
serializer_class = DealerParsingSerializer
filter_backends = [DjangoFilterBackend, filters.OrderingFilter]
filterset_class = StatisticFilter

def list(self, request, *args, **kwargs):
total_records = self.queryset.count()
matching_records = self.queryset.filter(is_matched=True).count()
postponed_records = self.queryset.filter(is_postponed=True).count()
no_matches_records = self.queryset.filter(has_no_matches=True).count()
queryset = self.filter_queryset(self.get_queryset())
total_records = queryset.count()
matching_records = queryset.filter(is_matched=True).count()
postponed_records = queryset.filter(is_postponed=True).count()
no_matches_records = queryset.filter(has_no_matches=True).count()

data = {
'is_matching': matching_records,
Expand Down

0 comments on commit fa331f5

Please sign in to comment.