forked from responsible-ai-collaborative/aiid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'staging' into feature/entity-entity-relationship
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
site/gatsby-site/migrations/2024.10.25T21.09.57.remove-report-attribution.js
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,24 @@ | ||
const config = require('../config'); | ||
|
||
/** @type {import('umzug').MigrationFn<any>} */ | ||
exports.up = async ({ context: { client } }) => { | ||
const reportsCollection = client.db(config.realm.production_db.db_name).collection('reports'); | ||
|
||
// Change "AIAAIC" to "Anonymous" if it is the only element in the `submitters` array | ||
const result1 = await reportsCollection.updateMany( | ||
{ submitters: ['AIAAIC'] }, | ||
{ $set: { submitters: ['Anonymous'] } } | ||
); | ||
|
||
console.log(`Modified ${result1.modifiedCount} documents where "AIAAIC" was the only submitter`); | ||
|
||
// Remove "AIAAIC" from the `submitters` array if there are multiple elements | ||
const result2 = await reportsCollection.updateMany( | ||
{ submitters: 'AIAAIC' }, | ||
{ $pull: { submitters: 'AIAAIC' } } | ||
); | ||
|
||
console.log( | ||
`Modified ${result2.modifiedCount} documents where "AIAAIC" was one of the submitters` | ||
); | ||
}; |