-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
112 lines (77 loc) · 2.53 KB
/
index.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
'use strict';
const fs = require('fs');
const moment = require('moment');
const async = require('async');
const AI = require('./libs/ai');
const SZ = require('./libs/sz');
const Twitter = require('./libs/twitter');
const _ = require('lodash');
function process() {
}
function getMentions (cb) {
Twitter.getMentions((err, tweets) => {
if (err) {
return cb(err);
}
return cb(null, tweets);
});
}
// fs.readFile('./corpus.txt', 'utf8', (err, data) => {
// if (err) {
// throw err;
// }
// const corpus = data.split('\n');
// //getUserTimeline();
// // Run the sample data through AI. It will be async call,
// // we do not need to wait for it
// async.map(corpus, AI.process, (err, data) => {
// if (err) {
// console.log(err);
// }
// const stayQueries = data.map((res) => {
// const stayQuery= {};
// const query = res.result.parameters;
// // Process the city name
// if (!query['geo-city']) {
// return false;
// }
// stayQuery.city = query['geo-city'];
// // Process the stay type
// stayQuery.stayType = query['stay-type'] || 'homestay';
// const dates = getCheckinCheckout(query['date']);
// stayQuery.checkInDate = dates.checkInDate;
// stayQuery.checkOutDate = dates.checkOutDate;
// return stayQuery;
// });
// // Get search results
// async.map(stayQueries, SZ.search, (err, cbData) => {
// if (err) {
// throw err;
// }
// const stays = _.flatten(cbData);
// extractStayData(stays);
// });
// });
// });
function extractStayData(stays) {
const stayData = stays.map(function(s) {
return {
name: s.name,
type: s.category,
contact: s.contact,
url: `https://stayzilla.com${s.url}`,
images: s.images
}
});
//console.log(stayData);
}
function getCheckinCheckout(checkIn, checkOut) {
const defaultCheckin = new Date(new Date().setDate(new Date().getDate() + 2));
checkIn = checkIn ? new Date(checkIn) : defaultCheckin,
checkOut = new Date(new Date().setDate(checkIn.getDate() + 3));
return {
checkInDate: moment(checkIn).format('YYYY-MM-DD'),
checkOutDate: moment(checkOut).format('YYYY-MM-DD'),
}
}
setTimeout(process, 6000);