mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-17 15:23:28 +02:00
feat: flatten file tree for better performance
This commit is contained in:
@@ -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[];
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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> {}
|
||||
Reference in New Issue
Block a user