Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into triumphThemeNoPackageLock
- Loading branch information
Showing
1,214 changed files
with
27,974 additions
and
20,922 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
var migrationName = '20171230_nye_hats.js'; | ||
var authorName = 'Sabe'; // in case script author needs to know when their ... | ||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done | ||
|
||
/* | ||
* Award New Year's Eve party hats to users in sequence | ||
*/ | ||
|
||
var monk = require('monk'); | ||
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE | ||
var dbUsers = monk(connectionString).get('users', { castIds: false }); | ||
|
||
function processUsers(lastId) { | ||
// specify a query to limit the affected users (empty for all users): | ||
var query = { | ||
'migration': {$ne:migrationName}, | ||
'auth.timestamps.loggedin': {$gt:new Date('2017-11-30')}, | ||
}; | ||
|
||
if (lastId) { | ||
query._id = { | ||
$gt: lastId | ||
} | ||
} | ||
|
||
dbUsers.find(query, { | ||
sort: {_id: 1}, | ||
limit: 250, | ||
fields: [ | ||
'items.gear.owned', | ||
] // specify fields we are interested in to limit retrieved data (empty if we're not reading data): | ||
}) | ||
.then(updateUsers) | ||
.catch(function (err) { | ||
console.log(err); | ||
return exiting(1, 'ERROR! ' + err); | ||
}); | ||
} | ||
|
||
var progressCount = 1000; | ||
var count = 0; | ||
|
||
function updateUsers (users) { | ||
if (!users || users.length === 0) { | ||
console.warn('All appropriate users found and modified.'); | ||
displayData(); | ||
return; | ||
} | ||
|
||
var userPromises = users.map(updateUser); | ||
var lastUser = users[users.length - 1]; | ||
|
||
return Promise.all(userPromises) | ||
.then(function () { | ||
processUsers(lastUser._id); | ||
}); | ||
} | ||
|
||
function updateUser (user) { | ||
count++; | ||
|
||
var set = {}; | ||
var push = {}; | ||
|
||
if (typeof user.items.gear.owned.head_special_nye2016 !== 'undefined') { | ||
set = {'migration':migrationName, 'items.gear.owned.head_special_nye2017':false}; | ||
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.head_special_nye2017', '_id': monk.id()}}; | ||
} else if (typeof user.items.gear.owned.head_special_nye2015 !== 'undefined') { | ||
set = {'migration':migrationName, 'items.gear.owned.head_special_nye2016':false}; | ||
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.head_special_nye2016', '_id': monk.id()}}; | ||
} else if (typeof user.items.gear.owned.head_special_nye2014 !== 'undefined') { | ||
set = {'migration':migrationName, 'items.gear.owned.head_special_nye2015':false}; | ||
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.head_special_nye2015', '_id': monk.id()}}; | ||
} else if (typeof user.items.gear.owned.head_special_nye !== 'undefined') { | ||
set = {'migration':migrationName, 'items.gear.owned.head_special_nye2014':false}; | ||
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.head_special_nye2014', '_id': monk.id()}}; | ||
} else { | ||
set = {'migration':migrationName, 'items.gear.owned.head_special_nye':false}; | ||
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.head_special_nye', '_id': monk.id()}}; | ||
} | ||
|
||
dbUsers.update({_id: user._id}, {$set: set, $push: push}); | ||
|
||
if (count % progressCount == 0) console.warn(count + ' ' + user._id); | ||
if (user._id == authorUuid) console.warn(authorName + ' processed'); | ||
} | ||
|
||
function displayData() { | ||
console.warn('\n' + count + ' users processed\n'); | ||
return exiting(0); | ||
} | ||
|
||
function exiting(code, msg) { | ||
code = code || 0; // 0 = success | ||
if (code && !msg) { msg = 'ERROR!'; } | ||
if (msg) { | ||
if (code) { console.error(msg); } | ||
else { console.log( msg); } | ||
} | ||
process.exit(code); | ||
} | ||
|
||
module.exports = processUsers; |
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,79 @@ | ||
/* | ||
* Convert purchased.plan.nextPaymentProcessing from a double to a date field for Apple subscribers | ||
*/ | ||
|
||
var monk = require('monk'); | ||
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE | ||
var dbUsers = monk(connectionString).get('users', { castIds: false }); | ||
|
||
function processUsers(lastId) { | ||
// specify a query to limit the affected users (empty for all users): | ||
var query = { | ||
'purchased.plan.paymentMethod': "Apple", | ||
'purchased.plan.nextPaymentProcessing': {$type: 'double'}, | ||
}; | ||
|
||
if (lastId) { | ||
query._id = { | ||
$gt: lastId | ||
} | ||
} | ||
|
||
dbUsers.find(query, { | ||
sort: {_id: 1}, | ||
limit: 250, | ||
}) | ||
.then(updateUsers) | ||
.catch(function (err) { | ||
console.log(err); | ||
return exiting(1, 'ERROR! ' + err); | ||
}); | ||
} | ||
|
||
var progressCount = 100; | ||
var count = 0; | ||
|
||
function updateUsers (users) { | ||
if (!users || users.length === 0) { | ||
console.warn('All appropriate users found and modified.'); | ||
displayData(); | ||
return; | ||
} | ||
|
||
var userPromises = users.map(updateUser); | ||
var lastUser = users[users.length - 1]; | ||
|
||
return Promise.all(userPromises) | ||
.then(function () { | ||
processUsers(lastUser._id); | ||
}); | ||
} | ||
|
||
function updateUser (user) { | ||
count++; | ||
|
||
var set = { | ||
'purchased.plan.nextPaymentProcessing': new Date(user.purchased.plan.nextPaymentProcessing), | ||
}; | ||
|
||
dbUsers.update({_id: user._id}, {$set: set}); | ||
|
||
if (count % progressCount == 0) console.warn(count + ' ' + user._id); | ||
} | ||
|
||
function displayData() { | ||
console.warn('\n' + count + ' users processed\n'); | ||
return exiting(0); | ||
} | ||
|
||
function exiting(code, msg) { | ||
code = code || 0; // 0 = success | ||
if (code && !msg) { msg = 'ERROR!'; } | ||
if (msg) { | ||
if (code) { console.error(msg); } | ||
else { console.log( msg); } | ||
} | ||
process.exit(code); | ||
} | ||
|
||
module.exports = processUsers; |
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,58 @@ | ||
# Indexes | ||
|
||
This file contains a list of indexes that are on Habitica's production Mongo server. | ||
If we ever have an issue, use this list to reindex. | ||
|
||
## Challenges | ||
- `{ "group": 1, "official": -1, "timestamp": -1 }` | ||
- `{ "leader": 1, "official": -1, "timestamp": -1 }` | ||
- `{ "official": -1, "timestamp": -1 }` | ||
|
||
## Groups | ||
- `{ "privacy": 1, "type": 1, "memberCount": -1 }` | ||
- `{ "privacy": 1 }` | ||
- `{ "purchased.plan.customerId": 1 }` | ||
- `{ "purchased.plan.paymentMethod": 1 }` | ||
- `{ "purchased.plan.planId": 1, "purchased.plan.dateTerminated": 1 }` | ||
- `{ "type": 1, "memberCount": -1, "_id": 1 }` | ||
- `{ "type": 1 }` | ||
|
||
## Tasks | ||
- `{ "challenge.id": 1 }` | ||
- `{ "challenge.taskId": 1 }` | ||
- `{ "group.id": 1 }` | ||
- `{ "group.taskId": 1 }` | ||
- `{ "type": 1, "everyX": 1, "frequency": 1 }` | ||
- `{ "userId": 1 }` | ||
- `{ "yesterDaily": 1, "type": 1 }` | ||
|
||
## Users | ||
- `{ "_id": 1, "apiToken": 1 }` | ||
- `{ "auth.facebook.emails.value": 1 }` | ||
- `{ "auth.facebook.id": 1 }` | ||
- `{ "auth.google.emails.value": 1 }` | ||
- `{ "auth.google.id": 1 }` | ||
- `{ "auth.local.email": 1 }` | ||
- `{ "auth.local.lowerCaseUsername": 1 }` | ||
- `{ "auth.local.username": 1 }` | ||
- `{ "auth.timestamps.created": 1 }` | ||
- `{ "auth.timestamps.loggedin": 1, "_lastPushNotification": 1, "preferences.timezoneOffset": 1 }` | ||
- `{ "auth.timestamps.loggedin": 1 }` | ||
- `{ "backer.tier": -1 }` | ||
- `{ "challenges": 1, "_id": 1 }` | ||
- `{ "contributor.admin": 1, "contributor.level": -1, "backer.npc": -1, "profile.name": 1 }` | ||
- `{ "contributor.level": 1 }` | ||
- `{ "flags.newStuff": 1 }` | ||
- `{ "guilds": 1, "_id": 1 }` | ||
- `{ "invitations.guilds.id": 1, "_id": 1 }` | ||
- `{ "invitations.party.id": 1 }` | ||
- `{ "loginIncentives": 1 }` | ||
- `{ "migration": 1 }` | ||
- {` "party._id": 1, "_id": 1 }` | ||
- `{ "preferences.sleep": 1, "_id": 1, "flags.lastWeeklyRecap": 1, "preferences.emailNotifications.unsubscribeFromAll": 1, "preferences.emailNotifications.weeklyRecaps": 1 }` | ||
- `{ "preferences.sleep": 1, "_id": 1, "lastCron": 1, "preferences.emailNotifications.importantAnnouncements": 1, "preferences.emailNotifications.unsubscribeFromAll": 1, "flags.recaptureEmailsPhase": 1 }` | ||
- `{ "profile.name": 1 }` | ||
- `{ "purchased.plan.customerId": 1 }` | ||
- `{ "purchased.plan.paymentMethod": 1 }` | ||
- `{ "stats.score.overall": 1 }` | ||
- `{ "webhooks.type": 1 }` |
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
Oops, something went wrong.