Skip to content

Commit

Permalink
remove contributions with pack
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Jan 17, 2024
1 parent 671df3c commit 1360bbd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/v2/repository/firestorm/packs.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
PackSearch,
FirestormPack,
} from "~/v2/interfaces";
import { packs } from "../../firestorm";
import { contributions, packs } from "../../firestorm";
import SubmissionFirestormRepository from "./submissions.repository";

export default class PackFirestormRepository implements PackRepository {
Expand Down Expand Up @@ -130,6 +130,18 @@ export default class PackFirestormRepository implements PackRepository {
delete(packId: AnyPack): Promise<void> {
// try removing submission data if exists too
this.submissionRepo.delete(packId as FaithfulPack).catch(() => {});
return packs.remove(packId).then(() => {});

// remove associated contributions
return contributions
.search([
{
field: "pack",
criteria: "==",
value: packId,
},
])
.then((contribs) => contributions.removeBulk(contribs.map((c) => c.id)))
.then(() => packs.remove(packId))
.then(() => {});
}
}

0 comments on commit 1360bbd

Please sign in to comment.