|
@@ -575,6 +575,11 @@ def get_player_info(player_id):
|
|
return player
|
|
return player
|
|
|
|
|
|
@ccc.cache_data()
|
|
@ccc.cache_data()
|
|
|
|
+def get_player_info_cache(player_id):
|
|
|
|
+ player = cm.Player.objects.filter(id=player_id).values().first()
|
|
|
|
+ return player
|
|
|
|
+
|
|
|
|
+@ccc.cache_data()
|
|
def get_match_info(match_id):
|
|
def get_match_info(match_id):
|
|
match = cm.Match.objects.filter(id=match_id).values().first()
|
|
match = cm.Match.objects.filter(id=match_id).values().first()
|
|
return match
|
|
return match
|
|
@@ -788,6 +793,7 @@ def add_model(cls,**kwargs):
|
|
#记录持股情况
|
|
#记录持股情况
|
|
new_stock_list = []
|
|
new_stock_list = []
|
|
today_stock_list = json.loads(today_stock)
|
|
today_stock_list = json.loads(today_stock)
|
|
|
|
+ month = "%s%s" % (stock_date.split("-")[0],stock_date.split("-")[1])
|
|
for ts in today_stock_list:
|
|
for ts in today_stock_list:
|
|
if ts["name"] and ts["fund"]:
|
|
if ts["name"] and ts["fund"]:
|
|
try:
|
|
try:
|
|
@@ -795,11 +801,8 @@ def add_model(cls,**kwargs):
|
|
name = ts["name"]
|
|
name = ts["name"]
|
|
)
|
|
)
|
|
stock_id = stock.id
|
|
stock_id = stock.id
|
|
- try:
|
|
|
|
- cm.UserStock.objects.filter(stock_id=stock_id,player_id=player.id,stock_date=stock_date).delete()
|
|
|
|
- except Exception as e:
|
|
|
|
- print(e)
|
|
|
|
- usobj,flag = cm.UserStock.objects.get_or_create(
|
|
|
|
|
|
+
|
|
|
|
+ usobj,flag = cm.UserStock.get_db_model(month).objects.get_or_create(
|
|
stock_id = stock_id,
|
|
stock_id = stock_id,
|
|
player_id = player.id,
|
|
player_id = player.id,
|
|
stock_date = stock_date
|
|
stock_date = stock_date
|
|
@@ -1414,16 +1417,22 @@ def get_stock_info(stock_id):
|
|
return stock
|
|
return stock
|
|
|
|
|
|
|
|
|
|
|
|
+@ccc.cache_data()
|
|
|
|
+def get_stock_cache(stock_id):
|
|
|
|
+ stock = cm.Stock.objects.filter(id=stock_id).values().first()
|
|
|
|
+ return stock
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
def get_hot_stock_buy(**kwargs):
|
|
def get_hot_stock_buy(**kwargs):
|
|
"""
|
|
"""
|
|
"""
|
|
"""
|
|
stock_date = kwargs.get("stock_date")
|
|
stock_date = kwargs.get("stock_date")
|
|
|
|
+ month = "%s%s" % (stock_date.split("-")[0],stock_date.split("-")[1])
|
|
|
|
|
|
- qset = cm.UserStock.objects.filter(stock_date=stock_date,fund__gt=0)
|
|
|
|
|
|
+ qset = cm.UserStock.get_db_model(month).objects.filter(stock_date=stock_date,fund__gt=0)
|
|
if kwargs.get("name"):
|
|
if kwargs.get("name"):
|
|
- qset = cm.UserStock.objects.filter(stock_name__icontains=kwargs.get("name"),stock_date=stock_date)
|
|
|
|
|
|
+ qset = qset.filter(stock_name__icontains=kwargs.get("name"),stock_date=stock_date)
|
|
|
|
|
|
if int(kwargs.get("fund_rank",0)) == 1:
|
|
if int(kwargs.get("fund_rank",0)) == 1:
|
|
qset = qset.values("stock_id","stock_name").annotate(count=Count("stock_id"),total_fund=Sum("fund")).order_by("-total_fund")
|
|
qset = qset.values("stock_id","stock_name").annotate(count=Count("stock_id"),total_fund=Sum("fund")).order_by("-total_fund")
|
|
@@ -1451,10 +1460,11 @@ def get_hot_stock_buy(**kwargs):
|
|
if page and page_size:
|
|
if page and page_size:
|
|
total,data = ccf.get_page_list(data,page,page_size)
|
|
total,data = ccf.get_page_list(data,page,page_size)
|
|
for item in data:
|
|
for item in data:
|
|
- stock = cm.Stock.objects.filter(id=item["id"]).first()
|
|
|
|
|
|
+ #stock = cm.Stock.objects.filter(id=item["id"]).first()
|
|
|
|
+ stock = get_stock_cache(item["id"])
|
|
if stock:
|
|
if stock:
|
|
- item["stock_code"] = stock.code
|
|
|
|
- item["stock_desc"] = stock.desc
|
|
|
|
|
|
+ item["stock_code"] = stock.get("code","")
|
|
|
|
+ item["stock_desc"] = stock.get("desc","")
|
|
return total,data
|
|
return total,data
|
|
else:
|
|
else:
|
|
return len(data),data
|
|
return len(data),data
|
|
@@ -1578,20 +1588,22 @@ def get_hot_stock_sell_players(**kwargs):
|
|
"""
|
|
"""
|
|
_id = kwargs.get("id")
|
|
_id = kwargs.get("id")
|
|
stock_date = kwargs.get("stock_date")
|
|
stock_date = kwargs.get("stock_date")
|
|
|
|
+ month = "%s%s" % (stock_date.split("-")[0],stock_date.split("-")[1])
|
|
stock_date_time = ccf.str_to_datetime(kwargs.get("stock_date"),"%Y-%m-%d")
|
|
stock_date_time = ccf.str_to_datetime(kwargs.get("stock_date"),"%Y-%m-%d")
|
|
yesterday = (stock_date_time - datetime.timedelta(days=1)).strftime("%Y-%m-%d")
|
|
yesterday = (stock_date_time - datetime.timedelta(days=1)).strftime("%Y-%m-%d")
|
|
|
|
|
|
#昨天持股选手
|
|
#昨天持股选手
|
|
- yes_players = list(cm.UserStock.objects.filter(stock_date=yesterday,stock_id=_id).values_list("player_id",flat=True))
|
|
|
|
- td_players = list(cm.UserStock.objects.filter(stock_date=stock_date,stock_id=_id).values_list("player_id",flat=True))
|
|
|
|
|
|
+ yes_players = list(cm.UserStock.get_db_model(month).objects.filter(stock_date=yesterday,stock_id=_id).values_list("player_id",flat=True))
|
|
|
|
+ td_players = list(cm.UserStock.get_db_model(month).objects.filter(stock_date=stock_date,stock_id=_id).values_list("player_id",flat=True))
|
|
sell_players = list(set(yes_players)-set(td_players))
|
|
sell_players = list(set(yes_players)-set(td_players))
|
|
|
|
|
|
data = []
|
|
data = []
|
|
for player_id in sell_players:
|
|
for player_id in sell_players:
|
|
- player = cm.Player.objects.filter(id=player_id).first()
|
|
|
|
|
|
+ #player = cm.Player.objects.filter(id=player_id).first()
|
|
|
|
+ player = get_player_info_cache(player_id)
|
|
if player:
|
|
if player:
|
|
- match_id = player.match_id
|
|
|
|
- match_group = player.match_group
|
|
|
|
|
|
+ match_id = player["match_id"]
|
|
|
|
+ match_group = player["match_group"]
|
|
today_record = get_today_record(player_id,match_id,match_group,stock_date)
|
|
today_record = get_today_record(player_id,match_id,match_group,stock_date)
|
|
|
|
|
|
if today_record:
|
|
if today_record:
|
|
@@ -1684,7 +1696,7 @@ def get_defend_rank(request):
|
|
return total,data
|
|
return total,data
|
|
|
|
|
|
|
|
|
|
-@ccc.cache_data(10*60)
|
|
|
|
|
|
+@ccc.cache_data_kw(10*60)
|
|
def get_champion_articles_list(**kwargs):
|
|
def get_champion_articles_list(**kwargs):
|
|
"""
|
|
"""
|
|
"""
|
|
"""
|
|
@@ -1913,15 +1925,19 @@ def get_stock_players(**kwargs):
|
|
"""
|
|
"""
|
|
stock_id = kwargs.get("stock_id")
|
|
stock_id = kwargs.get("stock_id")
|
|
stock_date = kwargs.get("stock_date",get_today_date())
|
|
stock_date = kwargs.get("stock_date",get_today_date())
|
|
|
|
+ month = "%s%s" % (stock_date.split("-")[0],stock_date.split("-")[1])
|
|
|
|
+ print(month)
|
|
|
|
+
|
|
data = []
|
|
data = []
|
|
- user_stocks = cm.UserStock.objects.filter(stock_id=stock_id,stock_date=stock_date,fund__gt=0.0)
|
|
|
|
|
|
+ user_stocks = cm.UserStock.get_db_model(month).objects.filter(stock_id=stock_id,stock_date=stock_date,fund__gt=0.0)
|
|
for us in user_stocks:
|
|
for us in user_stocks:
|
|
player_id = us.player_id
|
|
player_id = us.player_id
|
|
- player = cm.Player.objects.filter(id=player_id).first()
|
|
|
|
|
|
+ #player = cm.Player.objects.filter(id=player_id).first()
|
|
|
|
+ player = get_player_info_cache(player_id)
|
|
if player:
|
|
if player:
|
|
- match_id = player.match_id
|
|
|
|
- match_group = player.match_group
|
|
|
|
- user_id = player.user_id
|
|
|
|
|
|
+ match_id = player["match_id"]
|
|
|
|
+ match_group = player["match_group"]
|
|
|
|
+ user_id = player["user_id"]
|
|
if stock_date:
|
|
if stock_date:
|
|
today_record = get_today_record(user_id,match_id,match_group,stock_date)
|
|
today_record = get_today_record(user_id,match_id,match_group,stock_date)
|
|
else:
|
|
else:
|
|
@@ -2585,7 +2601,7 @@ def add_zan(request):
|
|
zans = cm.PlayerRecord.get_db_model(match_id).objects.filter(id=record_id).first().zans
|
|
zans = cm.PlayerRecord.get_db_model(match_id).objects.filter(id=record_id).first().zans
|
|
return zans
|
|
return zans
|
|
|
|
|
|
-@ccc.cache_data(10*60)
|
|
|
|
|
|
+@ccc.cache_data_kw(10*60)
|
|
def get_experience_list(**kwargs):
|
|
def get_experience_list(**kwargs):
|
|
"""
|
|
"""
|
|
"""
|
|
"""
|
|
@@ -2756,6 +2772,7 @@ def get_user_match_list(request):
|
|
user_id = kwargs.get("user_id")
|
|
user_id = kwargs.get("user_id")
|
|
if not user_id:
|
|
if not user_id:
|
|
user_id = request.user.get("id")
|
|
user_id = request.user.get("id")
|
|
|
|
+
|
|
qset = cm.Player.objects.filter(user_id=user_id).filter(match_group__isnull=False).order_by("-id")
|
|
qset = cm.Player.objects.filter(user_id=user_id).filter(match_group__isnull=False).order_by("-id")
|
|
qset = qset.values("user_id","match_id","match_group").annotate(cnt=Count("match_id"))
|
|
qset = qset.values("user_id","match_id","match_group").annotate(cnt=Count("match_id"))
|
|
|
|
|
|
@@ -3235,7 +3252,7 @@ def articles_top5_by_type(**kwargs):
|
|
data.append({"category":cat,"articles":articles})
|
|
data.append({"category":cat,"articles":articles})
|
|
return data
|
|
return data
|
|
|
|
|
|
-@ccc.cache_data(5*60)
|
|
|
|
|
|
+@ccc.cache_data_kw(5*60)
|
|
def get_match_winlost_top5(**kwargs):
|
|
def get_match_winlost_top5(**kwargs):
|
|
"""
|
|
"""
|
|
"""
|
|
"""
|
|
@@ -3481,7 +3498,7 @@ def get_opmode_group_rank_info_list(**kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-@ccc.cache_data(5*60)
|
|
|
|
|
|
+@ccc.cache_data_kw(5*60)
|
|
def get_match_group_winlose_statistic(**qdata):
|
|
def get_match_group_winlose_statistic(**qdata):
|
|
"""
|
|
"""
|
|
"""
|
|
"""
|
|
@@ -3631,7 +3648,7 @@ def get_match_group_winlose_allday(**qdata):
|
|
return rst
|
|
return rst
|
|
|
|
|
|
|
|
|
|
-@ccc.cache_data(5*60)
|
|
|
|
|
|
+@ccc.cache_data_kw(5*60)
|
|
def get_match_group_winlose_avg_allday(**qdata):
|
|
def get_match_group_winlose_avg_allday(**qdata):
|
|
"""
|
|
"""
|
|
"""
|
|
"""
|