<commit_before>///////////////////////
// todo methods

Meteor.methods({

  addTodo: function (text, taskId) {
    // Make sure the user is logged in before inserting a task
    if (! Meteor.userId()) {
      throw new Meteor.Error("not-authorized");
    }

    // bottom of the list
    var pos = 0.0;
    var ts = Tasks.findOne({_id: taskId}).todos;
    if(ts.length > 0) pos = _.max(_.map(ts, function(t){return t.position;})) + 1.0;
<commit_msg>Fix previous todos existance assumption<commit_after>///////////////////////
// todo methods

Meteor.methods({

  addTodo: function (text, taskId) {
    // Make sure the user is logged in before inserting a task
    if (! Meteor.userId()) {
      throw new Meteor.Error("not-authorized");
    }

    // bottom of the list
    var pos = 0.0;
    var ts = Tasks.findOne({_id: taskId}).todos;
    if(ts && (ts.length > 0)) pos = _.max(_.map(ts, function(t){return t.position;})) + 1.0;

{'fraction_non_alphanumeric': 0.19313304721030042, 'fraction_numerical': 0.01072961373390558, 'mean_word_length': 2.3927272727272726, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3581637', 'n_tokens_mistral': 319, 'n_tokens_neox': 302, 'n_words': 89}