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