feat: gist & co-authors

This commit is contained in:
tdurieux
2026-05-04 13:10:44 +02:00
parent f0f6436370
commit f0bc53f093
24 changed files with 1707 additions and 158 deletions
@@ -0,0 +1,14 @@
import { model } from "mongoose";
import AnonymizedGistSchema from "./anonymizedGists.schema";
import {
IAnonymizedGistDocument,
IAnonymizedGistModel,
} from "./anonymizedGists.types";
const AnonymizedGistModel = model<IAnonymizedGistDocument>(
"AnonymizedGist",
AnonymizedGistSchema
) as IAnonymizedGistModel;
export default AnonymizedGistModel;
@@ -0,0 +1,68 @@
import { Schema } from "mongoose";
const AnonymizedGistSchema = new Schema({
gistId: {
type: String,
index: { unique: true },
},
status: {
type: String,
default: "preparing",
},
statusDate: Date,
statusMessage: String,
anonymizeDate: Date,
lastView: Date,
pageView: Number,
owner: Schema.Types.ObjectId,
conference: String,
source: {
gistId: String,
accessToken: String,
},
options: {
terms: [String],
expirationMode: { type: String },
expirationDate: Date,
update: Boolean,
image: Boolean,
link: Boolean,
title: Boolean,
body: Boolean,
comments: Boolean,
content: Boolean,
origin: Boolean,
username: Boolean,
date: Boolean,
},
dateOfEntry: {
type: Date,
default: new Date(),
},
gist: {
description: String,
isPublic: Boolean,
creationDate: Date,
updatedDate: Date,
ownerLogin: String,
files: [
{
filename: String,
content: String,
language: String,
size: Number,
type: String,
},
],
comments: [
{
body: String,
creationDate: Date,
updatedDate: Date,
author: String,
},
],
},
});
export default AnonymizedGistSchema;
@@ -0,0 +1,58 @@
import { Document, Model } from "mongoose";
import { RepositoryStatus } from "../../types";
export interface IAnonymizedGist {
gistId: string;
status?: RepositoryStatus;
statusMessage?: string;
statusDate: Date;
anonymizeDate: Date;
source: {
gistId: string;
accessToken?: string;
};
owner: string;
conference: string;
options: {
terms: string[];
expirationMode: "never" | "redirect" | "remove";
expirationDate?: Date;
update: boolean;
image: boolean;
link: boolean;
title: boolean;
body: boolean;
comments: boolean;
content: boolean;
origin: boolean;
username: boolean;
date: boolean;
};
pageView: number;
lastView: Date;
gist: {
description: string;
isPublic?: boolean;
creationDate: Date;
updatedDate: Date;
ownerLogin?: string;
files?: {
filename: string;
content: string;
language?: string;
size?: number;
type?: string;
}[];
comments?: {
body: string;
creationDate: Date;
updatedDate: Date;
author: string;
}[];
};
}
export interface IAnonymizedGistDocument extends IAnonymizedGist, Document {
setLastUpdated: (this: IAnonymizedGistDocument) => Promise<void>;
}
export interface IAnonymizedGistModel extends Model<IAnonymizedGistDocument> {}
@@ -20,6 +20,14 @@ const AnonymizedRepositorySchema = new Schema({
ref: "user",
index: true,
},
coauthors: [
{
username: { type: String, index: true },
githubId: { type: String },
photo: { type: String },
addedAt: { type: Date, default: Date.now },
},
],
conference: String,
source: {
type: { type: String },
@@ -17,6 +17,12 @@ export interface IAnonymizedRepository {
accessToken?: string;
};
owner: string;
coauthors?: {
username: string;
githubId?: string;
photo?: string;
addedAt?: Date;
}[];
truncatedFolders: string[];
conference: string;
options: {