Merge branch 'avg_value' into 'dev'

avg_route

See merge request spatial/postamates!161
dev
Aleksandr Popov 2 years ago
commit d9c20d3b8e

@ -33,6 +33,7 @@ from django.db.models import Min, Max
import os
from django.forms.models import model_to_dict
import base64
from django.db.models import Avg, Max, Min
class AOViewSet(CustomReadOnlyModelViewSet):
@ -353,6 +354,44 @@ class PlacementPointViewSet(ReadOnlyModelViewSet):
st = status.status
return Response({'last_time': models.LastMLCall.objects.first().dt, 'task_status': st}, status=HTTPStatus.OK)
@action(detail=False, methods=['get'])
def avg_bi_values(self, request):
qs = self.get_queryset()
result = qs.aggregate(Avg('target_dist_shap'), Avg('target_post_cnt_shap'), Avg('target_cnt_ao_mean_shap'),
Avg('rival_pvz_cnt_shap'), Avg('rival_post_cnt_shap'), Avg('metro_dist_shap'),
Avg('property_price_bargains_shap'), Avg('property_price_offers_shap'),
Avg('property_mean_floor_shap'), Avg('property_era_shap'), Avg('flats_cnt_shap'),
Avg('popul_home_shap'), Avg('popul_job_shap'), Avg('yndxfood_sum_shap'),
Avg('yndxfood_cnt_shap'),
Avg('school_cnt_shap'), Avg('kindergar_cnt_shap'), Avg('public_stop_cnt_shap'),
Avg('sport_center_cnt_shap'), Avg('pharmacy_cnt_shap'), Avg('supermarket_cnt_shap'),
Avg('supermarket_premium_cnt_shap'), Avg('clinic_cnt_shap'), Avg('bank_cnt_shap'),
Avg('reca_cnt_shap'), Avg('lab_cnt_shap'), Avg('culture_cnt_shap'),
Avg('attraction_cnt_shap'),
Avg('mfc_cnt_shap'), Avg('bc_cnt_shap'), Avg('tc_cnt_shap'), Avg('business_activity_shap'),
Max('target_dist_shap'), Max('target_post_cnt_shap'), Max('target_cnt_ao_mean_shap'),
Max('rival_pvz_cnt_shap'), Max('rival_post_cnt_shap'), Max('metro_dist_shap'),
Max('property_price_bargains_shap'), Max('property_price_offers_shap'),
Max('property_mean_floor_shap'), Max('property_era_shap'), Max('flats_cnt_shap'),
Max('popul_home_shap'), Max('popul_job_shap'), Max('yndxfood_sum_shap'),
Max('yndxfood_cnt_shap'), Max('school_cnt_shap'), Max('kindergar_cnt_shap'),
Max('public_stop_cnt_shap'), Max('sport_center_cnt_shap'), Max('pharmacy_cnt_shap'),
Max('supermarket_cnt_shap'), Max('supermarket_premium_cnt_shap'), Max('clinic_cnt_shap'),
Max('bank_cnt_shap'), Max('reca_cnt_shap'), Max('lab_cnt_shap'), Max('culture_cnt_shap'),
Max('attraction_cnt_shap'), Max('mfc_cnt_shap'), Max('bc_cnt_shap'), Max('tc_cnt_shap'),
Max('business_activity_shap'), Min('target_dist_shap'), Min('target_post_cnt_shap'),
Min('target_cnt_ao_mean_shap'), Min('rival_pvz_cnt_shap'), Min('rival_post_cnt_shap'),
Min('metro_dist_shap'), Min('property_price_bargains_shap'),
Min('property_price_offers_shap'), Min('property_mean_floor_shap'), Min('property_era_shap'),
Min('flats_cnt_shap'), Min('popul_home_shap'), Min('popul_job_shap'),
Min('yndxfood_sum_shap'), Min('yndxfood_cnt_shap'), Min('school_cnt_shap'),
Min('kindergar_cnt_shap'), Min('public_stop_cnt_shap'), Min('sport_center_cnt_shap'),
Min('pharmacy_cnt_shap'), Min('supermarket_cnt_shap'), Min('supermarket_premium_cnt_shap'),
Min('clinic_cnt_shap'), Min('bank_cnt_shap'), Min('reca_cnt_shap'), Min('lab_cnt_shap'),
Min('culture_cnt_shap'), Min('attraction_cnt_shap'), Min('mfc_cnt_shap'), Min('bc_cnt_shap'),
Min('tc_cnt_shap'), Min('business_activity_shap'))
return Response({'result': result}, status=HTTPStatus.OK)
class PrePlacementPointViewSet(PlacementPointViewSet):
queryset = models.PrePlacementPoint.objects
@ -458,7 +497,6 @@ class AvgBiValuesViewSet(APIView):
return Response(data, status=HTTPStatus.OK)
@api_view(['POST'])
def upload_post_and_pvz(request):
warnings.filterwarnings('ignore')

Loading…
Cancel
Save