xjc 4 hónapja
szülő
commit
15ac4f6fd2
3 módosított fájl, 27 hozzáadás és 9 törlés
  1. 7 0
      src/common/common_control.py
  2. 15 6
      src/weixin/controls.py
  3. 5 3
      src/weixin/views.py

+ 7 - 0
src/common/common_control.py

@@ -47,6 +47,13 @@ def cache_data(timeout=60*60):
         def __wrapper(*args,**kwargs):
             if args:
                 key = "cdata_{}_{}".format(func.__name__,str(args))
+            elif kwargs:
+                kwstr = ""
+                for k in kwargs:
+                    kstr = "{}:{};".format(k,kwargs.get(k))
+                    kwstr += kstr
+                key = "cdata_{}_{}".format(func.__name__,kwstr)
+
             else:
                 key = "cdata_{}".format(func.__name__)
             #if not kwargs.get("cache",True) or not cache.get(key):

+ 15 - 6
src/weixin/controls.py

@@ -1684,10 +1684,11 @@ def get_defend_rank(request):
     return total,data
 
 
-def get_champion_articles_list(request):
+@ccc.cache_data(10*60)
+def get_champion_articles_list(**kwargs):
     """
     """
-    kwargs = request.json
+    #kwargs = request.json
     _type = kwargs.get("type")
     isbanner = kwargs.get("isbanner")
     category = kwargs.get("category")
@@ -2584,11 +2585,13 @@ def add_zan(request):
     zans = cm.PlayerRecord.get_db_model(match_id).objects.filter(id=record_id).first().zans
     return zans
 
-def get_experience_list(request):
+@ccc.cache_data(10*60)
+def get_experience_list(**kwargs):
     """
     """
     #return 0,[]
-    kwargs = request.json
+    #kwargs = request.json
+
     today = get_today_date()
     match_id = ccc.get_cur_match().id
     match_group = kwargs.get("match_group")
@@ -3232,12 +3235,13 @@ def articles_top5_by_type(**kwargs):
         data.append({"category":cat,"articles":articles})
     return data
 
+@ccc.cache_data(5*60)
 def get_match_winlost_top5(**kwargs):
     """
     """
     data = []
     cur_match_id = ccc.get_cur_match().id
-    matchs = cm.Match.objects.filter(id__gte=8,match_status__in=[3,4]).order_by("-id")
+    matchs = cm.Match.objects.filter(id__gte=19,match_status__in=[3,4]).order_by("-id")
     for match in matchs:
         match_id = match.id
         match_name = match.name
@@ -3477,6 +3481,7 @@ def get_opmode_group_rank_info_list(**kwargs):
 
 
 
+@ccc.cache_data(5*60)
 def get_match_group_winlose_statistic(**qdata):
     """
     """
@@ -3551,7 +3556,9 @@ def user_mark_score(**kwargs):
     )
     obj.score = score
     obj.save()
+    
 
+    return obj.score
 
 def get_user_markscore_list(**kwargs):
     """
@@ -3575,7 +3582,8 @@ def check_user_markscore(**kwargs):
     """
     """
     user_id = kwargs.get("user_id")
-    if cm.UserMarkScore.objects.filter(user_id=user_id):
+    stock_date = kwargs.get("stock_date")
+    if cm.UserMarkScore.objects.filter(user_id=user_id,stock_date=stock_date):
         return 1
     else:
         return 0
@@ -3623,6 +3631,7 @@ def get_match_group_winlose_allday(**qdata):
     return rst
 
 
+@ccc.cache_data(5*60)
 def get_match_group_winlose_avg_allday(**qdata):
     """
     """

+ 5 - 3
src/weixin/views.py

@@ -551,7 +551,8 @@ class ChampionArticleListView(cv.BaseView):
         """#冠军心得(2.0小程序)                                                       
         """                                                                        
         try:                                                                       
-            total,rst = ctl.get_champion_articles_list(request)                                 
+            kwargs = request.json
+            total,rst = ctl.get_champion_articles_list(**kwargs)                                 
             return cv.to_suc({"total":total,"list":rst})
         except Exception as e:                                                     
             cv.tracefail()                                                         
@@ -990,7 +991,8 @@ class V3ExperienceView(cv.AuthView):
         """#今日反思列表v3(3.0小程序)
         """
         try:
-            total,rst = ctl.get_experience_list(request)
+            kwargs = request.json
+            total,rst = ctl.get_experience_list(**kwargs)
             return cv.to_suc({"total":total,"list":rst})
         except Exception as e: 
             cv.tracefail()
@@ -1685,7 +1687,7 @@ class UserMarkScoreCheckView(cv.AuthView):
         qdata = request.json
         try:
             qdata["user_id"] = request.user.get("id",0)
-            rst = ctl.get_user_markscore_list(**qdata)
+            rst = ctl.check_user_markscore(**qdata)
             return cv.to_suc(rst)
         except Exception as e:
             cv.tracefail()