浏览代码

优化活动新增和删除的埋点问题

Li 2 年之前
父节点
当前提交
6f661f2483

+ 2 - 1
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -45,6 +45,8 @@ namespace TEAMModelOS.FunctionV4
                             continue;
                         }
                     }
+
+                    await BIStats.SetTypeAddStats(client, data.school, "Exam", -1,careDate:data.startTime);//BI统计增/减量
                     return;
                 }
                 ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(data.id, new Azure.Cosmos.PartitionKey($"{data.code}"));
@@ -123,7 +125,6 @@ namespace TEAMModelOS.FunctionV4
                                 await table.Save<ChangeRecord>(changeRecord);
                                 //await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
                             }
-                            await BIStats.SetTypeAddStats(client, info.school, "Exam", 1);//BI统计增/减量
                             break;
                         case "going":
 

+ 2 - 1
TEAMModelOS.FunctionV4/CosmosDB/TriggerHomework.cs

@@ -46,6 +46,8 @@ namespace TEAMModelOS.FunctionV4
                             continue;
                         }
                     }
+
+                    await BIStats.SetTypeAddStats(client, tdata.school, "Homework", -1, careDate: tdata.startTime);//BI统计增/减量
                     return;
                 }
                 var adid = tdata.id;
@@ -99,7 +101,6 @@ namespace TEAMModelOS.FunctionV4
                                 await table.Save<ChangeRecord>(changeRecord);
                             }
 
-                            await BIStats.SetTypeAddStats(client, work.school, "Homework", 1);//BI统计增/减量
                             break;
                         case "going":
 

+ 2 - 1
TEAMModelOS.FunctionV4/CosmosDB/TriggerStudy.cs

@@ -47,6 +47,8 @@ namespace TEAMModelOS.FunctionV4
                             continue;
                         }
                     }
+
+                    await BIStats.SetTypeAddStats(client, tdata.school, "Study", -1, careDate: tdata.startTime);//BI统计增/减量
                     return;
                 }
                 var adid = tdata.id;
@@ -100,7 +102,6 @@ namespace TEAMModelOS.FunctionV4
                                 };                                
                                 await table.Save<ChangeRecord>(changeRecord);
                             }
-                            await BIStats.SetTypeAddStats(client, study.school, "Study", 1);//BI统计增/减量
                             break;
                         case "going":
                             try {

+ 2 - 1
TEAMModelOS.FunctionV4/CosmosDB/TriggerSurvey.cs

@@ -54,6 +54,8 @@ namespace TEAMModelOS.FunctionV4
                             continue;
                         }
                     }
+
+                    await BIStats.SetTypeAddStats(client, tdata.school, "Survey", -1,careDate: tdata.startTime);//BI统计增/减量
                     return;
                 }
                 var adid = tdata.id;
@@ -106,7 +108,6 @@ namespace TEAMModelOS.FunctionV4
                                 };                                
                                 await table.Save<ChangeRecord>(changeRecord);
                             }
-                            await BIStats.SetTypeAddStats(client, survey.school, "Survey", 1);//BI统计增/减量
                             break;
                         case "going":
                             List<(string pId, List<string> gid)> ps = new List<(string pId, List<string> gid)>();

+ 2 - 1
TEAMModelOS.FunctionV4/CosmosDB/TriggerVote.cs

@@ -52,6 +52,8 @@ namespace TEAMModelOS.FunctionV4
                             continue;
                         }
                     }
+
+                    await BIStats.SetTypeAddStats(client, tdata.school, "Vote", -1, careDate: tdata.startTime);//BI统计增/减量
                     return;
                 }
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("ChangeRecord");
@@ -102,7 +104,6 @@ namespace TEAMModelOS.FunctionV4
                                 };                                
                                 await table.Save<ChangeRecord>(changeRecord);
                             }
-                            await BIStats.SetTypeAddStats(client, vote.school, "Vote", 1);//BI统计增/减量
                             break;
                         case "going":
                             List<(string pId, List<string> gid)> ps = new List<(string pId, List<string> gid)>();

+ 3 - 0
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -32,6 +32,7 @@ using Item = TEAMModelOS.SDK.Models.Cosmos.Common.Item;
 using DocumentFormat.OpenXml.Office2016.Excel;
 using OpenXmlPowerTools;
 using TEAMModelOS.SDK.Services;
+using TEAMModelOS.SDK.Models.Service.BI;
 
 namespace TEAMModelOS.Controllers
 {
@@ -265,6 +266,8 @@ namespace TEAMModelOS.Controllers
                             simple.sheet = null;
                         }
                         exam = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+
+                        await BIStats.SetTypeAddStats(client, exam.school, "Exam", 1);//BI统计增/减量
                     }
                 }
                 return Ok(new { exam });

+ 5 - 0
TEAMModelOS/Controllers/Common/HomeworkController.cs

@@ -29,6 +29,7 @@ using Azure.Storage.Blobs.Models;
 using static TEAMModelOS.SDK.SchoolService;
 using DocumentFormat.OpenXml.Office2010.Excel;
 using TEAMModelOS.SDK.Services;
+using TEAMModelOS.SDK.Models.Service.BI;
 
 namespace TEAMModelOS.Controllers.Learn
 {
@@ -130,6 +131,8 @@ namespace TEAMModelOS.Controllers.Learn
                     var cods = new { records = new List<string>(), userids = new List<string>(), question = new List<QuestionRecord>() };
                     await _azureStorage.GetBlobContainerClient(blobcntr).UploadFileByContainer(cods.ToJsonString(), "homework", $"{homework.id}/record.json");
                     homework = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(homework, new PartitionKey($"{homework.code}"));
+
+                    await BIStats.SetTypeAddStats(client, homework.school, "Homework", 1);//BI统计增/减量
                 }
                 else
                 {
@@ -189,6 +192,8 @@ namespace TEAMModelOS.Controllers.Learn
                         var cods = new { records = new List<string>(), userids = new List<string>(), question = new List<QuestionRecord>() };
                         await _azureStorage.GetBlobContainerClient(blobcntr).UploadFileByContainer(cods.ToJsonString(), "homework", $"{homework.id}/record.json");
                         homework = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(homework, new PartitionKey($"{homework.code}"));
+
+                        await BIStats.SetTypeAddStats(client, homework.school, "Homework", 1);//BI统计增/减量
                     }
                 }
                 return Ok(new { homework });

+ 2 - 0
TEAMModelOS/Controllers/Common/StudyController.cs

@@ -24,6 +24,7 @@ using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Service;
+using TEAMModelOS.SDK.Models.Service.BI;
 
 namespace TEAMModelOS.Controllers.Common
 {
@@ -90,6 +91,7 @@ namespace TEAMModelOS.Controllers.Common
                 {
                     study.id = Guid.NewGuid().ToString();
                     await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(study, new PartitionKey($"{study.code}"));
+                    await BIStats.SetTypeAddStats(client, study.school, "Study", 1);//BI统计增/减量
                 }
                 else
                 {

+ 5 - 0
TEAMModelOS/Controllers/Common/SurveyController.cs

@@ -28,6 +28,7 @@ using Microsoft.Extensions.Configuration;
 using System.IO;
 using Microsoft.AspNetCore.Authorization;
 using TEAMModelOS.SDK.Services;
+using TEAMModelOS.SDK.Models.Service.BI;
 
 namespace TEAMModelOS.Controllers
 {
@@ -121,6 +122,8 @@ namespace TEAMModelOS.Controllers
                     var cods = new { records = new List<string>(), userids = new List<string>(), question = new List<QuestionRecord>() };
                     await _azureStorage.GetBlobContainerClient(blobcntr).UploadFileByContainer(cods.ToJsonString(), "survey", $"{request.id}/record.json");
                     request = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+
+                    await BIStats.SetTypeAddStats(client, request.school, "Survey", 1);//BI统计增/减量
                 }
                 else
                 {
@@ -178,6 +181,8 @@ namespace TEAMModelOS.Controllers
                         var cods = new { records = new List<string>(), userids = new List<string>(), question = new List<QuestionRecord>() };
                         await _azureStorage.GetBlobContainerClient(blobcntr).UploadFileByContainer(cods.ToJsonString(), "survey", $"{request.id}/record.json");
                         request = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+
+                        await BIStats.SetTypeAddStats(client, request.school, "Survey", 1);//BI统计增/减量
                     }
                 }
                 return Ok(new { survey = request });

+ 5 - 0
TEAMModelOS/Controllers/Common/VoteController.cs

@@ -17,6 +17,7 @@ using Microsoft.Extensions.Configuration;
 using Microsoft.AspNetCore.Authorization;
 using TEAMModelOS.SDK.Services;
 using DocumentFormat.OpenXml.Office2013.Excel;
+using TEAMModelOS.SDK.Models.Service.BI;
 
 namespace TEAMModelOS.Controllers
 {
@@ -109,6 +110,8 @@ namespace TEAMModelOS.Controllers
                     request.recordUrl = url;
                     await _azureStorage.GetBlobContainerClient(blobcntr).UploadFileByContainer(new { options = new List<string>(), records = new List<VoteRecord>() }.ToJsonString(), "vote", $"{request.id}/record.json");
                     request = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+
+                    await BIStats.SetTypeAddStats(client, request.school, "Vote", 1);//BI统计增/减量
                 }
                 else
                 {
@@ -168,6 +171,8 @@ namespace TEAMModelOS.Controllers
                         request.recordUrl = url;
                         await _azureStorage.GetBlobContainerClient(blobcntr).UploadFileByContainer(new { options = new List<string>(), records = new List<VoteRecord>() }.ToJsonString(), "vote", $"{request.id}/record.json");
                         request = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
+
+                        await BIStats.SetTypeAddStats(client, request.school, "Vote", 1);//BI统计增/减量
                     }
                 }
                 return Ok(new { vote = request });