mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 15:58:38 +01:00
Fix
This commit is contained in:
@@ -8,7 +8,7 @@ export default defineEventHandler(async event => {
|
||||
|
||||
const { name } = await readBody(event);
|
||||
|
||||
if (name.trim()) return setResponseStatus(event, 400, 'name is required');
|
||||
if (name.trim().length == 0) return setResponseStatus(event, 400, 'name is required');
|
||||
if (name.trim().length < 2) return setResponseStatus(event, 400, 'name too short');
|
||||
if (name.trim().length > 32) return setResponseStatus(event, 400, 'name too long');
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ export default defineEventHandler(async event => {
|
||||
}
|
||||
|
||||
|
||||
const link = `http://127.0.0.1:3000/accept_invite?project_id=${project_id.toString()}`;
|
||||
const link = `https://dashboard.litlyx.com/accept_invite?project_id=${project_id.toString()}`;
|
||||
|
||||
if (!targetUser) {
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ export default defineEventHandler(async event => {
|
||||
})
|
||||
|
||||
for (const member of members) {
|
||||
const userMember = await UserModel.findById(member.user_id);
|
||||
const userMember = member.user_id ? await UserModel.findById(member.user_id) : await UserModel.findOne({ email: member.email });
|
||||
if (!userMember) continue;
|
||||
|
||||
const permission: TPermission = {
|
||||
|
||||
@@ -24,6 +24,28 @@ export default defineEventHandler(async event => {
|
||||
customProjection: {
|
||||
count: { $divide: ["$duration", "$count"] }
|
||||
},
|
||||
customQueries: [
|
||||
{
|
||||
index: 1,
|
||||
query: {
|
||||
"$lookup": {
|
||||
"from": "visits",
|
||||
"localField": "session",
|
||||
"foreignField": "session",
|
||||
"as": "visits",
|
||||
"pipeline": [{ "$limit": 1 }]
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
query: {
|
||||
"$match": {
|
||||
"visits.0": { "$exists": true }
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
const timelineFilledMerged = fillAndMergeTimelineAggregationV2(timelineData, slice, from, to);
|
||||
return timelineFilledMerged;
|
||||
|
||||
@@ -20,7 +20,8 @@ export type AdvancedTimelineAggregationOptions = TimelineAggregationOptions & {
|
||||
customGroup?: Record<string, any>,
|
||||
customProjection?: Record<string, any>,
|
||||
customIdGroup?: Record<string, any>,
|
||||
customAfterMatch?: Record<string, any>
|
||||
customAfterMatch?: Record<string, any>,
|
||||
customQueries?: { index: number, query: Record<string, any> }[]
|
||||
}
|
||||
|
||||
export async function executeAdvancedTimelineAggregation<T = {}>(options: AdvancedTimelineAggregationOptions) {
|
||||
@@ -29,6 +30,7 @@ export async function executeAdvancedTimelineAggregation<T = {}>(options: Advanc
|
||||
options.customGroup = options.customGroup || {};
|
||||
options.customProjection = options.customProjection || {};
|
||||
options.customIdGroup = options.customIdGroup || {};
|
||||
options.customQueries = options.customQueries || [];
|
||||
|
||||
const { dateFromParts, granularity } = DateService.getGranularityData(options.slice, '$tmpDate');
|
||||
if (!dateFromParts) throw Error('Slice is probably not correct');
|
||||
@@ -103,6 +105,9 @@ export async function executeAdvancedTimelineAggregation<T = {}>(options: Advanc
|
||||
}
|
||||
] as any[];
|
||||
|
||||
for (const customQuery of options.customQueries) {
|
||||
aggregation.splice(customQuery.index, 0, customQuery.query);
|
||||
}
|
||||
|
||||
if (options.customAfterMatch) aggregation.splice(1, 0, options.customAfterMatch);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user