mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-11 00:08:37 +01:00
new selfhosted version
This commit is contained in:
22
dashboard/server/controllers/DomainController.ts
Normal file
22
dashboard/server/controllers/DomainController.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { endOfDay, startOfDay } from "date-fns";
|
||||
import { Types } from "mongoose";
|
||||
import { VisitModel } from "~/shared/schema/metrics/VisitSchema";
|
||||
|
||||
|
||||
type DomainsListOptions = {
|
||||
project_id: string,
|
||||
date: Date
|
||||
}
|
||||
|
||||
export async function getAllDomains(options: DomainsListOptions) {
|
||||
const domains = await VisitModel.aggregate([
|
||||
{
|
||||
$match: {
|
||||
project_id: new Types.ObjectId(options.project_id),
|
||||
created_at: { $gte: startOfDay(options.date), $lte: endOfDay(options.date) }
|
||||
},
|
||||
},
|
||||
{ $group: { _id: "$website" } }
|
||||
]);
|
||||
return domains.map(e => e._id) as string[];
|
||||
}
|
||||
Reference in New Issue
Block a user