|
|
|
@ -99,190 +99,25 @@ class PlacementPointViewSet(ReadOnlyModelViewSet):
|
|
|
|
@action(detail=False, methods=['get'])
|
|
|
|
@action(detail=False, methods=['get'])
|
|
|
|
def filters(self, request):
|
|
|
|
def filters(self, request):
|
|
|
|
qs = self.get_queryset()
|
|
|
|
qs = self.get_queryset()
|
|
|
|
age_day = [
|
|
|
|
keys = (
|
|
|
|
x for x in list(set(qs.values_list('age_day', flat=True)))
|
|
|
|
'age_day', 'prediction_first', 'prediction_current',
|
|
|
|
if
|
|
|
|
'plan_first', 'plan_current', 'fact', 'delta_first',
|
|
|
|
x is not None
|
|
|
|
'delta_current', 'flat_cnt', 'year_bld', 'levels',
|
|
|
|
]
|
|
|
|
'doors', 'flats_cnt', 'popul_home', 'popul_job',
|
|
|
|
prediction_first = [
|
|
|
|
'other_post_cnt', 'target_post_cnt', 'yndxfood_cnt',
|
|
|
|
x for x in list(
|
|
|
|
'yndxfood_sum', 'yndxfood_cnt_cst',
|
|
|
|
set(qs.values_list('prediction_first', flat=True)),
|
|
|
|
)
|
|
|
|
) if
|
|
|
|
temp_data = {
|
|
|
|
x is not None
|
|
|
|
key: [
|
|
|
|
]
|
|
|
|
x for x in list(set(qs.values_list(key, flat=True))) if
|
|
|
|
prediction_current = [
|
|
|
|
x is not None
|
|
|
|
x for x in list(
|
|
|
|
]
|
|
|
|
set(qs.values_list('prediction_current', flat=True)),
|
|
|
|
for key in keys
|
|
|
|
) if
|
|
|
|
}
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
plan_first = [
|
|
|
|
|
|
|
|
x for x in
|
|
|
|
|
|
|
|
list(set(qs.values_list('plan_first', flat=True))) if
|
|
|
|
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
plan_current = [
|
|
|
|
|
|
|
|
x for x in
|
|
|
|
|
|
|
|
list(set(qs.values_list('plan_current', flat=True))) if
|
|
|
|
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
fact = [
|
|
|
|
|
|
|
|
x for x in list(set(qs.values_list('fact', flat=True))) if
|
|
|
|
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
delta_first = [
|
|
|
|
|
|
|
|
x for x in
|
|
|
|
|
|
|
|
list(set(qs.values_list('delta_first', flat=True))) if
|
|
|
|
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
delta_current = [
|
|
|
|
|
|
|
|
x for x in
|
|
|
|
|
|
|
|
list(set(qs.values_list('delta_current', flat=True)))
|
|
|
|
|
|
|
|
if x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
flat_cnt = [
|
|
|
|
|
|
|
|
x for x in list(set(qs.values_list('flat_cnt', flat=True)))
|
|
|
|
|
|
|
|
if x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
year_bld = [
|
|
|
|
|
|
|
|
x for x in list(set(qs.values_list('year_bld', flat=True)))
|
|
|
|
|
|
|
|
if x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
levels = [
|
|
|
|
|
|
|
|
x for x in list(set(qs.values_list('levels', flat=True))) if
|
|
|
|
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
doors = [
|
|
|
|
|
|
|
|
x for x in list(set(qs.values_list('doors', flat=True))) if
|
|
|
|
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
flats_cnt = [
|
|
|
|
|
|
|
|
x for x in
|
|
|
|
|
|
|
|
list(set(qs.values_list('flats_cnt', flat=True))) if
|
|
|
|
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
popul_home = [
|
|
|
|
|
|
|
|
x for x in
|
|
|
|
|
|
|
|
list(set(qs.values_list('popul_home', flat=True))) if
|
|
|
|
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
popul_job = [
|
|
|
|
|
|
|
|
x for x in
|
|
|
|
|
|
|
|
list(set(qs.values_list('popul_job', flat=True))) if
|
|
|
|
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
other_post_cnt = [
|
|
|
|
|
|
|
|
x for x in
|
|
|
|
|
|
|
|
list(
|
|
|
|
|
|
|
|
set(qs.values_list('other_post_cnt', flat=True)),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
if x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
target_post_cnt = [
|
|
|
|
|
|
|
|
x for x in list(
|
|
|
|
|
|
|
|
set(qs.values_list('target_post_cnt', flat=True)),
|
|
|
|
|
|
|
|
) if
|
|
|
|
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
yndxfood_cnt = [
|
|
|
|
|
|
|
|
x for x in
|
|
|
|
|
|
|
|
list(set(qs.values_list('yndxfood_cnt', flat=True))) if
|
|
|
|
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
yndxfood_sum = [
|
|
|
|
|
|
|
|
x for x in
|
|
|
|
|
|
|
|
list(set(qs.values_list('yndxfood_sum', flat=True))) if
|
|
|
|
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
yndxfood_cnt_cst = [
|
|
|
|
|
|
|
|
x for x in list(
|
|
|
|
|
|
|
|
set(qs.values_list('yndxfood_cnt_cst', flat=True)),
|
|
|
|
|
|
|
|
) if
|
|
|
|
|
|
|
|
x is not None
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
data = {
|
|
|
|
data = {
|
|
|
|
'age_day': [min(age_day), max(age_day)] if age_day else [0, 2030],
|
|
|
|
key: [
|
|
|
|
'prediction_first': [
|
|
|
|
min(temp_data[key]), max(temp_data[key]),
|
|
|
|
min(prediction_first), max(
|
|
|
|
] if temp_data[key] else [0, 100] for key in keys
|
|
|
|
prediction_first,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
] if prediction_first else [-22, 22],
|
|
|
|
|
|
|
|
'prediction_current': [
|
|
|
|
|
|
|
|
min(prediction_current), max(
|
|
|
|
|
|
|
|
prediction_current,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
] if prediction_current else [
|
|
|
|
|
|
|
|
-22,
|
|
|
|
|
|
|
|
22,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
'plan_first': [
|
|
|
|
|
|
|
|
min(plan_first),
|
|
|
|
|
|
|
|
max(plan_first),
|
|
|
|
|
|
|
|
] if plan_first else [0, 100],
|
|
|
|
|
|
|
|
'plan_current': [
|
|
|
|
|
|
|
|
min(plan_current),
|
|
|
|
|
|
|
|
max(plan_current),
|
|
|
|
|
|
|
|
] if plan_current else [0, 100],
|
|
|
|
|
|
|
|
'fact': [min(fact), max(fact)] if fact else [0, 100],
|
|
|
|
|
|
|
|
'delta_first': [
|
|
|
|
|
|
|
|
min(delta_first),
|
|
|
|
|
|
|
|
max(delta_first),
|
|
|
|
|
|
|
|
] if delta_first else [0, 100],
|
|
|
|
|
|
|
|
'delta_current': [
|
|
|
|
|
|
|
|
min(delta_current),
|
|
|
|
|
|
|
|
max(delta_current),
|
|
|
|
|
|
|
|
] if delta_current else [
|
|
|
|
|
|
|
|
0,
|
|
|
|
|
|
|
|
100,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
'flat_cnt': [min(flat_cnt), max(flat_cnt)] if flat_cnt else [
|
|
|
|
|
|
|
|
0,
|
|
|
|
|
|
|
|
100,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
'year_bld': [min(year_bld), max(year_bld)] if year_bld else [
|
|
|
|
|
|
|
|
0,
|
|
|
|
|
|
|
|
2030,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
'levels': [min(levels), max(levels)] if levels else [0, 100],
|
|
|
|
|
|
|
|
'doors ': [min(doors), max(doors)] if doors else [0, 100],
|
|
|
|
|
|
|
|
'flats_cnt': [min(flats_cnt), max(flats_cnt)] if flats_cnt else [
|
|
|
|
|
|
|
|
0,
|
|
|
|
|
|
|
|
100,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
'popul_home': [
|
|
|
|
|
|
|
|
min(popul_home),
|
|
|
|
|
|
|
|
max(popul_home),
|
|
|
|
|
|
|
|
] if popul_home else [0, 100],
|
|
|
|
|
|
|
|
'popul_job': [min(popul_job), max(popul_job)] if popul_job else [
|
|
|
|
|
|
|
|
0,
|
|
|
|
|
|
|
|
100,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
'other_post_cnt': [
|
|
|
|
|
|
|
|
min(other_post_cnt),
|
|
|
|
|
|
|
|
max(other_post_cnt),
|
|
|
|
|
|
|
|
] if other_post_cnt else [
|
|
|
|
|
|
|
|
0,
|
|
|
|
|
|
|
|
100,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
'target_post_cnt': [
|
|
|
|
|
|
|
|
min(target_post_cnt),
|
|
|
|
|
|
|
|
max(target_post_cnt),
|
|
|
|
|
|
|
|
] if target_post_cnt else [
|
|
|
|
|
|
|
|
0, 100,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
'yndxfood_cnt': [
|
|
|
|
|
|
|
|
min(yndxfood_cnt),
|
|
|
|
|
|
|
|
max(yndxfood_cnt),
|
|
|
|
|
|
|
|
] if yndxfood_cnt else [0, 100],
|
|
|
|
|
|
|
|
'yndxfood_sum': [
|
|
|
|
|
|
|
|
min(yndxfood_sum),
|
|
|
|
|
|
|
|
max(yndxfood_sum),
|
|
|
|
|
|
|
|
] if yndxfood_sum else [0, 100],
|
|
|
|
|
|
|
|
'yndxfood_cnt_cst': [
|
|
|
|
|
|
|
|
min(yndxfood_cnt_cst), max(
|
|
|
|
|
|
|
|
yndxfood_cnt_cst,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
] if yndxfood_cnt_cst else [0, 100],
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Response(data, status=status.HTTP_200_OK)
|
|
|
|
return Response(data, status=status.HTTP_200_OK)
|
|
|
|
|
|
|
|
|
|
|
|
|