mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-02-13 02:42:45 +00:00
perf: improve the perf of Anonymous GitHub
This commit is contained in:
@@ -21,14 +21,25 @@ export async function connect() {
|
||||
return database;
|
||||
}
|
||||
|
||||
export async function getRepository(repoId: string) {
|
||||
export async function getRepository(
|
||||
repoId: string,
|
||||
opts: {
|
||||
includeFiles: boolean;
|
||||
} = {
|
||||
includeFiles: true,
|
||||
}
|
||||
) {
|
||||
if (!repoId || repoId == "undefined") {
|
||||
throw new AnonymousError("repo_not_found", {
|
||||
object: repoId,
|
||||
httpStatus: 404,
|
||||
});
|
||||
}
|
||||
const data = await AnonymizedRepositoryModel.findOne({ repoId });
|
||||
const project: any = {};
|
||||
if (!opts.includeFiles) {
|
||||
project.originalFiles = 0;
|
||||
}
|
||||
const data = await AnonymizedRepositoryModel.findOne({ repoId }, project);
|
||||
if (!data)
|
||||
throw new AnonymousError("repo_not_found", {
|
||||
object: repoId,
|
||||
|
||||
Reference in New Issue
Block a user