<commit_before>var client = require("./database.js");
var user = require('./user.js');
var api = require("../db/API.js");

exports.createGroup = function(){
        api.createGroupIfNotExistsFor("-1241",function(e){
        console.log(e);
    });
};

exports.get_by_user = function(user,cb){
    if(user.aid==null){
        api.createAuthorIfNotExistsFor(user.id,user.name,function(err,response){
            if(err)
                throw err;
            aid = response.authorID;
            //TODO: update user info, and put authorID
            get_by_author_id(aid,cb);
        });
    } else {
        get_by_author_id(user.aid,cb);
    }
}

exports.get_by_author_id = get_by_author_id = function(aid,name,cb){
    //get sessions by user
    //
    

}

exports.get_by_lecture = function(lecture,cb){
    get_by_lecture_id(lecture.id,cb);
}

exports.get_by_lecture_id = get_by_lecture_id = function(lecture_id,cb){
    api.createGroupIfNotExistsFor(lecture_id,function(err,group){
        if(err)
            throw err;
        console.log(group);
    });
}

exports.setPassword = function(padID, password,cb){
    api.setPassword(padID,password,function(err,response){
        if(err)
            throw err;
        cb(response);
    })   
}<commit_msg>create/destroy pads that does not belong to lecture(group)<commit_after>var client = require("./database.js");
var user = require('./user.js');
var api = require("../db/API.js");

/*
 *  Create group ID
 */
exports.createGroup = function(groupID){
        api.createGroupIfNotExistsFor(groupID,function(e){
        console.log(e);
    });
};
/*
 * Get pads that belongs to the user.
 */
exports.get_by_user = function(user,cb){
    if(user.aid==null){
        api.createAuthorIfNotExistsFor(user.id,user.name,function(err,response){
            if(err)
                throw err;
            aid = response.authorID;
            //TODO: update user info, and put authorID
            get_by_author_id(aid,cb);
        });
    } else {
        get_by_author_id(user.aid,cb);
    }
}

/*
 * Get pads that belong to the author_id of the user
 */
exports.get_by_author_id = get_by_author_id = function(aid,name,cb){
    //TODO:get sessions by user
    //get groups that the author belongs to 
    //get pads for each group
}

/*
 * Get pads that belongs to the lecture(group)
 */
exports.get_by_lecture = function(lecture,cb){
    get_by_lecture_id(lecture.id,cb);
}

/*
 * Get pads that belongs to the lecture_id(group_id)
 */
exports.get_by_lecture_id = get_by_lecture_id = function(lecture_id,cb){
    api.createGroupIfNotExistsFor(lecture_id,function(err,group){
        if(err)
            throw err;
        console.log(group);
    });
}
/*
 * Set password for the pad with padID
 */
exports.setPassword = function(padID, password,cb){
    api.setPassword(padID,password,function(err,response){
        if(err)
            throw err;
        cb(response);
    })   
}

/*
 * Create pad that does not belong to any group
 */
exports.create = function(padID, cb){
    api.createPad(padID, "", cb);
}

/*
 * Destroy pad with specific ID
 */
exports.destroy = function(padID, cb){
    api.deletePad(padID, function(err,response){
        cb(response);
    });
}
{'fraction_non_alphanumeric': 0.1357564461012737, 'fraction_numerical': 0.0012426219322771047, 'mean_word_length': 2.788235294117647, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3173267', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1062, 'n_words': 201}