<commit_before>var data = require('./test-like-data.js').data.data;

data.forEach(function(person) {
	if (person.hasOwnProperty('likes') && person.likes.hasOwnProperty('data')) {
		var likes = person.likes.data;
		likes.forEach(function(likedPage) {
			console.log(person.name + " likes " + likedPage.name);
		})
	}
})<commit_msg>node test data import script<commit_after>var predictionio = require('predictionio-driver');
var config = require('../../../config/keys.js').predictionio;
var data = require('./test-like-data.js').data.data;

var count = 0;

var eventClient = new predictionio.Events({
	appId: config.appId, 
	accessKey: config.appKey, 
	url: config.eventUrl
});


eventClient.status()
.then(function(status) {
	console.log(status);
	data.forEach(function(person) {
		if (person.hasOwnProperty('likes') && person.likes.hasOwnProperty('data')) {
			var likes = person.likes.data;
			likes.forEach(function(likedPage) {
				userLikeSong(eventClient, parseInt(person.id), parseInt(likedPage.id), function (err, result) {
						if (err) return console.log('ERROR:: ' +err + '\n');
						return console.log(result);
						console.log(++count + 'events imported' + '\n');
				})
			})
		}
	})
});

userLikeSong = function (pioClient, userId, artistId, cb) { 
	pioClient.createEvent({
		event: 'buy',
		entityType:'user',
		entityId: userId,
		targetEntityType: 'item',
		targetEntityId: artistId,
		eventTime: new Date().toISOString()
	})
	.then(function(result) {
		cb(null, result);
	})
	.catch(function(err) {
		cb(err);
	});
}
{'fraction_non_alphanumeric': 0.1782693558880937, 'fraction_numerical': 0.0006506180871828237, 'mean_word_length': 4.415492957746479, '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': '4734488', 'n_tokens_mistral': 571, 'n_tokens_neox': 527, 'n_words': 93}