Skip to content

Commit

Permalink
Implement page (#50)
Browse files Browse the repository at this point in the history
* add selected-events page

* remove dateutil, use datetime instead, add required modules for python

* add recommendations page

* disable esline for console.log in catch

* fix no marked events returning recommendations

* minimalize typo
  • Loading branch information
bluenex authored and titipata committed Sep 20, 2019
1 parent abae094 commit 4e241b0
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 145 deletions.
7 changes: 5 additions & 2 deletions backend/hug_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import json
import numpy as np
from datetime import datetime
import dateutil
from scipy.spatial.distance import cosine

# enable CORS
Expand All @@ -22,7 +21,7 @@ def get_future_event(date):
Function return True if the event happens after now
"""
try:
if dateutil.parser.parse(date) > datetime.now():
if datetime.strptime(date, '%d-%m-%Y') > datetime.now():
return True
else:
return False
Expand All @@ -43,6 +42,10 @@ def recommendations(body):
The body is then passed as an argument to this function, as a dictionary.
"""
event_indices = body['payload']

if len(event_indices) == 0:
return json.dumps([])

pref_indices = [int(event_idx) for event_idx in event_indices]
pref_vector = np.mean([np.array(event_vectors_map[idx])
for idx in pref_indices], axis=0)
Expand Down
2 changes: 2 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
hug
uwsgi
numpy
scipy
Loading

0 comments on commit 4e241b0

Please sign in to comment.