-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
72 lines (67 loc) · 1.6 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* Libraries
*/
var Indexer = require('./lib/indexer.js');
var matchesFile = './data_matches/resultados.csv';
var elasticsearch = require('elasticsearch');
var async = require('async');
var index = 'liga';
var Conf = require('./conf.js');
var KibanaConf = require('./kibana/kibana-examples.json');
var client = new elasticsearch.Client({
host: process.env.ES_SERVER || 'elasticsearch:9200',
});
function configureKibana(callback) {
async.each(KibanaConf, function(kConf, next) {
console.log(kConf._type);
client.index({
index: kConf._index,
type: kConf._type,
id: kConf._id,
body: kConf._source
}, next);
}, callback);
}
async.series({
wait4ES: function(cb) {
setTimeout(function() {
cb();
}, 10000);
},
deletePartidos: function(cb) {
console.log('DELETE', index);
client.indices.delete({
index: index
}, function(err, data) {
cb();
});
},
deletePlantillas: function(cb) {
console.log('DELETE', index + 2);
client.indices.delete({
index: index + 2
}, function(err, data) {
cb();
});
},
createPartidos: function(cb) {
console.log('CREATE', index);
client.indices.create({
index: index
}, cb);
},
createPlantillas: function(cb) {
console.log('CREATE', index + 2);
client.indices.create({
index: index + 2
}, cb);
}
}, function(callback) {
Indexer.matches(matchesFile, index, function() {
Indexer.plantillas('./data_matches/platillas.csv', index + 2, function() {
configureKibana(function() {
console.log('finish');
});
});
});
});