-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1286 from AletheiaFact/fixed-claim-review-creation
Added `target` and `targetModel` fields in claim review schema
- Loading branch information
Showing
8 changed files
with
83 additions
and
40 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
migrations/20240717100604-add-target-and-target-model-fields-in-claim-review-schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Db } from "mongodb"; | ||
|
||
export async function up(db: Db) { | ||
const claimReviewCursor = await db.collection("claimreviews").find(); | ||
|
||
while (await claimReviewCursor.hasNext()) { | ||
const claimReview = await claimReviewCursor.next(); | ||
if (claimReview.claim) { | ||
await db.collection("claimreviews").updateOne( | ||
{ _id: claimReview._id }, | ||
{ | ||
$set: { | ||
target: claimReview.claim, | ||
targetModel: "Claim", | ||
}, | ||
$unset: { | ||
claim: undefined, | ||
}, | ||
} | ||
); | ||
} | ||
|
||
if (claimReview.source) { | ||
await db.collection("claimreviews").updateOne( | ||
{ _id: claimReview._id }, | ||
{ | ||
$set: { | ||
target: claimReview.source, | ||
targetModel: "Source", | ||
}, | ||
$unset: { | ||
source: undefined, | ||
}, | ||
} | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters