<commit_before>/**
 * Created by admin on 1.12.2016 г..
 */
/* globals module */

'use strict';

module.exports = (models) => {
    var EventModel = models.EventModel;

    return {
        eventCreateAndSave(title, author, body, date, hidden = false){

            var eventObject = {
                title: title,
                author: author,
                body: body,
                date: date,
                hidden: hidden
            };
            var event = new EventModel(eventObject);

            var promise = new Promise(function (resolve, reject) {
                event.save(function (error, dbEvent) {
                    if(error){
                        return reject(error);
                    }

                    return resolve(dbEvent);
                })
            });

            return promise;
        },
        findById(eventId) {
            // TODO this is for tests only, edit and refactor later
            var dbUser = {
                firstName: 'Alex',
                lastName: 'Toplijski',
                age: 36,
                gender: 'gender',
                userName: 'userName101',
                passHash: '<PASSWORD>',
                email: '<EMAIL>',
                ProfilePicture: { src: 'source'}
            };
            var dbEvent = {
                _id: 123456789,
                title: 'test event',
                author: dbUser,
                body: 'this si th body text, this si th body text, this si th body text, this si th body text',
                date: new Date(),
                hidden: false
            };

            if (eventId == dbEvent._id) {
                return Promise.resolve(dbEvent);
            }
            

            return Promise.resolve(null);
        }
    };
};<commit_msg>eventCreateAndSave function is working<commit_after>/**
 * Created by admin on 1.12.2016 г..
 */
/* globals module */

'use strict';

module.exports = (models) => {
    var EventModel = models.EventModel;

    return {
        eventCreateAndSave(title, author, body, date, hidden = false){

            var eventObject = {
                title: title,
                author: author,
                body: body,
                date: date,
                hidden: hidden
            };
            var event = new EventModel(eventObject);

            return new Promise(function (resolve, reject) {
                event.save(function (error, dbEvent) {
                    if(error){
                        return reject(error);
                    }

                    return resolve(dbEvent);
                })
            });
        },
        eventFindById(eventId) {
            // TODO this is for tests only, edit and refactor later
            var dbUser = {
                firstName: 'Alex',
                lastName: 'Toplijski',
                age: 36,
                gender: 'gender',
                userName: 'userName101',
                passHash: '<PASSWORD>',
                email: '<EMAIL>',
                ProfilePicture: { src: 'source'}
            };
            var dbEvent = {
                _id: 123456789,
                title: 'test event',
                author: dbUser,
                body: 'this si th body text, this si th body text, this si th body text, this si th body text',
                date: new Date(),
                hidden: false
            };

            if (eventId == dbEvent._id) {
                return Promise.resolve(dbEvent);
            }


            return Promise.resolve(null);
        }
    };
};
{'fraction_non_alphanumeric': 0.09803921568627451, 'fraction_numerical': 0.011764705882352941, 'mean_word_length': 1.1319402985074627, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '2743200', 'n_tokens_mistral': 943, 'n_tokens_neox': 848, 'n_words': 254}