mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 03:52:14 +00:00
[#1711] got it! task.*.history & user.history as defined schemas was the
problem, since they're arrays of >100 each
This commit is contained in:
parent
01536a2e29
commit
838108d579
4 changed files with 8 additions and 25 deletions
|
|
@ -70,7 +70,6 @@ function deleteTask(user, task) {
|
||||||
|
|
||||||
function addTask(user, task) {
|
function addTask(user, task) {
|
||||||
task = helpers.taskDefaults(task);
|
task = helpers.taskDefaults(task);
|
||||||
task._id = task.id;
|
|
||||||
user[task.type+'s'].unshift(task);
|
user[task.type+'s'].unshift(task);
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ ChallengeSchema.methods.toJSON = function(){
|
||||||
doc._isMember = this._isMember;
|
doc._isMember = this._isMember;
|
||||||
_.each(['habits','dailys','todos','rewards'], function(type){
|
_.each(['habits','dailys','todos','rewards'], function(type){
|
||||||
_.each(doc[type],function(task){
|
_.each(doc[type],function(task){
|
||||||
task.id = task._id;
|
task.id = task.id || task._id;
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return doc;
|
return doc;
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ var _ = require('lodash');
|
||||||
// Task Schema
|
// Task Schema
|
||||||
// -----------
|
// -----------
|
||||||
|
|
||||||
var TaskSchema = new Schema({
|
var TaskSchema = {
|
||||||
_id:{type: String,'default': helpers.uuid},
|
_id:{type: String,'default': helpers.uuid},
|
||||||
history: [{date:Date, value:Number}],
|
history: Array, // [{date:Date, value:Number}], // this causes major performance problems
|
||||||
text: String,
|
text: String,
|
||||||
notes: {type: String, 'default': ''},
|
notes: {type: String, 'default': ''},
|
||||||
tags: {type: Schema.Types.Mixed, 'default': {}}, //{ "4ddf03d9-54bd-41a3-b011-ca1f1d2e9371" : true },
|
tags: {type: Schema.Types.Mixed, 'default': {}}, //{ "4ddf03d9-54bd-41a3-b011-ca1f1d2e9371" : true },
|
||||||
|
|
@ -32,21 +32,6 @@ var TaskSchema = new Schema({
|
||||||
winner: String // user.profile.name
|
winner: String // user.profile.name
|
||||||
// group: {type: 'Strign', ref: 'Group'} // if we restore this, rename `id` above to `challenge`
|
// group: {type: 'Strign', ref: 'Group'} // if we restore this, rename `id` above to `challenge`
|
||||||
}
|
}
|
||||||
}, {
|
};
|
||||||
minimize: 'false'
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
module.exports.schema = TaskSchema;
|
||||||
* FIXME why is this function is never called? Instead we're doing a _.each(obj.tasks) in challenges & user
|
|
||||||
*/
|
|
||||||
TaskSchema.methods.toJSON = function() {
|
|
||||||
var doc = this.toObject();
|
|
||||||
doc.id = doc._id;
|
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
TaskSchema.virtual('id').get(function(){
|
|
||||||
return this._id;
|
|
||||||
})
|
|
||||||
|
|
||||||
module.exports.schema = TaskSchema;
|
|
||||||
module.exports.model = mongoose.model("Task", TaskSchema);
|
|
||||||
|
|
@ -83,8 +83,8 @@ var UserSchema = new Schema({
|
||||||
rest: {type: Boolean, 'default': false} // fixme - change to preferences.resting once we're off derby
|
rest: {type: Boolean, 'default': false} // fixme - change to preferences.resting once we're off derby
|
||||||
},
|
},
|
||||||
history: {
|
history: {
|
||||||
exp: [{date: Date, value: Number}],
|
exp: Array, // [{date: Date, value: Number}], // big peformance issues if these are defined
|
||||||
todos: [{data: Date, value: Number}]
|
todos: Array //[{data: Date, value: Number}] // big peformance issues if these are defined
|
||||||
},
|
},
|
||||||
|
|
||||||
/* FIXME remove?*/
|
/* FIXME remove?*/
|
||||||
|
|
@ -209,10 +209,9 @@ UserSchema.methods.toJSON = function() {
|
||||||
doc.filters = {};
|
doc.filters = {};
|
||||||
doc._tmp = this._tmp; // be sure to send down drop notifs
|
doc._tmp = this._tmp; // be sure to send down drop notifs
|
||||||
|
|
||||||
// TODO why isnt' this happening automatically given the TaskSchema.methods.toJSON above?
|
|
||||||
_.each(['habits','dailys','todos','rewards'], function(type){
|
_.each(['habits','dailys','todos','rewards'], function(type){
|
||||||
_.each(doc[type],function(task){
|
_.each(doc[type],function(task){
|
||||||
task.id = task._id;
|
task.id = task.id || task._id;
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue