mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-06 21:57:57 +02:00
chore: remove all reference to originalFiles
This commit is contained in:
+3
-8
@@ -130,14 +130,9 @@ export default class User {
|
|||||||
const span = trace.getTracer("ano-file").startSpan("User.getRepositories");
|
const span = trace.getTracer("ano-file").startSpan("User.getRepositories");
|
||||||
span.setAttribute("username", this.username);
|
span.setAttribute("username", this.username);
|
||||||
const repositories = (
|
const repositories = (
|
||||||
await AnonymizedRepositoryModel.find(
|
await AnonymizedRepositoryModel.find({
|
||||||
{
|
owner: this.id,
|
||||||
owner: this.id,
|
}).exec()
|
||||||
},
|
|
||||||
{
|
|
||||||
originalFiles: 0,
|
|
||||||
}
|
|
||||||
).exec()
|
|
||||||
).map((d) => new Repository(d));
|
).map((d) => new Repository(d));
|
||||||
const promises = [];
|
const promises = [];
|
||||||
for (let repo of repositories) {
|
for (let repo of repositories) {
|
||||||
|
|||||||
+2
-16
@@ -24,28 +24,14 @@ export async function connect() {
|
|||||||
return database;
|
return database;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getRepository(
|
export async function getRepository(repoId: string, opts: {} = {}) {
|
||||||
repoId: string,
|
|
||||||
opts: {
|
|
||||||
includeFiles: boolean;
|
|
||||||
} = {
|
|
||||||
includeFiles: true,
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
if (!repoId || repoId == "undefined") {
|
if (!repoId || repoId == "undefined") {
|
||||||
throw new AnonymousError("repo_not_found", {
|
throw new AnonymousError("repo_not_found", {
|
||||||
object: repoId,
|
object: repoId,
|
||||||
httpStatus: 404,
|
httpStatus: 404,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const project: any = {};
|
const data = await AnonymizedRepositoryModel.findOne({ repoId }).collation({
|
||||||
if (!opts.includeFiles) {
|
|
||||||
project.originalFiles = 0;
|
|
||||||
}
|
|
||||||
const data = await AnonymizedRepositoryModel.findOne(
|
|
||||||
{ repoId },
|
|
||||||
project
|
|
||||||
).collation({
|
|
||||||
locale: "en",
|
locale: "en",
|
||||||
strength: 2,
|
strength: 2,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -152,13 +152,10 @@ router.get("/repos", async (req, res) => {
|
|||||||
}
|
}
|
||||||
const skipIndex = (page - 1) * limit;
|
const skipIndex = (page - 1) * limit;
|
||||||
const [total, results] = await Promise.all([
|
const [total, results] = await Promise.all([
|
||||||
AnonymizedRepositoryModel.find(
|
AnonymizedRepositoryModel.find({
|
||||||
{
|
$and: query,
|
||||||
$and: query,
|
}).countDocuments(),
|
||||||
},
|
AnonymizedRepositoryModel.find({ $and: query })
|
||||||
{ originalFiles: 0 }
|
|
||||||
).countDocuments(),
|
|
||||||
AnonymizedRepositoryModel.find({ $and: query }, { originalFiles: 0 })
|
|
||||||
.skip(skipIndex)
|
.skip(skipIndex)
|
||||||
.sort(sort)
|
.sort(sort)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
|
|||||||
@@ -480,7 +480,7 @@ router.post("/", async (req: express.Request, res: express.Response) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
await db.getRepository(repoUpdate.repoId, { includeFiles: false });
|
await db.getRepository(repoUpdate.repoId);
|
||||||
throw new AnonymousError("repoId_already_used", {
|
throw new AnonymousError("repoId_already_used", {
|
||||||
httpStatus: 400,
|
httpStatus: 400,
|
||||||
object: repoUpdate,
|
object: repoUpdate,
|
||||||
|
|||||||
Reference in New Issue
Block a user