<commit_before>import UserProfileStore from '../../stores/UserProfileStore';
const log = require('../log/clog');
import serviceUnavailable from '../error/serviceUnavailable';
import addActivities from '../activityfeed/addActivities';

export default function addTreeNodeList(context, payload, done) {
    log.info(context);
    let userid = context.getStore(UserProfileStore).userid;
    if (userid != null && userid !== '') {
        //enrich with user id
        payload.userid = userid;
        context.service.create('decktree.node', payload, {timeout: 20 * 1000}, (err, res) => {
            if (err) {
                log.error(context, {filepath: __filename, err: err});
                context.executeAction(serviceUnavailable, payload, done);
            } else {
                context.dispatch('ADD_TREE_NODELIST_SUCCESS', res); //perhaps another thing is needed..
                let activities = res.map((activity) => {
                    return {
                        activity_type: 'add',
                        user_id: String(context.getStore(UserProfileStore).userid),
                        content_id: String(activity.node.id),
                        content_kind: activity.node.type
                    };

                });
                context.executeAction(addActivities, {activities: activities});
            }
            done(null, res);
        });
    }
}
<commit_msg>SWIK-1356-AppendSlides addTreeNodeList: modified to call the proper addActiviy action<commit_after>import UserProfileStore from '../../stores/UserProfileStore';
import log from  '../log/clog';
import serviceUnavailable from '../error/serviceUnavailable';
import addActivities from '../activityfeed/addActivities';
import addActivity from '../activityfeed/addActivity';

export default function addTreeNodeList(context, payload, done) {
    log.info(context);
    let userid = context.getStore(UserProfileStore).userid;
    if (userid != null && userid !== '') {
        //enrich with user id
        payload.userid = userid;
        context.service.create('decktree.node', payload, {timeout: 20 * 1000}, (err, res) => {
            if (err) {
                log.error(context, {filepath: __filename, err: err});
                context.executeAction(serviceUnavailable, payload, done);
            } else {
                context.dispatch('ADD_TREE_NODELIST_SUCCESS', res); 
                if(Array.isArray(res.node)){ //More than one slide/deck was added
                    let activities = res.node.map((node) => {
                        return {
                            activity_type: 'add',
                            user_id: String(context.getStore(UserProfileStore).userid),
                            content_id: String(node.id),
                            content_kind: node.type
                        };

                    });
                    context.executeAction(addActivities, {activities: activities});
                } else {  //Only a slide/deck was added
                    let activity = {
                        activity_type: 'add',
                        user_id: String(context.getStore(UserProfileStore).userid),
                        content_id: String(res.node.id),
                        content_kind: res.node.type
                    };
                    context.executeAction(addActivity, {activity: activity});
                }



            }
            done(null, res);
        });
    }
}

{'fraction_non_alphanumeric': 0.11457431457431458, 'fraction_numerical': 0.004617604617604618, 'mean_word_length': 1.768370607028754, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1668456', 'n_tokens_mistral': 893, 'n_tokens_neox': 846, 'n_words': 188}