diff --git a/apps/herd/services/rancher_dashboard_service.py b/apps/herd/services/rancher_dashboard_service.py index 9937542..ae440d0 100644 --- a/apps/herd/services/rancher_dashboard_service.py +++ b/apps/herd/services/rancher_dashboard_service.py @@ -71,7 +71,7 @@ class RancherDashboardService: return rancher_data @staticmethod - def rancher_dashboard_by_quota_usage(self, rancher: Rancher): + def get_rancher_dashboard_by_quota_usage(self, rancher: Rancher): """ get rancher dashboard by quota usage """ @@ -83,4 +83,6 @@ class RancherDashboardService: transaction__transaction_status='success', ).values('quota_stat') - return + print(list(set(transaction_sale_items))) + + return {} diff --git a/apps/herd/web/api/v1/api.py b/apps/herd/web/api/v1/api.py index a7dcf14..c950a2c 100644 --- a/apps/herd/web/api/v1/api.py +++ b/apps/herd/web/api/v1/api.py @@ -217,3 +217,25 @@ class RancherViewSet(BaseViewSet, RancherDashboardService, SoftDeleteMixin, view rancher=rancher ) return Response(rancher_dashboard_data) + + @action( + methods=['get'], + detail=True, + url_path='rancher_dashboard_by_quota_usage', + url_name='rancher_dashboard_by_quota_usage', + name='rancher_dashboard_by_quota_usage' + ) + def rancher_dashboard_by_quota_usage(self, request, pk=None): + """ rancher dashboard """ + + rancher = self.get_object() + + query_param = self.request.query_params # noqa + + query_string = query_param.get('search', None) + + rancher_dashboard_data = self.get_rancher_dashboard_by_quota_usage( + self, + rancher=rancher + ) + return Response(rancher_dashboard_data)