mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
fix ai UI + add domain filter on visits
This commit is contained in:
@@ -14,7 +14,8 @@ const getVisitsCountsTool: AIPlugin_TTool<'getVisitsCount'> = {
|
||||
from: { type: 'string', description: 'ISO string of start date' },
|
||||
to: { type: 'string', description: 'ISO string of end date' },
|
||||
website: { type: 'string', description: 'The website of the visits' },
|
||||
page: { type: 'string', description: 'The page of the visit' }
|
||||
page: { type: 'string', description: 'The page of the visit' },
|
||||
domain: { type: 'string', description: 'Used only to filter a specific domain' }
|
||||
},
|
||||
required: ['from', 'to']
|
||||
}
|
||||
@@ -33,6 +34,7 @@ const getVisitsTimelineTool: AIPlugin_TTool<'getVisitsTimeline'> = {
|
||||
to: { type: 'string', description: 'ISO string of end date' },
|
||||
website: { type: 'string', description: 'The website of the visits' },
|
||||
page: { type: 'string', description: 'The page of the visit' },
|
||||
domain: { type: 'string', description: 'Used only to filter a specific domain' }
|
||||
},
|
||||
required: ['from', 'to']
|
||||
}
|
||||
@@ -45,14 +47,15 @@ export class AiVisits extends AIPlugin<['getVisitsCount', 'getVisitsTimeline']>
|
||||
|
||||
super({
|
||||
'getVisitsCount': {
|
||||
handler: async (data: { project_id: string, from: string, to: string, website?: string, page?: string }) => {
|
||||
handler: async (data: { project_id: string, from: string, to: string, website?: string, page?: string, domain?: string }) => {
|
||||
|
||||
const query: any = {
|
||||
project_id: data.project_id,
|
||||
created_at: {
|
||||
$gt: new Date(data.from),
|
||||
$lt: new Date(data.to),
|
||||
}
|
||||
},
|
||||
website: data.domain || { $ne: '_NODOMAIN_' }
|
||||
}
|
||||
|
||||
if (data.website) query.website = data.website;
|
||||
@@ -67,7 +70,7 @@ export class AiVisits extends AIPlugin<['getVisitsCount', 'getVisitsTimeline']>
|
||||
tool: getVisitsCountsTool
|
||||
},
|
||||
'getVisitsTimeline': {
|
||||
handler: async (data: { project_id: string, from: string, to: string, time_offset: number, website?: string, page?: string }) => {
|
||||
handler: async (data: { project_id: string, from: string, to: string, time_offset: number, website?: string, page?: string, domain?: string }) => {
|
||||
|
||||
const timelineData = await executeTimelineAggregation({
|
||||
projectId: new Types.ObjectId(data.project_id),
|
||||
@@ -75,7 +78,8 @@ export class AiVisits extends AIPlugin<['getVisitsCount', 'getVisitsTimeline']>
|
||||
from: data.from,
|
||||
to: data.to,
|
||||
slice: 'day',
|
||||
timeOffset: data.time_offset
|
||||
timeOffset: data.time_offset,
|
||||
domain: data.domain || { $ne: '_NODOMAIN_' } as any
|
||||
});
|
||||
return { data: timelineData };
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user