mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
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:
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Sync groups with Firebase
|
||||
*/
|
||||
|
||||
let mongo = require('mongoskin');
|
||||
let Firebase = require('Firebase');
|
||||
|
||||
let dbserver = 'mongodb://url';
|
||||
let dbname = 'db';
|
||||
|
||||
let db = mongo.db(`${dbserver }/${ dbname }?auto_reconnect`);
|
||||
let dbGroups = db.collection('groups');
|
||||
let countGroups = 0;
|
||||
|
||||
let firebaseRef = new Firebase('https://' + 'firebase-app' + '.firebaseio.com');
|
||||
|
||||
// TODO handle sync errors with firebase?
|
||||
firebaseRef.authWithCustomToken('firebase-secret', function (err, authData) {
|
||||
if (err) throw new Error('Impossible to authenticate Firebase');
|
||||
|
||||
console.log('Firebase connected, begins work on db');
|
||||
|
||||
dbGroups.findEach({}, {_id: 1, members: 1}, {batchSize: 100}, function (err, group) {
|
||||
if (err) throw err;
|
||||
if (group._id !== 'habitrpg') return;
|
||||
|
||||
countGroups++;
|
||||
console.log('Group: ', countGroups);
|
||||
|
||||
firebaseRef.child(`rooms/${ group._id}`)
|
||||
.set({
|
||||
name: group.name,
|
||||
});
|
||||
|
||||
group.members.forEach(function (member) {
|
||||
firebaseRef.child(`members/${ group._id }/${ userId}`)
|
||||
.set(true);
|
||||
|
||||
firebaseRef.child(`users/${ member }/rooms/${ group._id}`)
|
||||
.set(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user