mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
fix emails templates
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"dev": "node scripts/start_dev.js",
|
||||
"compile": "tsc",
|
||||
"build_project": "node ../scripts/build.js",
|
||||
"build": "npm run compile && npm run build"
|
||||
"build": "npm run compile && npm run build_project"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Emily",
|
||||
|
||||
@@ -2,9 +2,11 @@ import DateService, { Slice } from '@services/DateService';
|
||||
import { Model, Types } from "mongoose";
|
||||
|
||||
|
||||
export async function getAggregation(model: Model<any>, pid: Types.ObjectId, from: number, to: number, slice: Slice) {
|
||||
export async function getDayAggregation(model: Model<any>, pid: Types.ObjectId, from: number, to: number) {
|
||||
|
||||
const { group, sort, fromParts } = DateService.getQueryDateRange(slice);
|
||||
const sort = { created_at: 1 };
|
||||
const group = { $dateToString: { format: "%Y-%m-%d", date: "$created_at" } };
|
||||
const fromParts = { year: { $year: "$created_at" }, month: { $month: "$created_at" }, day: { $dayOfMonth: "$created_at" } };
|
||||
|
||||
const result = model.aggregate([
|
||||
{
|
||||
@@ -16,7 +18,7 @@ export async function getAggregation(model: Model<any>, pid: Types.ObjectId, fro
|
||||
{ $group: { _id: group, count: { $sum: 1 } } },
|
||||
{ $sort: sort },
|
||||
{ $project: { _id: { $dateFromParts: fromParts }, count: "$count" } }
|
||||
]);
|
||||
] as any);
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { VisitModel } from '@schema/metrics/VisitSchema'
|
||||
|
||||
import * as url from 'url';
|
||||
import { ProjectModel } from "@schema/project/ProjectSchema";
|
||||
import { getAggregation } from "./Aggregations";
|
||||
import { getDayAggregation } from "./Aggregations";
|
||||
|
||||
type TAvgInput = { _id: string, count: number }
|
||||
|
||||
@@ -75,9 +75,9 @@ export async function findAnomalies(project_id: string, callback: AnomalyCallbac
|
||||
const from = Date.now() - 1000 * 60 * 60 * 24 * 30;
|
||||
const to = Date.now() - 1000 * 60 * 60 * 24;
|
||||
|
||||
const visitsTimelineData = await getAggregation(VisitModel, pid, from, to, 'day');
|
||||
const visitsTimelineData = await getDayAggregation(VisitModel, pid, from, to);
|
||||
|
||||
const eventsTimelineData = await getAggregation(EventModel, pid, from, to, 'day');
|
||||
const eventsTimelineData = await getDayAggregation(EventModel, pid, from, to);
|
||||
|
||||
|
||||
const websites: { _id: string, count: number }[] = await VisitModel.aggregate([
|
||||
|
||||
Reference in New Issue
Block a user