mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
add referrers bar chart
This commit is contained in:
@@ -7,7 +7,7 @@ export type MetricsTimeline = {
|
||||
count: number
|
||||
}
|
||||
|
||||
export async function getTimeline(model: Model<any>, project_id: string, slice: 'hour' | 'day' | 'month' | 'year' = 'day', duration?: number, customOptions: AggregateOptions = {}, customGroup: Object = {}, customProjection: Object = {}, customGroupId: Object = {}) {
|
||||
export async function getTimeline(model: Model<any>, project_id: string, slice: 'hour' | 'day' | 'month' | 'year' = 'day', duration?: number, customOptions: AggregateOptions = {}, customGroup: Object = {}, customProjection: Object = {}, customGroupId: Object = {}, customMatch: Object = {}) {
|
||||
|
||||
const groupId: any = {};
|
||||
const sort: any = {};
|
||||
@@ -53,7 +53,8 @@ export async function getTimeline(model: Model<any>, project_id: string, slice:
|
||||
{
|
||||
$match: {
|
||||
project_id: new Types.ObjectId(project_id),
|
||||
created_at: { $gte: from, $lte: to }
|
||||
created_at: { $gte: from, $lte: to },
|
||||
...customMatch
|
||||
}
|
||||
},
|
||||
{ $group: { _id: { ...groupId, ...customGroupId }, count: { $sum: 1 }, ...customGroup } },
|
||||
@@ -61,6 +62,7 @@ export async function getTimeline(model: Model<any>, project_id: string, slice:
|
||||
{ $project: { _id: { $dateFromParts: fromParts }, count: "$count", ...customProjection } }
|
||||
]
|
||||
|
||||
|
||||
const result: MetricsTimeline[] = await model.aggregate(aggregation, customOptions);
|
||||
|
||||
return { data: result, from, to };
|
||||
|
||||
Reference in New Issue
Block a user