mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 13:17:24 +01:00
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:
committed by
Blade Barringer
parent
6f2767edd3
commit
f20a7b851f
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user