import { repositoryAccessSchema } from "../repository-access.schema"; import { Schema } from "mongoose"; const AnonymizedPullRequestSchema = new Schema({ pullRequestId: { type: String, index: { unique: true }, }, status: { type: String, default: "preparing", }, statusDate: Date, statusMessage: String, anonymizeDate: Date, lastView: Date, pageView: Number, owner: { type: Schema.Types.ObjectId, index: true }, githubAccess: { type: repositoryAccessSchema, default: undefined }, conference: String, source: { pullRequestId: Number, repositoryFullName: String, accessToken: { type: String, select: false }, }, options: { terms: [String], expirationMode: { type: String }, expirationDate: Date, update: Boolean, image: Boolean, link: Boolean, title: Boolean, body: Boolean, comments: Boolean, diff: Boolean, origin: Boolean, username: Boolean, date: Boolean, }, dateOfEntry: { type: Date, default: Date.now, }, pullRequest: { diff: String, title: String, body: String, creationDate: Date, updatedDate: Date, draft: Boolean, merged: Boolean, mergedDate: Date, state: String, baseRepositoryFullName: String, headRepositoryFullName: String, comments: [ { body: String, creationDate: Date, updatedDate: Date, author: String, }, ], }, }); AnonymizedPullRequestSchema.index({ status: 1, "options.expirationDate": 1 }); export default AnonymizedPullRequestSchema;