林轩 1 year atrás
parent
commit
cc9b923f86
1 changed files with 2 additions and 1 deletions
  1. 2 1
      apps/PestAnalysis/views.py

+ 2 - 1
apps/PestAnalysis/views.py

@@ -198,8 +198,9 @@ class RecentMonthPestCount(GenericAPIView):
             for k, v in result.items():
                 if k in insect_dict.keys():
                     temp[insect_dict.get(k)] = v 
+            temp = sorted(temp.items(), key=lambda item: item[1], reverse=True)
             data = {
-                "pest": temp,
+                "pest": dict(temp),
                 "imgs": imgs[:10]
             }
             return Response(data)