Skip to content

Commit

Permalink
REVERT BACK -- BAD DAY
Browse files Browse the repository at this point in the history
  • Loading branch information
kristiyanto committed Oct 10, 2016
1 parent f6dcce3 commit 8e8edaf
Show file tree
Hide file tree
Showing 63 changed files with 145 additions and 291 deletions.
Empty file modified README.md
100644 → 100755
Empty file.
13 changes: 6 additions & 7 deletions elasticsearch/RESET DB.ipynb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 236,
"execution_count": 144,
"metadata": {
"collapsed": false
},
Expand Down Expand Up @@ -59,8 +59,7 @@
" 'altdest2': {'type': 'geo_point', 'lat_lon': 'true', \"include_in_all\": \"false\"},\n",
" 'altdestid2':{'type': 'string', \"include_in_all\": \"false\"}, \n",
" 'origin': {'type': 'geo_point', 'lat_lon': 'true', \"include_in_all\": \"false\"},\n",
" 'path': {'type': 'string', \"include_in_all\": \"false\"},\n",
" 'tripdistance': {'type': 'string', \"include_in_all\": \"false\"}\n",
" 'path': {'type': 'string', \"include_in_all\": \"false\"}\n",
" }\n",
" }\n",
" }\n",
Expand All @@ -71,7 +70,7 @@
},
{
"cell_type": "code",
"execution_count": 237,
"execution_count": 145,
"metadata": {
"collapsed": false
},
Expand All @@ -82,7 +81,7 @@
"{u'acknowledged': True}"
]
},
"execution_count": 237,
"execution_count": 145,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -94,7 +93,7 @@
},
{
"cell_type": "code",
"execution_count": 238,
"execution_count": 146,
"metadata": {
"collapsed": false
},
Expand All @@ -105,7 +104,7 @@
"{u'acknowledged': True}"
]
},
"execution_count": 238,
"execution_count": 146,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
Empty file modified elasticsearch/elasticschema.txt
100644 → 100755
Empty file.
Empty file modified flask/app/__init__.py
100644 → 100755
Empty file.
Empty file modified flask/app/__init__.pyc
100644 → 100755
Empty file.
Empty file modified flask/app/static/dist/css/.Rhistory
100644 → 100755
Empty file.
Empty file modified flask/app/static/qr.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 26 additions & 33 deletions flask/app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,19 @@ <h1 class="page-header">http://venturo.kristiyanto.me</h1>
var DATA;



function drawPath()
{
$.getJSON("lines", function(path){
polyline = new L.Polyline(path.path)
mymap.addLayer(polyline)
});

var circle = L.circle(path.location, 50, {
color: 'yellow',
fillOpacity: 0.5
}).addTo(mymap);

}

function currentTime()
{
Expand Down Expand Up @@ -337,6 +349,11 @@ <h1 class="page-header">http://venturo.kristiyanto.me</h1>
color: 'black',
fillOpacity: 0.2
}).addTo(mymap);

var circle = L.circle(data.arrMsgLoc, 250, {
color: 'yellow',
fillOpacity: 0.5
}).addTo(mymap);

var circle = L.circle(data.arrMsgLoc, 30, {
color: 'black',
Expand Down Expand Up @@ -397,6 +414,14 @@ <h1 class="page-header">http://venturo.kristiyanto.me</h1>
}


$(function () {
setInterval(currentTime, 500);
setInterval(clearMap, 4999);
setInterval(drawPassengers, 5000);
setInterval(drawDrivers, 5000);
setInterval(drawPath, 1000);

});

function centerIt(){
mymap.panTo(DATA.mLoc);
Expand All @@ -414,39 +439,7 @@ <h1 class="page-header">http://venturo.kristiyanto.me</h1>
mymap.panTo(DATA.arrMsgLoc);
}

function drawPath()
{
var path
var _first
var _last
$.getJSON("lines", function(p){

if (p.path) {
polyline = new L.Polyline(p.path)
mymap.addLayer(polyline)

var circle = L.circle(p.location, 50, {
color: 'yellow',
fillOpacity: 0.5
}).addTo(mymap);

var circle = L.circle(p.path[0], 50, {
color: 'purple',
fillOpacity: 0.5
}).addTo(mymap);
}

});
}

$(function () {
setInterval(currentTime, 500);
setInterval(clearMap, 4999);
setInterval(drawPassengers, 5000);
setInterval(drawDrivers, 5000);
setInterval(drawPath, 1000);

});

</script>

Expand Down
3 changes: 3 additions & 0 deletions flask/app/views.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def lines():
res = arrivedMsg()
if len(res['hits']['hits']) > 0:
res = res['hits']['hits'][0]['_source']
path = res['path']
sorted(path , key=lambda k: [k[1], k[0]])
res['path'] = path
else:
res = []
return json.dumps(res)
Expand Down
Binary file modified flask/app/views.pyc
100644 → 100755
Binary file not shown.
Empty file modified flask/run.py
100644 → 100755
Empty file.
Empty file modified flask/tornadoapp.py
100644 → 100755
Empty file.
Empty file modified kafka/archive/Driver_Generator.ipynb
100644 → 100755
Empty file.
Empty file modified kafka/archive/Kafka_Producer.ipynb
100644 → 100755
Empty file.
Empty file modified kafka/archive/Passenger_Generator.ipynb
100644 → 100755
Empty file.
Empty file modified kafka/archive/Untitled.ipynb
100644 → 100755
Empty file.
Empty file modified kafka/archive/consumer.py
100644 → 100755
Empty file.
Empty file modified kafka/archive/producer.py
100644 → 100755
Empty file.
Empty file modified kafka/boundaries.csv
100644 → 100755
Empty file.
Empty file modified kafka/create_topic.txt
100644 → 100755
Empty file.
Empty file modified kafka/d.sh
100644 → 100755
Empty file.
Empty file modified kafka/destinations.csv
100644 → 100755
Empty file.
36 changes: 14 additions & 22 deletions kafka/driver_producer.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is the script to populate driver's Data
# {driver_id, time, curr_lat, curr_long, dest, load}
total_drivers = 5000
total_drivers = 2000


import time
Expand Down Expand Up @@ -32,12 +32,7 @@
es = Elasticsearch(cluster, port=9200)

def convertTime(tm):
try:
t = datetime.strptime("{}".format(tm),'%Y-%m-%dT%H:%M:%S.%fZ')
t = t.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
except:
t = datetime.strptime("{}".format(tm),'%Y-%m-%d %H:%M:%S.%f')
t = t.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
t = datetime.strptime("{}".format(tm),'%Y-%m-%dT%H:%M:%S.%fZ')
return t


Expand Down Expand Up @@ -68,13 +63,13 @@ def simulateTrip(c, d):


def generateDriver(city):
driverID = random.randint(1, total_drivers)
d_id = random.randint(1, total_drivers)
driver_mapping ={
'city': city,
'name': 'driver_{}'.format(driverID),
'id': driverID,
'name': 'driver_{}'.format(d_id),
'id': d_id,
'status': 'idle',
'location': randomLoc(driverID, city),
'location': randomLoc(d_id, city),
'ctime': str(datetime.now()),
'p1': None,
'p2': None,
Expand All @@ -87,17 +82,15 @@ def generateDriver(city):
'origin': None,
}

q = es.get(index='driver', doc_type='rolling', id=driverID, ignore=[404, 400])
if q['found'] and (q['_source']['status'] in ['ontrip', 'pickup', '']):
q = es.get(index='driver', doc_type='rolling', id=d_id, ignore=[404, 400])
if q['found'] and (q['_source']['status'] in ['ontrip', 'pickup']):
driver_mapping = q['_source']
driver_mapping['location'] = simulateTrip(driver_mapping['location'], driver_mapping['destination'])
if q['found'] and (q['_source']['status'] in ['arrived']):
driver_mapping['ctime'] = convertTime(driver_mapping['ctime'])
doc = json.dumps(driver_mapping)
doc = '{{"doc": {}, "doc_as_upsert" : "true"}}'.format(doc)

q = es.update(index='driver', doc_type='rolling', id=driverID, ignore=[404, 400], body=doc)
return False
q = es.update(index='driver', doc_type='rolling', id=d_id, ignore=[404, 400],
body={'doc': doc, "doc_as_upsert" : "true"})

return(driver_mapping)

Expand All @@ -108,11 +101,10 @@ def main():
for n in range(total_drivers):
city = random.choice(['CHI','NYC'])
driver = generateDriver(city)
if driver:
u_json = json.dumps(driver).encode('utf-8')
key = json.dumps(driver['id']).encode('utf-8')
#print('{}'.format(driver))
producer.send(b'drv', key, u_json)
u_json = json.dumps(driver).encode('utf-8')
key = json.dumps(driver['id']).encode('utf-8')
print('{}'.format(driver))
producer.send(b'drv', key, u_json)
kafka.close()

if __name__ == "__main__":
Expand Down
15 changes: 7 additions & 8 deletions kafka/passenger_producer.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# for the stream. Ideally, this would come from User.
# Boundaries.csv contains information about the location boundaries for the generation.

totalPassenger = 15000
totalPassenger = 20000
# Once generated, the request then sent to Kafka.

import csv
Expand Down Expand Up @@ -69,14 +69,13 @@ def retention(passanger):
res = es.search(index='passenger', doc_type='rolling', body=q, ignore=[404, 400])
return res['hits']["total"]

def convertTime(tm):
def convertTime(ctime):
try:
t = datetime.strptime("{}".format(tm),'%Y-%m-%dT%H:%M:%S.%fZ')
t = t.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
tmp = datetime.strptime("{}".format(ctime), '%Y-%m-%d %H:%M:%S.%f')
ctime = tmp.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
except:
t = datetime.strptime("{}".format(tm),'%Y-%m-%d %H:%M:%S.%f')
t = t.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
return t
print "Time conversion failed"
return ctime

def generatePassenger(city, ID):
last_uid = ID
Expand All @@ -101,7 +100,7 @@ def generatePassenger(city, ID):
'altdest2': att[2][1],
'altdest2id': att[2][0],
'origin': [curr_lat, curr_long],
'path': [[curr_lat, curr_long]]
'path': [curr_lat, curr_long]
}

q = es.get(index='passenger', doc_type='rolling', id=ID, ignore=[404, 400])
Expand Down
Empty file modified kafka/read_topic.txt
100644 → 100755
Empty file.
Empty file modified kafka/start_secor.sh
100644 → 100755
Empty file.
Empty file modified media/architecture.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified media/docker.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified media/insight.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified media/screen_big.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified media/screenshot.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified media/youtube.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified media/youtube_big.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified recommendation/als.ipynb
100644 → 100755
Empty file.
Empty file modified recommendation/als.scala
100644 → 100755
Empty file.
Empty file modified recommendation/data/data_row_number.txt
100644 → 100755
Empty file.
Empty file modified recommendation/data/gps.csv.zip
100644 → 100755
Empty file.
Empty file modified spark/archive/.ipynb_checkpoints/SCRAPBOOK-checkpoint.ipynb
100644 → 100755
Empty file.
Loading

0 comments on commit 8e8edaf

Please sign in to comment.