|
|
@@ -140,12 +140,14 @@ class MessageRecordController {
|
|
|
*/
|
|
|
public getOverallStatistics = async (req: Request, res: Response): Promise<Response> => {
|
|
|
try {
|
|
|
+ console.time("getOverallStatistics");
|
|
|
const { startDate, endDate, strategyName } = req.query;
|
|
|
const start = startDate ? new Date(startDate as string) : undefined;
|
|
|
const end = endDate ? new Date(endDate as string) : undefined;
|
|
|
const stratName = strategyName ? (strategyName as string) : undefined;
|
|
|
|
|
|
const stats = await this.messageRecordService.getOverallStatistics(start, end, stratName);
|
|
|
+ console.timeEnd("getOverallStatistics");
|
|
|
|
|
|
return res.status(200).json({ success: true, data: stats });
|
|
|
} catch (error: any) {
|
|
|
@@ -162,10 +164,13 @@ class MessageRecordController {
|
|
|
*/
|
|
|
public getStatisticsByActivity = async (req: Request, res: Response): Promise<Response> => {
|
|
|
try {
|
|
|
+ console.time("getStatisticsByActivity");
|
|
|
const { startDate, endDate } = req.query;
|
|
|
const start = startDate ? new Date(startDate as string) : undefined;
|
|
|
const end = endDate ? new Date(endDate as string) : undefined;
|
|
|
const stats = await this.messageRecordService.getStatisticsByActivity(start, end);
|
|
|
+ console.timeEnd("getStatisticsByActivity");
|
|
|
+
|
|
|
return res.status(200).json({ success: true, data: stats });
|
|
|
} catch (error: any) {
|
|
|
console.error("Error fetching statistics by activity:", error);
|
|
|
@@ -181,11 +186,13 @@ class MessageRecordController {
|
|
|
*/
|
|
|
public getStatisticsByStrategy = async (req: Request, res: Response): Promise<Response> => {
|
|
|
try {
|
|
|
+ console.time("getStatisticsByStrategy");
|
|
|
const { startDate, endDate, strategyName } = req.query;
|
|
|
const start = startDate ? new Date(startDate as string) : undefined;
|
|
|
const end = endDate ? new Date(endDate as string) : undefined;
|
|
|
const stratName = strategyName ? (strategyName as string) : undefined;
|
|
|
const stats = await this.messageRecordService.getStatisticsByStrategy(start, end, stratName);
|
|
|
+ console.timeEnd("getStatisticsByStrategy");
|
|
|
return res.status(200).json({ success: true, data: stats });
|
|
|
} catch (error: any) {
|
|
|
console.error("Error fetching statistics by strategy:", error);
|
|
|
@@ -201,12 +208,14 @@ class MessageRecordController {
|
|
|
*/
|
|
|
public getStatisticsByTemplate = async (req: Request, res: Response): Promise<Response> => {
|
|
|
try {
|
|
|
+ console.time("getStatisticsByTemplate");
|
|
|
// 从查询参数中获取 startDate, endDate 和 strategyName
|
|
|
const { startDate, endDate, strategyName } = req.query;
|
|
|
const start = startDate ? new Date(startDate as string) : undefined;
|
|
|
const end = endDate ? new Date(endDate as string) : undefined;
|
|
|
const stratName = strategyName ? (strategyName as string) : undefined;
|
|
|
const stats = await this.messageRecordService.getStatisticsByTemplate(start, end, stratName);
|
|
|
+ console.timeEnd("getStatisticsByTemplate");
|
|
|
return res.status(200).json({ success: true, data: stats });
|
|
|
} catch (error: any) {
|
|
|
console.error("Error fetching statistics by template:", error);
|
|
|
@@ -222,12 +231,14 @@ class MessageRecordController {
|
|
|
*/
|
|
|
public getStatisticsByCc = async (req: Request, res: Response): Promise<Response> => {
|
|
|
try {
|
|
|
+ console.time("getStatisticsByCc");
|
|
|
// 从查询参数中获取 startDate, endDate 和 strategyName
|
|
|
const { startDate, endDate, strategyName } = req.query;
|
|
|
const start = startDate ? new Date(startDate as string) : undefined;
|
|
|
const end = endDate ? new Date(endDate as string) : undefined;
|
|
|
const stratName = strategyName ? (strategyName as string) : undefined;
|
|
|
const stats = await this.messageRecordService.getStatisticsByCc(start, end, stratName);
|
|
|
+ console.timeEnd("getStatisticsByCc");
|
|
|
return res.status(200).json({ success: true, data: stats });
|
|
|
} catch (error: any) {
|
|
|
console.error("Error fetching statistics by cc:", error);
|
|
|
@@ -243,12 +254,14 @@ class MessageRecordController {
|
|
|
*/
|
|
|
public getStatisticsByImage = async (req: Request, res: Response): Promise<Response> => {
|
|
|
try {
|
|
|
+ console.time("getStatisticsByImage");
|
|
|
// 从查询参数中获取 startDate, endDate 和 strategyName
|
|
|
const { startDate, endDate, strategyName } = req.query;
|
|
|
const start = startDate ? new Date(startDate as string) : undefined;
|
|
|
const end = endDate ? new Date(endDate as string) : undefined;
|
|
|
const stratName = strategyName ? (strategyName as string) : undefined;
|
|
|
const stats = await this.messageRecordService.getStatisticsByImage(start, end, stratName);
|
|
|
+ console.timeEnd("getStatisticsByImage");
|
|
|
return res.status(200).json({ success: true, data: stats });
|
|
|
} catch (error: any) {
|
|
|
console.error("Error fetching statistics by image:", error);
|
|
|
@@ -264,12 +277,14 @@ class MessageRecordController {
|
|
|
*/
|
|
|
public getDailySentTrends = async (req: Request, res: Response): Promise<Response> => {
|
|
|
try {
|
|
|
+ console.time("getDailySentTrends");
|
|
|
// 从查询参数中获取 startDate, endDate 和 strategyName
|
|
|
const { startDate, endDate, strategyName } = req.query;
|
|
|
const start = startDate ? new Date(startDate as string) : undefined;
|
|
|
const end = endDate ? new Date(endDate as string) : undefined;
|
|
|
const stratName = strategyName ? (strategyName as string) : undefined;
|
|
|
const stats = await this.messageRecordService.getDailySentTrends(start, end, stratName);
|
|
|
+ console.timeEnd("getDailySentTrends");
|
|
|
return res.status(200).json({ success: true, data: stats });
|
|
|
} catch (error: any) {
|
|
|
console.error("Error fetching daily sent trends:", error);
|
|
|
@@ -285,6 +300,7 @@ class MessageRecordController {
|
|
|
*/
|
|
|
public getMultiDimensionalStatistics = async (req: Request, res: Response): Promise<Response> => {
|
|
|
try {
|
|
|
+ console.time("getMultiDimensionalStatistics");
|
|
|
const { startDate, endDate, templateName, strategyName, cc, image } = req.query;
|
|
|
|
|
|
const filters: { [key: string]: any } = {};
|
|
|
@@ -296,6 +312,8 @@ class MessageRecordController {
|
|
|
if (image) filters.image = image;
|
|
|
|
|
|
const stats = await this.messageRecordService.getMultiDimensionalStatistics(filters);
|
|
|
+ console.timeEnd("getMultiDimensionalStatistics");
|
|
|
+
|
|
|
return res.status(200).json({ success: true, data: stats });
|
|
|
} catch (error: any) {
|
|
|
console.error("Error fetching multi-dimensional statistics:", error);
|
|
|
@@ -311,6 +329,7 @@ class MessageRecordController {
|
|
|
*/
|
|
|
public getDailyTrendsByCc = async (req: Request, res: Response): Promise<Response> => {
|
|
|
try {
|
|
|
+ console.time("getDailyTrendsByCc");
|
|
|
const { cc } = req.params;
|
|
|
// 从查询参数中获取 startDate, endDate 和 strategyName
|
|
|
const { startDate, endDate, strategyName } = req.query;
|
|
|
@@ -323,6 +342,7 @@ class MessageRecordController {
|
|
|
}
|
|
|
|
|
|
const stats = await this.messageRecordService.getDailyTrendsByCc(cc as string, start, end, stratName);
|
|
|
+ console.timeEnd("getDailyTrendsByCc");
|
|
|
return res.status(200).json({ success: true, data: stats });
|
|
|
} catch (error: any) {
|
|
|
console.error("Error fetching daily trends by cc:", error);
|
|
|
@@ -338,6 +358,7 @@ class MessageRecordController {
|
|
|
*/
|
|
|
public getDailyTrendsByStrategy = async (req: Request, res: Response): Promise<Response> => {
|
|
|
try {
|
|
|
+ console.time("getDailyTrendsByStrategy");
|
|
|
const { strategyName } = req.params;
|
|
|
|
|
|
// 从查询参数中获取 startDate, endDate
|
|
|
@@ -350,6 +371,7 @@ class MessageRecordController {
|
|
|
}
|
|
|
|
|
|
const stats = await this.messageRecordService.getDailyTrendsByStrategy(strategyName as string, start, end);
|
|
|
+ console.timeEnd("getDailyTrendsByStrategy");
|
|
|
return res.status(200).json({ success: true, data: stats });
|
|
|
} catch (error: any) {
|
|
|
console.error("Error fetching daily trends by strategy:", error);
|
|
|
@@ -365,6 +387,7 @@ class MessageRecordController {
|
|
|
*/
|
|
|
public getDailyTrendsByTemplate = async (req: Request, res: Response): Promise<Response> => {
|
|
|
try {
|
|
|
+ console.time("getDailyTrendsByTemplate");
|
|
|
const { templateName } = req.params;
|
|
|
// 从查询参数中获取 startDate, endDate 和 strategyName
|
|
|
const { startDate, endDate, strategyName } = req.query;
|
|
|
@@ -377,6 +400,7 @@ class MessageRecordController {
|
|
|
}
|
|
|
|
|
|
const stats = await this.messageRecordService.getDailyTrendsByTemplate(templateName as string, start, end, stratName);
|
|
|
+ console.timeEnd("getDailyTrendsByTemplate");
|
|
|
return res.status(200).json({ success: true, data: stats });
|
|
|
} catch (error: any) {
|
|
|
console.error("Error fetching daily trends by template:", error);
|
|
|
@@ -392,6 +416,7 @@ class MessageRecordController {
|
|
|
*/
|
|
|
public getDailyTrendsByImage = async (req: Request, res: Response): Promise<Response> => {
|
|
|
try {
|
|
|
+ console.time("getDailyTrendsByImage");
|
|
|
const { image } = req.params;
|
|
|
|
|
|
// 从查询参数中获取 startDate, endDate 和 strategyName
|
|
|
@@ -405,6 +430,7 @@ class MessageRecordController {
|
|
|
}
|
|
|
|
|
|
const stats = await this.messageRecordService.getDailyTrendsByImage(image as string, start, end, stratName);
|
|
|
+ console.timeEnd("getDailyTrendsByImage");
|
|
|
return res.status(200).json({ success: true, data: stats });
|
|
|
} catch (error: any) {
|
|
|
console.error("Error fetching daily trends by image:", error);
|