sunsheng 1 年之前
父节点
当前提交
b500fc5122
共有 1 个文件被更改,包括 35 次插入35 次删除
  1. 35 35
      src/api/exeamLog.go

+ 35 - 35
src/api/exeamLog.go

@@ -116,41 +116,41 @@ func LatestExamExportExcel(c *gin.Context, apictx *ApiSession) (interface{}, err
 	return nil, nil
 }
 
-func getTotalLearnTime(apictx *ApiSession, db string, uid string) (int32, error) {
-
-	// 可以查询learn_log_statistics,数据量小些
-	colls := apictx.CreateRepoCtx().Client.GetDbCollection(db, repo.CollectionLearnLogStatistics)
-
-	// colls := apictx.CreateRepoCtx().Client.GetDbCollection(db, repo.CollectionLearnLog)
-
-	// 定义聚合管道
-	pipeline := mongo.Pipeline{
-		{{Key: "$match", Value: bson.D{{Key: "uid", Value: uid}}}},
-		{{Key: "$group", Value: bson.D{
-			{Key: "_id", Value: "$uid"},
-			{Key: "totalLearnTime", Value: bson.D{{Key: "$sum", Value: "$learnTime"}}},
-		}}},
-	}
-
-	// 执行聚合管道
-	cursor, err := colls.Aggregate(apictx.CreateRepoCtx().Ctx, pipeline)
-	if err != nil {
-		log.Error(err)
-		return 0, err
-	}
-
-	// 遍历结果
-	var results []bson.M
-	if err = cursor.All(apictx.CreateRepoCtx().Ctx, &results); err != nil {
-		log.Error(err)
-		return 0, err
-	}
-	if len(results) > 0 {
-		return results[0]["totalLearnTime"].(int32), err
-	}
-
-	return 0, nil
-}
+// func getTotalLearnTime(apictx *ApiSession, db string, uid string) (int32, error) {
+
+// 	// 可以查询learn_log_statistics,数据量小些
+// 	colls := apictx.CreateRepoCtx().Client.GetDbCollection(db, repo.CollectionLearnLogStatistics)
+
+// 	// colls := apictx.CreateRepoCtx().Client.GetDbCollection(db, repo.CollectionLearnLog)
+
+// 	// 定义聚合管道
+// 	pipeline := mongo.Pipeline{
+// 		{{Key: "$match", Value: bson.D{{Key: "uid", Value: uid}}}},
+// 		{{Key: "$group", Value: bson.D{
+// 			{Key: "_id", Value: "$uid"},
+// 			{Key: "totalLearnTime", Value: bson.D{{Key: "$sum", Value: "$learnTime"}}},
+// 		}}},
+// 	}
+
+// 	// 执行聚合管道
+// 	cursor, err := colls.Aggregate(apictx.CreateRepoCtx().Ctx, pipeline)
+// 	if err != nil {
+// 		log.Error(err)
+// 		return 0, err
+// 	}
+
+// 	// 遍历结果
+// 	var results []bson.M
+// 	if err = cursor.All(apictx.CreateRepoCtx().Ctx, &results); err != nil {
+// 		log.Error(err)
+// 		return 0, err
+// 	}
+// 	if len(results) > 0 {
+// 		return results[0]["totalLearnTime"].(int32), err
+// 	}
+
+// 	return 0, nil
+// }
 
 func getHandleLatestExamLog(apictx *ApiSession, db string, examType string) ([]*HandleLatestExamLog, error) {
 	colls := apictx.CreateRepoCtx().Client.GetDbCollection(db, repo.CollectionExeamLog)