修改请求参数
This commit is contained in:
parent
1d1e7cf760
commit
638b0966c0
@ -2888,7 +2888,6 @@ def remove_creator_from_private_pool(request):
|
||||
'data': None
|
||||
}, json_dumps_params={'ensure_ascii': False})
|
||||
|
||||
|
||||
@api_view(['POST'])
|
||||
@authentication_classes([CustomTokenAuthentication])
|
||||
@csrf_exempt
|
||||
@ -2966,44 +2965,16 @@ def filter_public_creators(request):
|
||||
|
||||
public_creators = public_creators.filter(gmv_q)
|
||||
|
||||
# 观看量范围过滤,单选
|
||||
# 观看量范围过滤,使用数值数组格式
|
||||
views_range = filter_data.get('views_range')
|
||||
if views_range and len(views_range) > 0:
|
||||
views_val = views_range[0] # 单选,取第一个值
|
||||
if ',' in views_val:
|
||||
# 新格式: "1000,10000"
|
||||
try:
|
||||
views_min, views_max = views_val.split(',')
|
||||
views_min = int(views_min.strip())
|
||||
views_max = int(views_max.strip())
|
||||
|
||||
public_creators = public_creators.filter(
|
||||
creator__avg_video_views__gte=views_min,
|
||||
creator__avg_video_views__lte=views_max
|
||||
)
|
||||
except (ValueError, IndexError):
|
||||
# 如果解析失败,忽略此过滤条件
|
||||
pass
|
||||
else:
|
||||
# 兼容旧格式,保持原有逻辑
|
||||
views_min, views_max = 0, float('inf')
|
||||
if views_val == "0-100":
|
||||
views_min, views_max = 0, 100
|
||||
elif views_val == "1k-10k":
|
||||
views_min, views_max = 1000, 10000
|
||||
elif views_val == "10k-100k":
|
||||
views_min, views_max = 10000, 100000
|
||||
elif views_val == "100k-250k":
|
||||
views_min, views_max = 100000, 250000
|
||||
elif views_val == "250k-500k":
|
||||
views_min, views_max = 250000, 500000
|
||||
elif views_val == "500k+":
|
||||
views_min = 500000
|
||||
|
||||
if views_min > 0:
|
||||
public_creators = public_creators.filter(creator__avg_video_views__gte=views_min)
|
||||
if views_max < float('inf'):
|
||||
public_creators = public_creators.filter(creator__avg_video_views__lte=views_max)
|
||||
if views_range and isinstance(views_range, list) and len(views_range) == 2:
|
||||
views_min = views_range[0]
|
||||
views_max = views_range[1]
|
||||
|
||||
if views_min is not None:
|
||||
public_creators = public_creators.filter(creator__avg_video_views__gte=views_min)
|
||||
if views_max is not None:
|
||||
public_creators = public_creators.filter(creator__avg_video_views__lte=views_max)
|
||||
|
||||
# 获取总数据量
|
||||
total_count = public_creators.count()
|
||||
@ -3205,77 +3176,27 @@ def filter_private_pool_creators(request):
|
||||
|
||||
creator_relations = creator_relations.filter(gmv_q)
|
||||
|
||||
# 观看量范围过滤,单选
|
||||
# 观看量范围过滤,使用数值数组格式
|
||||
views_range = filter_data.get('views_range')
|
||||
if views_range and len(views_range) > 0:
|
||||
views_val = views_range[0] # 单选,取第一个值
|
||||
if ',' in views_val:
|
||||
# 新格式: "1000,10000"
|
||||
try:
|
||||
views_min, views_max = views_val.split(',')
|
||||
views_min = int(views_min.strip())
|
||||
views_max = int(views_max.strip())
|
||||
|
||||
creator_relations = creator_relations.filter(
|
||||
creator__avg_video_views__gte=views_min,
|
||||
creator__avg_video_views__lte=views_max
|
||||
)
|
||||
except (ValueError, IndexError):
|
||||
# 如果解析失败,忽略此过滤条件
|
||||
pass
|
||||
else:
|
||||
# 兼容旧格式,保持原有逻辑
|
||||
views_min, views_max = 0, float('inf')
|
||||
if views_val == "0-100":
|
||||
views_min, views_max = 0, 100
|
||||
elif views_val == "1k-10k":
|
||||
views_min, views_max = 1000, 10000
|
||||
elif views_val == "10k-100k":
|
||||
views_min, views_max = 10000, 100000
|
||||
elif views_val == "100k-250k":
|
||||
views_min, views_max = 100000, 250000
|
||||
elif views_val == "250k-500k":
|
||||
views_min, views_max = 250000, 500000
|
||||
elif views_val == "500k+":
|
||||
views_min = 500000
|
||||
if views_range and isinstance(views_range, list) and len(views_range) == 2:
|
||||
views_min = views_range[0]
|
||||
views_max = views_range[1]
|
||||
|
||||
if views_min is not None:
|
||||
creator_relations = creator_relations.filter(creator__avg_video_views__gte=views_min)
|
||||
if views_max is not None:
|
||||
creator_relations = creator_relations.filter(creator__avg_video_views__lte=views_max)
|
||||
|
||||
if views_min > 0:
|
||||
creator_relations = creator_relations.filter(creator__avg_video_views__gte=views_min)
|
||||
if views_max < float('inf'):
|
||||
creator_relations = creator_relations.filter(creator__avg_video_views__lte=views_max)
|
||||
|
||||
# 价格区间过滤逻辑,单选
|
||||
# 价格区间过滤逻辑,使用数值数组格式
|
||||
pricing = filter_data.get('pricing')
|
||||
if pricing and len(pricing) > 0:
|
||||
pricing_val = pricing[0] # 单选,取第一个值
|
||||
if ',' in pricing_val:
|
||||
# 新格式: "100,500"
|
||||
try:
|
||||
min_price, max_price = pricing_val.split(',')
|
||||
min_price = float(min_price.strip())
|
||||
max_price = float(max_price.strip())
|
||||
|
||||
creator_relations = creator_relations.filter(
|
||||
creator__pricing__gte=min_price,
|
||||
creator__pricing__lte=max_price
|
||||
)
|
||||
except (ValueError, IndexError):
|
||||
# 如果解析失败,忽略此过滤条件
|
||||
pass
|
||||
elif '-' in pricing_val:
|
||||
# 兼容旧格式: "100-500"
|
||||
try:
|
||||
min_price, max_price = pricing_val.split('-')
|
||||
min_price = float(min_price.strip())
|
||||
max_price = float(max_price.strip())
|
||||
|
||||
creator_relations = creator_relations.filter(
|
||||
creator__pricing__gte=min_price,
|
||||
creator__pricing__lte=max_price
|
||||
)
|
||||
except (ValueError, IndexError):
|
||||
# 如果解析失败,忽略此过滤条件
|
||||
pass
|
||||
if pricing and isinstance(pricing, list) and len(pricing) == 2:
|
||||
min_price = pricing[0]
|
||||
max_price = pricing[1]
|
||||
|
||||
if min_price is not None:
|
||||
creator_relations = creator_relations.filter(creator__pricing__gte=min_price)
|
||||
if max_price is not None:
|
||||
creator_relations = creator_relations.filter(creator__pricing__lte=max_price)
|
||||
|
||||
# 获取总数据量
|
||||
total_count = creator_relations.count()
|
||||
|
@ -105,7 +105,7 @@ DATABASES = {
|
||||
'NAME': 'daren_detail',
|
||||
'USER': 'root',
|
||||
'PASSWORD': '123456',
|
||||
'HOST': '192.168.31.138',
|
||||
'HOST': '127.0.0.1',
|
||||
'PORT': '3306',
|
||||
'OPTIONS': {
|
||||
'charset': 'utf8mb4',
|
||||
|
Loading…
Reference in New Issue
Block a user