Răsfoiți Sursa

全球用户增长地区、所有用户地区

peng 3 ani în urmă
părinte
comite
2a0cad139a
1 a modificat fișierele cu 20 adăugiri și 19 ștergeri
  1. 20 19
      AdminController/dataSystemManagement/HomeDataController.py

+ 20 - 19
AdminController/dataSystemManagement/HomeDataController.py

@@ -218,25 +218,26 @@ class HomeDataView(View):
                             break
                     if flag == 0:
                         user_all_temp_list.append(item)
-            for item in user_increase_temp_list:
-                rate = round(item['count'] / user_increase_count * 100, 2)
-                if rate >= 10:
-                    item['rate'] = rate
-                    user_increase_list.append(item)
-                else:
-                    user_increase_other_dict['count'] += item['count']
-            user_increase_other_dict['rate'] = round(user_increase_other_dict['count'] / user_increase_count * 100, 2)
-            user_increase_list.append(user_increase_other_dict)
-
-            for item in user_all_temp_list:
-                rate = round(item['count'] / user_all_count * 100, 2)
-                if rate >= 10:
-                    item['rate'] = rate
-                    user_all_list.append(item)
-                else:
-                    user_all_other_dict['count'] += item['count']
-            user_all_other_dict['rate'] = round(user_all_other_dict['count'] / user_increase_count * 100, 2)
-            user_all_list.append(user_all_other_dict)
+            if user_increase_temp_list:
+                for item in user_increase_temp_list:
+                    rate = round(item['count'] / user_increase_count * 100, 2)
+                    if rate >= 10:
+                        item['rate'] = rate
+                        user_increase_list.append(item)
+                    else:
+                        user_increase_other_dict['count'] += item['count']
+                user_increase_other_dict['rate'] = round(user_increase_other_dict['count'] / user_increase_count * 100, 2)
+                user_increase_list.append(user_increase_other_dict)
+            if user_all_temp_list:
+                for item in user_all_temp_list:
+                    rate = round(item['count'] / user_all_count * 100, 2)
+                    if rate >= 10:
+                        item['rate'] = rate
+                        user_all_list.append(item)
+                    else:
+                        user_all_other_dict['count'] += item['count']
+                user_all_other_dict['rate'] = round(user_all_other_dict['count'] / user_all_count * 100, 2)
+                user_all_list.append(user_all_other_dict)
             res = {
                 'userIncreaseCount': user_increase_count,
                 'userActiveCount': user_active_count,