Forráskód Böngészése

update 股票更新后更新缓存

xjconline 4 hónapja
szülő
commit
c93793d07d
1 módosított fájl, 6 hozzáadás és 2 törlés
  1. 6 2
      src/manage/controls.py

+ 6 - 2
src/manage/controls.py

@@ -278,6 +278,7 @@ def update_model(cls,**kwargs):
         today_stock = obj.today_stock
         new_stock_list = []
         today_stock_list = json.loads(today_stock)
+        month = "%s%s" % (stock_date.split("-")[0],stock_date.split("-")[1])
         for ts in today_stock_list:
             if ts["name"]:
                 try:
@@ -285,7 +286,7 @@ def update_model(cls,**kwargs):
                         name = ts["name"] 
                     )
                     stock_id = stock.id
-                    usobj,flag = cm.UserStock.objects.get_or_create(
+                    usobj,flag = cm.UserStock.get_db_model(month).objects.get_or_create(
                         user_id = user_id, 
                         stock_id = stock_id,
                         stock_name = ts["name"],
@@ -315,6 +316,9 @@ def update_model(cls,**kwargs):
     if model_name == "UserInfo":
         ccc.del_cache("cdata_get_user_info_(%s,)"%id)
 
+    if model_name == "Stock":
+        ccc.del_cache("cdata_get_stock_cache_(%sL,)"%id)
+
     return rst
 
 
@@ -1420,7 +1424,7 @@ def update_stock_usernum(**kwargs):
     """
     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)
     qset = qset.values("stock_id","stock_name").annotate(count=Count("stock_id"),total_fund=Sum("fund")).order_by("-count")
     cm.Stock.objects.update(stock_date=None)
     for q in qset: