@@ -14,7 +14,6 @@ from authentication.selectors.user_selector import UserSelector from authentication.serializers import ( AllowedModelsStatus, BusinessAccountDataSerializer, - BusinessAccountStatisticsSerializer, BusinessHostSerializer, NeuronModelStatisticsSerialiser, ) @@ -87,17 +86,6 @@ class BusinessHostSelector: host, context={'worker_amount': host.accounts.count(), 'token_cap_enabled': host.token_cap_enabled} ) - def get_all_account_statistics( - self, - ) -> BusinessAccountStatisticsSerializer: - accounts = self.list_business_accounts() - context = dict() - for account in accounts: - spending_amount = ModelPaymentSelector(account.user).calculate_self_spending() - context[account] = spending_amount - - return BusinessAccountStatisticsSerializer(accounts, many=True, context={'amounts': context}) - def get_per_model_statistics(self): accounts = self.list_business_accounts() context = dict() @@ -201,14 +201,6 @@ class DeletedAccountDataSerializer(serializers.Serializer): return self.context.get('account_type') -class BusinessAccountStatisticsSerializer(serializers.Serializer): - username = serializers.CharField() - spent_amount = serializers.SerializerMethodField() - - def get_spent_amount(self, obj): - return self.context['amounts'][obj] - - class NeuronModelStatisticsSerialiser(serializers.Serializer): title = serializers.CharField() spent_amount = serializers.SerializerMethodField() @@ -105,11 +105,6 @@ urlpatterns = [ views.HostInvitationAPIView.as_view(), name='host-invitation-management', ), - path( - 'business-host/stats/accounts', - views.HostAccountStatisticsAPIView.as_view(), - name='add-judicial-to-host', - ), path( 'business-host/stats/models', views.HostModelStatisticsAPIView.as_view(), @@ -60,7 +60,6 @@ from authentication.serializers import ( AddModelsSerializer, AllowedModelsStatus, BusinessAccountDataSerializer, - BusinessAccountStatisticsSerializer, BusinessGroupSerializer, BusinessGroupsSerializer, BusinessGroupUpdateSerializer, @@ -424,19 +423,6 @@ class HostModelStatisticsAPIView(APIView): return Response({'detail': f'{err}'}, status=status.HTTP_400_BAD_REQUEST) -class HostAccountStatisticsAPIView(APIView): - permission_classes = (HasBusinessAdminPermissions,) - - @extend_schema(responses={200: BusinessAccountStatisticsSerializer}) - def get(self, request, *args, **kwargs): - """List company stats by company accounts.""" - try: - result = BusinessHostSelector(self.request.user).get_all_account_statistics() - return Response(result.data, status=status.HTTP_200_OK) - except Exception as err: - return Response({'detail': f'{err}'}, status=status.HTTP_400_BAD_REQUEST) - - class DeleteUserAPIView(APIView): permission_classes = (IsAuthenticated,)