feat(analytics): AB testing

User model update for AB tests, and the first AB test to start Sept 12

closes #7984
This commit is contained in:
Sabe Jones
2016-09-08 19:54:27 +00:00
committed by Blade Barringer
parent 6f2767edd3
commit f20a7b851f
225 changed files with 606 additions and 614 deletions

View File

@@ -1,5 +1,6 @@
import mongoose from 'mongoose';
import { TAVERN_ID } from '../../website/server/models/group';
import { get } from 'lodash';
// Useful for checking things that have been deleted,
// but you no longer have access to,
@@ -18,6 +19,20 @@ export async function checkExistence (collectionName, id) {
});
}
// Obtain a property from the database. Useful if the property is private
// and thus unavailable to the client
export async function getProperty (collectionName, id, path) {
return new Promise((resolve, reject) => {
let collection = mongoose.connection.db.collection(collectionName);
collection.find({_id: id}, {[path]: 1}).limit(1).toArray((findError, docs) => {
if (findError) return reject(findError);
resolve(get(docs[0], path));
});
});
}
// Specifically helpful for the GET /groups tests,
// resets the db to an empty state and creates a tavern document
export async function resetHabiticaDB () {