feat: flatten file tree for better performance

This commit is contained in:
tdurieux
2024-04-26 10:31:57 +01:00
parent ccdc95e4a8
commit 710f7328e7
23 changed files with 516 additions and 514 deletions
@@ -34,7 +34,6 @@ const AnonymizedRepositorySchema = new Schema({
type: Boolean,
default: false,
},
originalFiles: Schema.Types.Mixed,
options: {
terms: [String],
expirationMode: { type: String },
@@ -1,5 +1,5 @@
import { Document, Model } from "mongoose";
import { RepositoryStatus, Tree } from "../../types";
import { RepositoryStatus } from "../../types";
export interface IAnonymizedRepository {
repoId: string;
@@ -11,14 +11,13 @@ export interface IAnonymizedRepository {
type: "GitHubDownload" | "GitHubStream" | "Zip";
branch?: string;
commit?: string;
commitDate?: Date,
commitDate?: Date;
repositoryId?: string;
repositoryName?: string;
accessToken?: string;
};
owner: string;
truckedFileList: boolean;
originalFiles?: Tree;
conference: string;
options: {
terms: string[];
+8
View File
@@ -0,0 +1,8 @@
import { model } from "mongoose";
import { join } from "path";
import { IFileDocument, IFileModel } from "./files.types";
import FileSchema from "./files.schema";
const FileModel = model<IFileDocument>("File", FileSchema) as IFileModel;
export default FileModel;
+19
View File
@@ -0,0 +1,19 @@
import { Schema } from "mongoose";
const FileSchema = new Schema({
name: { type: String, index: true },
path: { type: String, index: true },
repoId: { type: String, index: true },
sha: {
type: String,
},
size: {
type: Number,
},
});
FileSchema.methods.toString = function () {
return `${this.path}/${this.name}`;
};
export default FileSchema;
+14
View File
@@ -0,0 +1,14 @@
import { Document, Model } from "mongoose";
export interface IFile {
name: string;
path: string;
repoId: string;
sha?: string;
size?: number;
}
export interface IFileDocument extends IFile, Document {
toString: (this: IFileDocument) => string;
}
export interface IFileModel extends Model<IFileDocument> {}