Skip to content

Commit

Permalink
yuhh rest of ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
jaynagpaul committed Sep 13, 2024
1 parent 68da0f7 commit 25d61f9
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 1,050 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/deletion-policy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Run Deletion Policy on a CRON Schedule
on:
schedule:
- cron: "0 0 * * *"

jobs:
run_deletion_policy:
runs-on: ubuntu-latest
name: A job to run the deletion policy
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run Deletion Policy Action Step
uses: ./deletion-policy # Uses an action in the deletion-policy directory
id: deletion-policy
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
36 changes: 20 additions & 16 deletions api/src/models/base-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,34 @@ import mongoose, { Schema } from "mongoose";
import { BaseEvent, EventEnvironment } from "@/src/utils/types";
import ProjectModel from "@/src/models/project";

export const BaseEventSchema = new mongoose.Schema<BaseEvent>({
// NOTE: Ensure this is in sync with the BaseEventSchema in the deletion-policy package
export const BaseEventSchema = new mongoose.Schema<BaseEvent>(
{
category: {
type: String,
required: true,
type: String,
required: true,
},
subcategory: {
type: String,
required: true,
type: String,
required: true,
},
projectId: {
type: Schema.Types.ObjectId,
required: true,
ref: ProjectModel.modelName
type: Schema.Types.ObjectId,
required: true,
ref: ProjectModel.modelName,
},
environment: {
type: String,
required: true,
enum: Object.values(EventEnvironment),
default: EventEnvironment.DEVELOPMENT
}
}, { timestamps: true });
type: String,
required: true,
enum: Object.values(EventEnvironment),
default: EventEnvironment.DEVELOPMENT,
},
},
{ timestamps: true }
);

const BaseEventModel =
(mongoose.models.BaseEvent as mongoose.Model<BaseEvent>) ||
mongoose.model<BaseEvent>("BaseEvent", BaseEventSchema);
(mongoose.models.BaseEvent as mongoose.Model<BaseEvent>) ||
mongoose.model<BaseEvent>("BaseEvent", BaseEventSchema);

export default BaseEventModel;
41 changes: 22 additions & 19 deletions api/src/models/custom-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,35 @@ import { CustomEvent, EventEnvironment } from "@/src/utils/types";
import CustomEventTypeModel from "@/src/models/custom-event-type";
import ProjectModel from "./project";


const CustomEventSchema = new Schema<CustomEvent>({
// NOTE: Ensure this is in sync with the CustomEventSchema in the deletion-policy package
const CustomEventSchema = new Schema<CustomEvent>(
{
properties: {
type: Schema.Types.Mixed,
required: true
type: Schema.Types.Mixed,
required: true,
},
eventTypeId: {
type: Schema.Types.ObjectId,
required: true,
ref: CustomEventTypeModel.modelName
type: Schema.Types.ObjectId,
required: true,
ref: CustomEventTypeModel.modelName,
},
projectId: {
type: Schema.Types.ObjectId,
required: true,
ref: ProjectModel.modelName
type: Schema.Types.ObjectId,
required: true,
ref: ProjectModel.modelName,
},
environment: {
type: String,
required: true,
enum: Object.values(EventEnvironment),
default: EventEnvironment.DEVELOPMENT
}
}, { timestamps: true });
type: String,
required: true,
enum: Object.values(EventEnvironment),
default: EventEnvironment.DEVELOPMENT,
},
},
{ timestamps: true }
);

export const CustomEventModel =
(mongoose.models.CustomEvent as mongoose.Model<CustomEvent>) ||
mongoose.model<CustomEvent>("CustomEvent", CustomEventSchema);
(mongoose.models.CustomEvent as mongoose.Model<CustomEvent>) ||
mongoose.model<CustomEvent>("CustomEvent", CustomEventSchema);

export default CustomEventModel;
export default CustomEventModel;
53 changes: 28 additions & 25 deletions api/src/models/project.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
import mongoose from "mongoose";
import { Project } from "@/src/utils/types";

export const ProjectSchema = new mongoose.Schema<Project>({
// NOTE: Ensure this is in sync with the ProjectSchema in the deletion-policy package
export const ProjectSchema = new mongoose.Schema<Project>(
{
clientApiKey: {
type: String,
required: true,
type: String,
required: true,
},
serverApiKey: {
type: String,
required: true
type: String,
required: true,
},
projectName: {
type: String,
required: true,
unique: true
type: String,
required: true,
unique: true,
},
privateData: {
type: Boolean,
required: true,
default: false
type: Boolean,
required: true,
default: false,
},
deletionPolicy: {
type: Number,
required: true,
default: -1
}
},
{
timestamps: {
createdAt: true,
updatedAt: true
}
});
type: Number,
required: true,
default: -1,
},
},
{
timestamps: {
createdAt: true,
updatedAt: true,
},
}
);

const ProjectModel =
(mongoose.models.Project as mongoose.Model<Project>) ||
mongoose.model<Project>("Project", ProjectSchema);
(mongoose.models.Project as mongoose.Model<Project>) ||
mongoose.model<Project>("Project", ProjectSchema);

export default ProjectModel;
export default ProjectModel;
Loading

0 comments on commit 25d61f9

Please sign in to comment.