浏览代码

优化区版本统计

Li 2 年之前
父节点
当前提交
3af13fa6ce
共有 1 个文件被更改,包括 6 次插入10 次删除
  1. 6 10
      TEAMModelBI/Controllers/Census/ActivitySticsController.cs

+ 6 - 10
TEAMModelBI/Controllers/Census/ActivitySticsController.cs

@@ -365,16 +365,14 @@ namespace TEAMModelBI.Controllers.Census
             List<string> scIds = schools.Select(x => x.id).ToList();
 
             int totalTime = 0;
-            foreach (var school in schools)
-            {
-                if (school.type == 2)
-                    heCount += 1;
-                else if (school.type == 1)
-                    geCount += 1;
-                else oeCount += 1;
 
-                areaSize += school.size;
+            heCount = schools.Select(s => s.type == 2).Count();
+            geCount = schools.Select(s => s.type == 1).Count();
+            oeCount = schools.Select(s => s.type != 2 && s.type != 1).Count();
+            areaSize = schools.Select(s => s.size).Sum();
 
+            foreach (var school in schools)
+            {
                 int count = 0;
                 int appraise = 0;
                 await foreach (var info in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<bool>(queryText: $"select value(array_contains(c.permissions,'train-appraise')) from c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school.id}") }))
@@ -476,7 +474,6 @@ namespace TEAMModelBI.Controllers.Census
                 }
             }
 
-
             //课例统计
             if (records.Count > 0)
             {
@@ -488,7 +485,6 @@ namespace TEAMModelBI.Controllers.Census
             }
 
             return Ok(new { state = 200, schoolCount = schools.Count, countArea, weekActivity, termActivity, totalTime, appraiseArea, examAreaCount, surveyAreaCount, voteAreaCount, homeworkAreaCount, major, standard, basics, oeCount, dayLess, weekLess, monthLess, termLess, teachCount, allLess = records.Count, schools = schoolInfos, schoolLessons });
-
         }
 
         /// <summary>