mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-09-13 06:08:58 +02:00
perf: cut MongoDB scans in repository workflows (#780)
* Add repository name index * Optimize repository file counts * Optimize MongoDB query workloads
This commit is contained in:
@@ -14,7 +14,7 @@ const AnonymizedGistSchema = new Schema({
|
||||
anonymizeDate: Date,
|
||||
lastView: Date,
|
||||
pageView: Number,
|
||||
owner: Schema.Types.ObjectId,
|
||||
owner: { type: Schema.Types.ObjectId, index: true },
|
||||
conference: String,
|
||||
source: {
|
||||
gistId: String,
|
||||
|
||||
@@ -14,7 +14,7 @@ const AnonymizedPullRequestSchema = new Schema({
|
||||
anonymizeDate: Date,
|
||||
lastView: Date,
|
||||
pageView: Number,
|
||||
owner: Schema.Types.ObjectId,
|
||||
owner: { type: Schema.Types.ObjectId, index: true },
|
||||
conference: String,
|
||||
source: {
|
||||
pullRequestId: Number,
|
||||
|
||||
@@ -77,4 +77,15 @@ const AnonymizedRepositorySchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
AnonymizedRepositorySchema.index({ "source.repositoryName": 1 });
|
||||
AnonymizedRepositorySchema.index({ status: 1, statusDate: 1 });
|
||||
AnonymizedRepositorySchema.index({ lastView: 1 });
|
||||
AnonymizedRepositorySchema.index({ anonymizeDate: 1 });
|
||||
AnonymizedRepositorySchema.index({ status: 1, isReseted: 1, lastView: 1 });
|
||||
AnonymizedRepositorySchema.index({
|
||||
status: 1,
|
||||
isReseted: 1,
|
||||
"options.expirationDate": 1,
|
||||
});
|
||||
|
||||
export default AnonymizedRepositorySchema;
|
||||
|
||||
@@ -55,4 +55,7 @@ const RepositorySchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
RepositorySchema.index({ owners: 1 });
|
||||
RepositorySchema.index({ status: 1, endDate: 1 });
|
||||
|
||||
export default RepositorySchema;
|
||||
|
||||
@@ -13,6 +13,14 @@ const FileSchema = new Schema({
|
||||
});
|
||||
|
||||
FileSchema.index({ path: 1, repoId: 1 });
|
||||
FileSchema.index(
|
||||
{ repoId: 1, size: 1, path: 1 },
|
||||
{ name: "repoId_1_size_1_path_1" }
|
||||
);
|
||||
FileSchema.index(
|
||||
{ repoId: 1, path: 1, name: 1 },
|
||||
{ name: "repoId_1_path_1_name_1" }
|
||||
);
|
||||
|
||||
FileSchema.methods.toString = function () {
|
||||
return `${this.path}/${this.name}`;
|
||||
|
||||
@@ -58,4 +58,6 @@ const UserSchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
UserSchema.index({ dateOfEntry: 1 });
|
||||
|
||||
export default UserSchema;
|
||||
|
||||
Reference in New Issue
Block a user