xjc 5 місяців тому
батько
коміт
840858a98b
2 змінених файлів з 14 додано та 10 видалено
  1. 13 9
      src/weixin/controls.py
  2. 1 1
      src/weixin/views.py

+ 13 - 9
src/weixin/controls.py

@@ -3733,16 +3733,20 @@ def get_user_markscore_week_avg(request):
     """
     """
     pass
-    now = datetime.datetime.now().date()
+    # now = datetime.datetime.now().date()
     data = []
-    for i in range(1,5):
-        item_list = []
-        for j in range(1,8):
-            now = now + datetime.timedelta(days=-1)
-            now_str = ccf.datetime_to_str(now,"%Y-%m-%d")
-            qset = cm.UserMarkScore.objects.filter(stock_date=now_str).aggregate(avg_score=Avg("score"))
-            item_list.append({"stock_date":now_str,"avg_score":qset.get("avg_score",0)})
-        data.append(item_list)
+    msret = cm.UserMarkScore.objects.all().order_by('-stock_date').values()
+    for item in msret:
+        qset = cm.UserMarkScore.objects.filter(stock_date=item['stock_date']).aggregate(avg_score=Avg("score"))
+        data.append({"stock_date":item['stock_date'],"avg_score":qset.get("avg_score",0)})
+    # for i in range(1,5):
+    #     item_list = []
+    #     for j in range(1,8):
+    #         now = now + datetime.timedelta(days=-1)
+    #         now_str = ccf.datetime_to_str(now,"%Y-%m-%d")
+    #         qset = cm.UserMarkScore.objects.filter(stock_date=now_str).aggregate(avg_score=Avg("score"))
+    #         item_list.append({"stock_date":now_str,"avg_score":qset.get("avg_score",0)})
+    #     data.append(item_list)
 
     return data
             

+ 1 - 1
src/weixin/views.py

@@ -1655,8 +1655,8 @@ class UserMarkScoreView(cv.AuthView):
             today = qdata.get("stock_date")
             if not today:
                 today = get_today_date()
-            vals["user_id"] = request.user.get("id")
             vals = ccf.get_need_params(*need_params,**qdata)
+            vals["user_id"] = request.user.get("id")
             rst = ctl.user_mark_score(**vals)
             return cv.to_suc()
         except Exception as e: