{"action":"created","comment":{"url":"https://api.github.com/repos/e-mission/e-mission-server/pulls/comments/27367635","id":27367635,"diff_hunk":"@@ -0,0 +1,55 @@\n+import sys\n+import googlemaps\n+import datetime\n+from crontab import CronTab\n+from common import get_perturbed_trips_db, json_to_trip, find_perturbed_trips, initialize_empty_perturbed_trips, update_perturbations \n+\n+#usage:\n+#(From terminal)\n+#python query.py lat1,lon1 lat2,lon2\n+\n+if len(sys.argv) == 4:\n+\tcurr_time = datetime.datetime.now()\n+\tcurr_month = curr_time.month\n+\tcurr_day = curr_time.day\n+\tcurr_hour =curr_time.hour\n+\tcurr_minute = curr_time.minute\n+\n+\t_id = sys.argv[1]\n+\n+\tmodes = ['driving', 'walking', 'bicycling', 'transit']\n+\tgmaps = googlemaps.Client(key='AIzaSyBEkw4PXVv_bsAdUmrFwatEyS6xLw3Bd9c')\n+\n+\tfor mode in modes:\n+\t\tdirections_result = gmaps.directions(origin=start, destination=end,\n+\t                                 mode=mode,\n+\t                                 departure_time=datetime.datetime.now())\n+\t\tfor result in directions_result:\n+\t\t\t#do something here related to saving the trip\n+\t\t\t#not really sure how to maintain unique ids??\n+\t\t\tgmaps_trip = json_to_trip(result)\n+\t\t\tupdate_perturbations(_id, gmaps_trip)\n+\n+\t#remove job from cronjob\n+\t#TODO: make sure that you only remove the cronjob related to your current query, this will remove all cronjobs scheduled at the same time\n+\tcron = CronTab()\n+\tfor job in cron:\n+\t\tif job.month == curr_month and job.day == curr_day and job.hour == curr_hour and job.minute == curr_minute:\n+\t\t\tcron.remove(job)\n+\t\t\tprint(\"Removed job!\")\n+\n+\tpdb = get_perturbed_trips_db()\n+\ttrip = pdb.find_one({\"_id\" : _id})\n+\n+\t#@TODO: josh - can you fill in this code? not sure what method to call to get the trip from the alternatives collection\n+\tall_alts_finished = True\n+\tfor pert in find_perturbed_trips(trip):\n+\t\tpert._id = pert._id.replace('.', '') \n+\t\tif [pert._id] == None:\n+\t\t\tall_alts_finished = False\n+\n+\tif all_alts_finished:\n+\t\ttrip.getpipelineFlags().finishAlternatives()","path":"CFC_DataCollector/recommender/query.py","position":52,"original_position":52,"commit_id":"1348dce2fbe4a7a3b58cdb93034e9d29678a05e3","original_commit_id":"1348dce2fbe4a7a3b58cdb93034e9d29678a05e3","user":{"login":"jeffdh5","id":3132718,"avatar_url":"https://avatars.githubusercontent.com/u/3132718?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffdh5","html_url":"https://github.com/jeffdh5","followers_url":"https://api.github.com/users/jeffdh5/followers","following_url":"https://api.github.com/users/jeffdh5/following{/other_user}","gists_url":"https://api.github.com/users/jeffdh5/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffdh5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffdh5/subscriptions","organizations_url":"https://api.github.com/users/jeffdh5/orgs","repos_url":"https://api.github.com/users/jeffdh5/repos","events_url":"https://api.github.com/users/jeffdh5/events{/privacy}","received_events_url":"https://api.github.com/users/jeffdh5/received_events","type":"User","site_admin":false},"body":"It's not entirely clear to me what you are referring to, but I'm assuming\nyou're talking about the Pipeline flag that says the alternative is\nfinished. If so, that makes sense to me that it has to be stored in the\ndatabase.\n\nIf that's the case, it makes sense to modify the startAlternatives() and\nfinishAlternatives() methods to update the database. Do you agree with that?\n\nOn Sun, Mar 29, 2015 at 10:05 PM, shankari <notifications@github.com> wrote:\n\n> In CFC_DataCollector/recommender/query.py\n> <https://github.com/e-mission/e-mission-server/pull/103#discussion_r27366879>\n> :\n>\n> > +\t\tif job.month == curr_month and job.day == curr_day and job.hour == curr_hour and job.minute == curr_minute:\n> > +\t\t\tcron.remove(job)\n> > +\t\t\tprint(\"Removed job!\")\n> > +\n> > +\tpdb = get_perturbed_trips_db()\n> > +\ttrip = pdb.find_one({\"_id\" : _id})\n> > +\n> > +\t#@TODO: josh - can you fill in this code? not sure what method to call to get the trip from the alternatives collection\n> > +\tall_alts_finished = True\n> > +\tfor pert in find_perturbed_trips(trip):\n> > +\t\tpert._id = pert._id.replace('.', '')\n> > +\t\tif [pert._id] == None:\n> > +\t\t\tall_alts_finished = False\n> > +\n> > +\tif all_alts_finished:\n> > +\t\ttrip.getpipelineFlags().finishAlternatives()\n>\n> @jeffdh5 <https://github.com/jeffdh5>, don't you need to store this to\n> the database?\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/e-mission/e-mission-server/pull/103/files#r27366879>.\n>\n","created_at":"2015-03-30T05:40:40Z","updated_at":"2015-03-30T05:40:40Z","html_url":"https://github.com/e-mission/e-mission-server/pull/103#discussion_r27367635","pull_request_url":"https://api.github.com/repos/e-mission/e-mission-server/pulls/103","_links":{"self":{"href":"https://api.github.com/repos/e-mission/e-mission-server/pulls/comments/27367635"},"html":{"href":"https://github.com/e-mission/e-mission-server/pull/103#discussion_r27367635"},"pull_request":{"href":"https://api.github.com/repos/e-mission/e-mission-server/pulls/103"}}},"pull_request":{"url":"https://api.github.com/repos/e-mission/e-mission-server/pulls/103","id":30917734,"html_url":"https://github.com/e-mission/e-mission-server/pull/103","diff_url":"https://github.com/e-mission/e-mission-server/pull/103.diff","patch_url":"https://github.com/e-mission/e-mission-server/pull/103.patch","issue_url":"https://api.github.com/repos/e-mission/e-mission-server/issues/103","number":103,"state":"open","locked":false,"title":"[WIP] Recommender System","user":{"login":"jimmydief","id":4480230,"avatar_url":"https://avatars.githubusercontent.com/u/4480230?v=3","gravatar_id":"","url":"https://api.github.com/users/jimmydief","html_url":"https://github.com/jimmydief","followers_url":"https://api.github.com/users/jimmydief/followers","following_url":"https://api.github.com/users/jimmydief/following{/other_user}","gists_url":"https://api.github.com/users/jimmydief/gists{/gist_id}","starred_url":"https://api.github.com/users/jimmydief/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimmydief/subscriptions","organizations_url":"https://api.github.com/users/jimmydief/orgs","repos_url":"https://api.github.com/users/jimmydief/repos","events_url":"https://api.github.com/users/jimmydief/events{/privacy}","received_events_url":"https://api.github.com/users/jimmydief/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-03-11T06:08:20Z","updated_at":"2015-03-30T05:40:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8b6da120cd202c8f630a76b4467754f4d57da04d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/e-mission/e-mission-server/pulls/103/commits","review_comments_url":"https://api.github.com/repos/e-mission/e-mission-server/pulls/103/comments","review_comment_url":"https://api.github.com/repos/e-mission/e-mission-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/e-mission/e-mission-server/issues/103/comments","statuses_url":"https://api.github.com/repos/e-mission/e-mission-server/statuses/1348dce2fbe4a7a3b58cdb93034e9d29678a05e3","head":{"label":"jimmydief:recommender","ref":"recommender","sha":"1348dce2fbe4a7a3b58cdb93034e9d29678a05e3","user":{"login":"jimmydief","id":4480230,"avatar_url":"https://avatars.githubusercontent.com/u/4480230?v=3","gravatar_id":"","url":"https://api.github.com/users/jimmydief","html_url":"https://github.com/jimmydief","followers_url":"https://api.github.com/users/jimmydief/followers","following_url":"https://api.github.com/users/jimmydief/following{/other_user}","gists_url":"https://api.github.com/users/jimmydief/gists{/gist_id}","starred_url":"https://api.github.com/users/jimmydief/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimmydief/subscriptions","organizations_url":"https://api.github.com/users/jimmydief/orgs","repos_url":"https://api.github.com/users/jimmydief/repos","events_url":"https://api.github.com/users/jimmydief/events{/privacy}","received_events_url":"https://api.github.com/users/jimmydief/received_events","type":"User","site_admin":false},"repo":{"id":30278632,"name":"e-mission-server","full_name":"jimmydief/e-mission-server","owner":{"login":"jimmydief","id":4480230,"avatar_url":"https://avatars.githubusercontent.com/u/4480230?v=3","gravatar_id":"","url":"https://api.github.com/users/jimmydief","html_url":"https://github.com/jimmydief","followers_url":"https://api.github.com/users/jimmydief/followers","following_url":"https://api.github.com/users/jimmydief/following{/other_user}","gists_url":"https://api.github.com/users/jimmydief/gists{/gist_id}","starred_url":"https://api.github.com/users/jimmydief/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimmydief/subscriptions","organizations_url":"https://api.github.com/users/jimmydief/orgs","repos_url":"https://api.github.com/users/jimmydief/repos","events_url":"https://api.github.com/users/jimmydief/events{/privacy}","received_events_url":"https://api.github.com/users/jimmydief/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jimmydief/e-mission-server","description":"The backend (server) code for the e-mission server","fork":true,"url":"https://api.github.com/repos/jimmydief/e-mission-server","forks_url":"https://api.github.com/repos/jimmydief/e-mission-server/forks","keys_url":"https://api.github.com/repos/jimmydief/e-mission-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jimmydief/e-mission-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jimmydief/e-mission-server/teams","hooks_url":"https://api.github.com/repos/jimmydief/e-mission-server/hooks","issue_events_url":"https://api.github.com/repos/jimmydief/e-mission-server/issues/events{/number}","events_url":"https://api.github.com/repos/jimmydief/e-mission-server/events","assignees_url":"https://api.github.com/repos/jimmydief/e-mission-server/assignees{/user}","branches_url":"https://api.github.com/repos/jimmydief/e-mission-server/branches{/branch}","tags_url":"https://api.github.com/repos/jimmydief/e-mission-server/tags","blobs_url":"https://api.github.com/repos/jimmydief/e-mission-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jimmydief/e-mission-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jimmydief/e-mission-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/jimmydief/e-mission-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jimmydief/e-mission-server/statuses/{sha}","languages_url":"https://api.github.com/repos/jimmydief/e-mission-server/languages","stargazers_url":"https://api.github.com/repos/jimmydief/e-mission-server/stargazers","contributors_url":"https://api.github.com/repos/jimmydief/e-mission-server/contributors","subscribers_url":"https://api.github.com/repos/jimmydief/e-mission-server/subscribers","subscription_url":"https://api.github.com/repos/jimmydief/e-mission-server/subscription","commits_url":"https://api.github.com/repos/jimmydief/e-mission-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/jimmydief/e-mission-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/jimmydief/e-mission-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/jimmydief/e-mission-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/jimmydief/e-mission-server/contents/{+path}","compare_url":"https://api.github.com/repos/jimmydief/e-mission-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jimmydief/e-mission-server/merges","archive_url":"https://api.github.com/repos/jimmydief/e-mission-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jimmydief/e-mission-server/downloads","issues_url":"https://api.github.com/repos/jimmydief/e-mission-server/issues{/number}","pulls_url":"https://api.github.com/repos/jimmydief/e-mission-server/pulls{/number}","milestones_url":"https://api.github.com/repos/jimmydief/e-mission-server/milestones{/number}","notifications_url":"https://api.github.com/repos/jimmydief/e-mission-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jimmydief/e-mission-server/labels{/name}","releases_url":"https://api.github.com/repos/jimmydief/e-mission-server/releases{/id}","created_at":"2015-02-04T03:10:50Z","updated_at":"2015-03-15T23:04:49Z","pushed_at":"2015-03-30T04:17:37Z","git_url":"git://github.com/jimmydief/e-mission-server.git","ssh_url":"git@github.com:jimmydief/e-mission-server.git","clone_url":"https://github.com/jimmydief/e-mission-server.git","svn_url":"https://github.com/jimmydief/e-mission-server","homepage":"https://e-mission.eecs.berkeley.edu","size":31315,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"e-mission:recommender","ref":"recommender","sha":"2bb91764a41be29aefd1d99d58fdd11dcdcc70d4","user":{"login":"e-mission","id":10713694,"avatar_url":"https://avatars.githubusercontent.com/u/10713694?v=3","gravatar_id":"","url":"https://api.github.com/users/e-mission","html_url":"https://github.com/e-mission","followers_url":"https://api.github.com/users/e-mission/followers","following_url":"https://api.github.com/users/e-mission/following{/other_user}","gists_url":"https://api.github.com/users/e-mission/gists{/gist_id}","starred_url":"https://api.github.com/users/e-mission/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e-mission/subscriptions","organizations_url":"https://api.github.com/users/e-mission/orgs","repos_url":"https://api.github.com/users/e-mission/repos","events_url":"https://api.github.com/users/e-mission/events{/privacy}","received_events_url":"https://api.github.com/users/e-mission/received_events","type":"Organization","site_admin":false},"repo":{"id":26307245,"name":"e-mission-server","full_name":"e-mission/e-mission-server","owner":{"login":"e-mission","id":10713694,"avatar_url":"https://avatars.githubusercontent.com/u/10713694?v=3","gravatar_id":"","url":"https://api.github.com/users/e-mission","html_url":"https://github.com/e-mission","followers_url":"https://api.github.com/users/e-mission/followers","following_url":"https://api.github.com/users/e-mission/following{/other_user}","gists_url":"https://api.github.com/users/e-mission/gists{/gist_id}","starred_url":"https://api.github.com/users/e-mission/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e-mission/subscriptions","organizations_url":"https://api.github.com/users/e-mission/orgs","repos_url":"https://api.github.com/users/e-mission/repos","events_url":"https://api.github.com/users/e-mission/events{/privacy}","received_events_url":"https://api.github.com/users/e-mission/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/e-mission/e-mission-server","description":"The backend (server) code for the e-mission server","fork":false,"url":"https://api.github.com/repos/e-mission/e-mission-server","forks_url":"https://api.github.com/repos/e-mission/e-mission-server/forks","keys_url":"https://api.github.com/repos/e-mission/e-mission-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/e-mission/e-mission-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/e-mission/e-mission-server/teams","hooks_url":"https://api.github.com/repos/e-mission/e-mission-server/hooks","issue_events_url":"https://api.github.com/repos/e-mission/e-mission-server/issues/events{/number}","events_url":"https://api.github.com/repos/e-mission/e-mission-server/events","assignees_url":"https://api.github.com/repos/e-mission/e-mission-server/assignees{/user}","branches_url":"https://api.github.com/repos/e-mission/e-mission-server/branches{/branch}","tags_url":"https://api.github.com/repos/e-mission/e-mission-server/tags","blobs_url":"https://api.github.com/repos/e-mission/e-mission-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/e-mission/e-mission-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/e-mission/e-mission-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/e-mission/e-mission-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/e-mission/e-mission-server/statuses/{sha}","languages_url":"https://api.github.com/repos/e-mission/e-mission-server/languages","stargazers_url":"https://api.github.com/repos/e-mission/e-mission-server/stargazers","contributors_url":"https://api.github.com/repos/e-mission/e-mission-server/contributors","subscribers_url":"https://api.github.com/repos/e-mission/e-mission-server/subscribers","subscription_url":"https://api.github.com/repos/e-mission/e-mission-server/subscription","commits_url":"https://api.github.com/repos/e-mission/e-mission-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/e-mission/e-mission-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/e-mission/e-mission-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/e-mission/e-mission-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/e-mission/e-mission-server/contents/{+path}","compare_url":"https://api.github.com/repos/e-mission/e-mission-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/e-mission/e-mission-server/merges","archive_url":"https://api.github.com/repos/e-mission/e-mission-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/e-mission/e-mission-server/downloads","issues_url":"https://api.github.com/repos/e-mission/e-mission-server/issues{/number}","pulls_url":"https://api.github.com/repos/e-mission/e-mission-server/pulls{/number}","milestones_url":"https://api.github.com/repos/e-mission/e-mission-server/milestones{/number}","notifications_url":"https://api.github.com/repos/e-mission/e-mission-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/e-mission/e-mission-server/labels{/name}","releases_url":"https://api.github.com/repos/e-mission/e-mission-server/releases{/id}","created_at":"2014-11-07T06:39:02Z","updated_at":"2015-03-07T18:00:17Z","pushed_at":"2015-03-30T04:17:38Z","git_url":"git://github.com/e-mission/e-mission-server.git","ssh_url":"git@github.com:e-mission/e-mission-server.git","clone_url":"https://github.com/e-mission/e-mission-server.git","svn_url":"https://github.com/e-mission/e-mission-server","homepage":"https://e-mission.eecs.berkeley.edu","size":32473,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":27,"forks":21,"open_issues":27,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/e-mission/e-mission-server/pulls/103"},"html":{"href":"https://github.com/e-mission/e-mission-server/pull/103"},"issue":{"href":"https://api.github.com/repos/e-mission/e-mission-server/issues/103"},"comments":{"href":"https://api.github.com/repos/e-mission/e-mission-server/issues/103/comments"},"review_comments":{"href":"https://api.github.com/repos/e-mission/e-mission-server/pulls/103/comments"},"review_comment":{"href":"https://api.github.com/repos/e-mission/e-mission-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/e-mission/e-mission-server/pulls/103/commits"},"statuses":{"href":"https://api.github.com/repos/e-mission/e-mission-server/statuses/1348dce2fbe4a7a3b58cdb93034e9d29678a05e3"}}}}