Bladeren bron

fix warning

sunsheng 1 jaar geleden
bovenliggende
commit
b6b9b5c1d8
1 gewijzigde bestanden met toevoegingen van 36 en 36 verwijderingen
  1. 36 36
      src/api/statistics.go

+ 36 - 36
src/api/statistics.go

@@ -47,16 +47,16 @@ func StatisticsLearnProcess(c *gin.Context, apictx *ApiSession) (interface{}, er
 func AggregateMonthlyLearnTime(colls *mongo.Collection, uid string, learnType string, year int) ([]bson.M, error) {
 	pipeline := mongo.Pipeline{
 		{
-			{"$match", bson.D{
-				{"uid", uid},
-				{"createTime", bson.D{
-					{"$gte", bson.M{
+			{Key: "$match", Value: bson.D{
+				{Key: "uid", Value: uid},
+				{Key: "createTime", Value: bson.D{
+					{Key: "$gte", Value: bson.M{
 						"$dateFromParts": bson.M{
 							"year": year, "month": 1, "day": 1,
 							"timezone": "Asia/Shanghai",
 						},
 					}},
-					{"$lt", bson.M{
+					{Key: "$lt", Value: bson.M{
 						"$dateFromParts": bson.M{
 							"year": year + 1, "month": 1, "day": 1,
 							"timezone": "Asia/Shanghai",
@@ -66,24 +66,24 @@ func AggregateMonthlyLearnTime(colls *mongo.Collection, uid string, learnType st
 			}},
 		},
 		{
-			{"$project", bson.D{
-				{"month", bson.D{
-					{"$month", "$createTime"},
+			{Key: "$project", Value: bson.D{
+				{Key: "month", Value: bson.D{
+					{Key: "$month", Value: "$createTime"},
 				}},
-				{"learnTime", 1},
+				{Key: "learnTime", Value: 1},
 			}},
 		},
 		{
-			{"$group", bson.D{
-				{"_id", "$month"},
-				{"totalLearnTime", bson.D{
-					{"$sum", "$learnTime"},
+			{Key: "$group", Value: bson.D{
+				{Key: "_id", Value: "$month"},
+				{Key: "totalLearnTime", Value: bson.D{
+					{Key: "$sum", Value: "$learnTime"},
 				}},
 			}},
 		},
 		{
-			{"$sort", bson.D{
-				{"_id", 1},
+			{Key: "$sort", Value: bson.D{
+				{Key: "_id", Value: 1},
 			}},
 		},
 	}
@@ -151,15 +151,15 @@ func StatisticsTotalLearnTime(c *gin.Context, apictx *ApiSession) (interface{},
 func AggregateTotalLearnTime(colls *mongo.Collection, uid string) (int, error) {
 	pipeline := mongo.Pipeline{
 		{
-			{"$match", bson.D{
-				{"uid", uid},
+			{Key: "$match", Value: bson.D{
+				{Key: "uid", Value: uid},
 			}},
 		},
 		{
-			{"$group", bson.D{
-				{"_id", "$uid"},
-				{"totalLearnTime", bson.D{
-					{"$sum", "$learnTime"},
+			{Key: "$group", Value: bson.D{
+				{Key: "_id", Value: "$uid"},
+				{Key: "totalLearnTime", Value: bson.D{
+					{Key: "$sum", Value: "$learnTime"},
 				}},
 			}},
 		},
@@ -254,14 +254,14 @@ func StatisticsLearnedModules(c *gin.Context, apictx *ApiSession) (interface{},
 	colls := apictx.CreateRepoCtx().Client.GetDbCollection(db, repo.CollectionLearnLog)
 	pipeline := mongo.Pipeline{
 		{
-			{"$match", bson.D{
-				{"uid", uid},
+			{Key: "$match", Value: bson.D{
+				{Key: "uid", Value: uid},
 			}},
 		},
 		{
-			{"$group", bson.D{
-				{"_id", "$cid"},
-				{"totalLearnTime", bson.D{{"$sum", "$learnTime"}}},
+			{Key: "$group", Value: bson.D{
+				{Key: "_id", Value: "$cid"},
+				{Key: "totalLearnTime", Value: bson.D{{Key: "$sum", Value: "$learnTime"}}},
 			}},
 		},
 	}
@@ -305,16 +305,16 @@ func StatisticsExeamTFRate(c *gin.Context, apictx *ApiSession) (interface{}, err
 	colls := apictx.CreateRepoCtx().Client.GetDbCollection(db, repo.CollectionLearnLog)
 	pipeline := mongo.Pipeline{
 		{
-			{"$match", bson.D{
-				{"uid", uid},
-				{"createTime", bson.D{
-					{"$gte", bson.M{
+			{Key: "$match", Value: bson.D{
+				{Key: "uid", Value: uid},
+				{Key: "createTime", Value: bson.D{
+					{Key: "$gte", Value: bson.M{
 						"$dateFromParts": bson.M{
 							"year": year, "month": 1, "day": 1,
 							"timezone": "Asia/Shanghai",
 						},
 					}},
-					{"$lt", bson.M{
+					{Key: "$lt", Value: bson.M{
 						"$dateFromParts": bson.M{
 							"year": year + 1, "month": 1, "day": 1,
 							"timezone": "Asia/Shanghai",
@@ -323,12 +323,12 @@ func StatisticsExeamTFRate(c *gin.Context, apictx *ApiSession) (interface{}, err
 				}},
 			}},
 		},
-		{{"$group", bson.D{
-			{"_id", bson.D{{"month", bson.D{{"$month", "$createTime"}}}}},
-			{"totalCorrect", bson.D{{"$sum", "$correct"}}},
-			{"totalError", bson.D{{"$sum", "$error"}}},
+		{{Key: "$group", Value: bson.D{
+			{Key: "_id", Value: bson.D{{Key: "month", Value: bson.D{{Key: "$month", Value: "$createTime"}}}}},
+			{Key: "totalCorrect", Value: bson.D{{Key: "$sum", Value: "$correct"}}},
+			{Key: "totalError", Value: bson.D{{Key: "$sum", Value: "$error"}}},
 		}}},
-		{{"$sort", bson.D{{"_id.month", 1}}}},
+		{{Key: "$sort", Value: bson.D{{Key: "_id.month", Value: 1}}}},
 	}
 
 	cursor, err := colls.Aggregate(apictx.CreateRepoCtx().Ctx, pipeline)