Added support for grouping tasks by chllenge

This commit is contained in:
Keith Holliday
2017-02-02 13:19:30 -07:00
committed by Alys
parent aef71db0f5
commit c244fe488d
8 changed files with 29 additions and 6 deletions

View File

@@ -121,7 +121,7 @@ schema.methods.syncToUser = async function syncChallengeToUser (user) {
if (!matchingTask) { // If the task is new, create it
matchingTask = new Tasks[chalTask.type](Tasks.Task.sanitize(syncableAttrs(chalTask)));
matchingTask.challenge = {taskId: chalTask._id, id: challenge._id};
matchingTask.challenge = {taskId: chalTask._id, id: challenge._id, name: challenge.shortName};
matchingTask.userId = user._id;
user.tasksOrder[`${chalTask.type}s`].push(matchingTask._id);
} else {

View File

@@ -58,6 +58,7 @@ export let TaskSchema = new Schema({
userId: {type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.']}, // When not set it belongs to a challenge
challenge: {
name: {type: String, default: 'No Category'},
id: {type: String, ref: 'Challenge', validate: [validator.isUUID, 'Invalid uuid.']}, // When set (and userId not set) it's the original task
taskId: {type: String, ref: 'Task', validate: [validator.isUUID, 'Invalid uuid.']}, // When not set but challenge.id defined it's the original task
broken: {type: String, enum: ['CHALLENGE_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED', 'CHALLENGE_CLOSED', 'CHALLENGE_TASK_NOT_FOUND']}, // CHALLENGE_TASK_NOT_FOUND comes from v3 migration

View File

@@ -7,7 +7,7 @@ require('./methods');
// A list of publicly accessible fields (not everything from preferences because there are also a lot of settings tha should remain private)
export let publicFields = `preferences.size preferences.hair preferences.skin preferences.shirt
preferences.chair preferences.costume preferences.sleep preferences.background profile stats
preferences.chair preferences.costume preferences.sleep preferences.background preferences.tasks profile stats
achievements party backer contributor auth.timestamps items inbox.optOut`;
// The minimum amount of data needed when populating multiple users

View File

@@ -465,6 +465,9 @@ let schema = new Schema({
raisePet: {type: Boolean, default: false},
streak: {type: Boolean, default: false},
},
tasks: {
groupByChallenge: {type: Boolean, default: false},
},
improvementCategories: {
type: Array,
validate: (categories) => {