-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: refine queries, endpoints, etc.
- Loading branch information
1 parent
125e9f2
commit 10f955f
Showing
22 changed files
with
111 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,35 @@ | ||
import { dbConnect } from "@/src/utils/db-connect"; | ||
import CustomGraphTypeModel from "@/src/models/custom-event-type"; | ||
import { CustomGraphType } from "@/src/utils/types"; | ||
import { CustomGraphType, GraphTypes } from "@/src/utils/types"; | ||
import CustomEventTypeModel from "@/src/models/custom-event-type"; | ||
|
||
|
||
export const createCustomGraphType = async (newGraph: Partial<CustomGraphType>) => { | ||
await dbConnect(); | ||
let eventTypeId = newGraph.eventTypeId | ||
let eventType = CustomGraphTypeModel.find({ _id: eventTypeId }) | ||
if (eventType == null) { | ||
//there is no event with this id for this projectId | ||
return; | ||
let eventType = await CustomEventTypeModel.findOne({ _id: eventTypeId }) | ||
if (!eventType) { | ||
return null; | ||
} | ||
let typeProperties = eventType.properties | ||
if (!typeProperties.includes("xProperty") || !typeProperties.includes("yProperty")) { | ||
//Checks if all the properties in event type are in the custom even properties | ||
return; | ||
let typeProperties = eventType.properties; | ||
if (!typeProperties.includes(newGraph.xProperty as string) || !typeProperties.includes(newGraph.yProperty as string)) { | ||
return null; | ||
} | ||
let type = newGraph.graphType | ||
if (type != "bar" && type != "line" && type != "scatter") { | ||
//graphType is not bar, line, or scatter | ||
return; | ||
|
||
if (!Object.values(GraphTypes).includes(newGraph.graphType as GraphTypes)) { | ||
return null; | ||
} | ||
const createdGraphType = await CustomGraphTypeModel.create(newGraph); | ||
return createdGraphType; | ||
} | ||
|
||
export const getCustomGraphTypes = async (eventTypeId: string, projectId: string) => { | ||
await dbConnect(); | ||
const graphTypes = await CustomGraphTypeModel.find({ eventTypeId, projectId}) | ||
const graphTypes = await CustomGraphTypeModel.find({ eventTypeId, projectId }) | ||
return graphTypes | ||
} | ||
export const deleteCustomGraphType = async (_id: string) => { | ||
await dbConnect(); | ||
const deletedGraphType = await CustomGraphTypeModel.deleteOne({_id}) | ||
const deletedGraphType = await CustomGraphTypeModel.deleteOne({ _id }) | ||
return deletedGraphType | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ const visitEventRoute = APIWrapper({ | |
eventProperties: { | ||
pageUrl, | ||
userId, | ||
date | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.