Upgrade tests tools and lint migrations and scripts (part 2) (#9998)

* upgrade gulp-babel

* upgrade babel-eslint

* upgrade eslint-friendly-formatter

* start upgrading chai

* start to upgrade eslint

* restore skipped tests

* start to upgrqde monk

* fix linting and remove unused file

* fix mocha notifications, and common tests

* fix unit tests

* start to fix initrgration tests

* more integration tests fixes

* upgrade monk to latest version

* lint /scripts

* migrations: start moving to /archive unused migrations and run eslint with --fix

* lint migrations

* fix more integration tests

* fix test
This commit is contained in:
Matteo Pagliazzi
2018-02-17 18:11:24 +01:00
committed by GitHub
parent b0ae0ef4da
commit 74ba55c20b
362 changed files with 8041 additions and 7813 deletions

View File

@@ -0,0 +1,88 @@
/*
* IMPORTANT:
*
* DO NOT TRUST THIS SCRIPT YET
*
*
* This has been written by Alys to identify and remove duplicated tasks
* i.e., tasks that have the same `id` value as another task.
* However it could almost certainly be improved (the aggregation step HAS
* to be easier that this!) and Alys is still working on it. Improvements
* welcome.
*
* If you use it, do ALL of the following things:
*
* - configuration, as described below
* - make a full backup of the user's data
* - be aware of how to restore the user's data from that backup
* - test the script first on a local copy of the database
* - dump the user's data to a text file before running the script so that
* it can later be compared to a dump made afterwards
* - run the script once first with both of the db.users.update() commands
* commented-out and check that the printed task IDs are correct
* - run the script with all code enabled
* - dump the user's data to a text file after running the script
* - diff the two dumps to ensure that only the correct tasks were removed
*
*
* When two tasks exist with the same ID, only one of those tasks will be
* removed (whichever copy the script finds first).
* If three tasks exist with the same ID, you'll probably need to run this
* script twice.
*
*/
// CONFIGURATION:
// - Change the uuid below to be the user's uuid.
// - Change ALL instances of "todos" to "habits"/"dailys"/"rewards" as
// needed. Do not miss any of them!
let uuid = '30fb2640-7121-4968-ace5-f385e60ea6c5';
db.users.aggregate([
{$match: {
_id: uuid,
}},
{$project: {
_id: 0, todos: 1,
}},
{$unwind: '$todos'},
{$group: {
_id: { taskid: '$todos.id' },
count: { $sum: 1 },
}},
{$match: {
count: { $gt: 1 },
}},
{$project: {
'_id.taskid': 1,
}},
{$group: {
_id: { taskid: '$todos.id' },
troublesomeIds: { $addToSet: '$_id.taskid' },
}},
{$project: {
_id: 0,
troublesomeIds: 1,
}},
]).forEach((data) => {
// print( "\n" ); printjson(data);
data.troublesomeIds.forEach((taskid) => {
print(`non-unique task: ${ taskid}`);
db.users.update({
_id: uuid,
todos: { $elemMatch: { id: taskid } },
}, {
$set: { 'todos.$.id': 'de666' },
});
});
});
db.users.update(
{_id: uuid},
{$pull: { todos: { id: 'de666' } } },
{multi: false }
);