{"action":"created","comment":{"url":"https://api.github.com/repos/slugiot/slugiot-server/pulls/comments/61156042","id":61156042,"diff_hunk":"@@ -12,62 +12,46 @@\n proc_table = db.procedures\n revisions_table = db.procedure_revisions\n \n-####### API FOR EDITOR TEAM ##########\n \n-# return procedure_id to be used for a new procedure being created\n-# note - currently this function does NOT implicitly save the procedure_id in the table\n-def create_procedure(procedure_name, user_id):\n-    return proc_table.insert(user_id = user_id,\n-                                name = procedure_name)\n+####### API FOR PROCEDURE HARNESS TEAM ##########\n \n-# return list procedure_id\n-# alternatively: return db(proc_table.user_id == user_id).select(proc_table.procedure_id)\n-# second option returns Rows object not list\n-def get_procedures_for_user(user_id):\n-    records = db(proc_table.user_id == user_id).select()\n-    procedure_ids = []\n-    for row in records:\n-        procedure_ids.append(row.id)\n-    return procedure_ids\n \n-# True for stable gets last stable, False gets most recent stable or not\n-# Do we have to worry about stuff coming in at the same time? Currently a bug\n-def get_procedure_data(procedure_id, stable):\n-    max = revisions_table.last_update.max()\n-    if stable:\n-        date = db((revisions_table.procedure_id == procedure_id) &\n-                                      (revisions_table.stable_version == stable)).select(max).first()[max]\n-    else:\n-        date = db(revisions_table.procedure_id == procedure_id).select(max).first()[max]\n-    return db((revisions_table.procedure_id == procedure_id) &\n-              (revisions_table.last_update == date)).select(revisions_table.procedure_data).first().procedure_data\n+def get_procedure_status(device_id):\n+    \"\"\"\n+    Called upon client request for procedure info\n \n-# True for stable is save stable, False is save temp\n-# when save is stable, flush all temp versions\n-def save(procedure_id, procedure_data, stable):\n-    # insert new record\n-    revisions_table.insert(procedure_id = procedure_id,\n-                           procedure_data = procedure_data,\n-                           last_update = datetime.datetime.utcnow(),\n-                           stable_version = stable)\n-    #flush temp versions for stable save\n-    if stable:\n-        db((db[table].uuid == item.uuid) &\n-           (db[table].id != item.id)).delete()\n-        db((revisions_table.procedure_id == procedure_id) &\n-           (revisions_table.stable_version == False)).delete()\n+    :param device_id: Device id for which the procedure sync is being performed\n+    :type device_id: long\n+    :return Dict of the format {procedure_id: last_update_stable}\n+                    that specifies the last save time for each procedure associated with the device\n+    :rtype:\n+    \"\"\"\n \n-####### API FOR PROCEDURE HARNESS TEAM ##########\n+    # Get all procedure_ids for the device_id\n+    procedure_ids = db((devices.device_id == device_id) &\n+                       (devices.user_email == proc_table.user_email)).select(proc_table.procedure_id)\n \n-# called in response to client request for procedure info\n-# returns a dictionary of the format {procedure_id, last_update_stable}\n-def get_procedure_status(device_id):\n-    # 1. Get all procedure_ids for the device_id\n-    procedure_ids = db((db.devices.device_id == device_id) &\n-                       (db.devices.user_id == proc_table.user_id)).select(proc_table.procedure_id)\n-    # 2. build dictionary containing last_update_stable date for each procedure_id\n+    # Build dictionary containing last_update date for each procedure_id\n     procedure_info = {}\n     for proc in procedure_ids:\n-        procedure_info[proc.procedure_id] = get_procedure_data(proc, True)\n-    # 3. return dictionary\n-    return procedure_info\n\\ No newline at end of file\n+        pid = proc.procedure_id\n+        procedure_info[pid] = db(revisions_table.procedure_id == pid).select(revisions_table.last_update).first().last_update\n+\n+    return procedure_info\n+\n+\n+def get_procedure_update(procedure_id_lst):","path":"applications/server/controllers/proc_harness.py","position":84,"original_position":84,"commit_id":"7f3dfb2c1241f6620d8d3b796467b8a9fa2bc165","original_commit_id":"7f3dfb2c1241f6620d8d3b796467b8a9fa2bc165","user":{"login":"lucadealfaro","id":118022,"avatar_url":"https://avatars.githubusercontent.com/u/118022?v=3","gravatar_id":"","url":"https://api.github.com/users/lucadealfaro","html_url":"https://github.com/lucadealfaro","followers_url":"https://api.github.com/users/lucadealfaro/followers","following_url":"https://api.github.com/users/lucadealfaro/following{/other_user}","gists_url":"https://api.github.com/users/lucadealfaro/gists{/gist_id}","starred_url":"https://api.github.com/users/lucadealfaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucadealfaro/subscriptions","organizations_url":"https://api.github.com/users/lucadealfaro/orgs","repos_url":"https://api.github.com/users/lucadealfaro/repos","events_url":"https://api.github.com/users/lucadealfaro/events{/privacy}","received_events_url":"https://api.github.com/users/lucadealfaro/received_events","type":"User","site_admin":false},"body":"I thought that this would be called with a device_id, and would return the list of all procedures for that device_id with their date. ","created_at":"2016-04-26T20:14:54Z","updated_at":"2016-04-26T20:14:54Z","html_url":"https://github.com/slugiot/slugiot-server/pull/17#discussion_r61156042","pull_request_url":"https://api.github.com/repos/slugiot/slugiot-server/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/slugiot/slugiot-server/pulls/comments/61156042"},"html":{"href":"https://github.com/slugiot/slugiot-server/pull/17#discussion_r61156042"},"pull_request":{"href":"https://api.github.com/repos/slugiot/slugiot-server/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/slugiot/slugiot-server/pulls/17","id":67432036,"html_url":"https://github.com/slugiot/slugiot-server/pull/17","diff_url":"https://github.com/slugiot/slugiot-server/pull/17.diff","patch_url":"https://github.com/slugiot/slugiot-server/pull/17.patch","issue_url":"https://api.github.com/repos/slugiot/slugiot-server/issues/17","number":17,"state":"open","locked":false,"title":"Procedure harness","user":{"login":"ahume128","id":2447805,"avatar_url":"https://avatars.githubusercontent.com/u/2447805?v=3","gravatar_id":"","url":"https://api.github.com/users/ahume128","html_url":"https://github.com/ahume128","followers_url":"https://api.github.com/users/ahume128/followers","following_url":"https://api.github.com/users/ahume128/following{/other_user}","gists_url":"https://api.github.com/users/ahume128/gists{/gist_id}","starred_url":"https://api.github.com/users/ahume128/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahume128/subscriptions","organizations_url":"https://api.github.com/users/ahume128/orgs","repos_url":"https://api.github.com/users/ahume128/repos","events_url":"https://api.github.com/users/ahume128/events{/privacy}","received_events_url":"https://api.github.com/users/ahume128/received_events","type":"User","site_admin":false},"body":"For now leaving both user_email and device_id in procedures table - we will continue to think about this and figure out a permanent solution with authorization team","created_at":"2016-04-21T22:22:45Z","updated_at":"2016-04-26T20:14:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b16c264439a9f8ae55de388a7b2159839b8622bc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/slugiot/slugiot-server/pulls/17/commits","review_comments_url":"https://api.github.com/repos/slugiot/slugiot-server/pulls/17/comments","review_comment_url":"https://api.github.com/repos/slugiot/slugiot-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/slugiot/slugiot-server/issues/17/comments","statuses_url":"https://api.github.com/repos/slugiot/slugiot-server/statuses/7f3dfb2c1241f6620d8d3b796467b8a9fa2bc165","head":{"label":"slugiot:procedure_harness","ref":"procedure_harness","sha":"7f3dfb2c1241f6620d8d3b796467b8a9fa2bc165","user":{"login":"slugiot","id":18412481,"avatar_url":"https://avatars.githubusercontent.com/u/18412481?v=3","gravatar_id":"","url":"https://api.github.com/users/slugiot","html_url":"https://github.com/slugiot","followers_url":"https://api.github.com/users/slugiot/followers","following_url":"https://api.github.com/users/slugiot/following{/other_user}","gists_url":"https://api.github.com/users/slugiot/gists{/gist_id}","starred_url":"https://api.github.com/users/slugiot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slugiot/subscriptions","organizations_url":"https://api.github.com/users/slugiot/orgs","repos_url":"https://api.github.com/users/slugiot/repos","events_url":"https://api.github.com/users/slugiot/events{/privacy}","received_events_url":"https://api.github.com/users/slugiot/received_events","type":"Organization","site_admin":false},"repo":{"id":56093310,"name":"slugiot-server","full_name":"slugiot/slugiot-server","owner":{"login":"slugiot","id":18412481,"avatar_url":"https://avatars.githubusercontent.com/u/18412481?v=3","gravatar_id":"","url":"https://api.github.com/users/slugiot","html_url":"https://github.com/slugiot","followers_url":"https://api.github.com/users/slugiot/followers","following_url":"https://api.github.com/users/slugiot/following{/other_user}","gists_url":"https://api.github.com/users/slugiot/gists{/gist_id}","starred_url":"https://api.github.com/users/slugiot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slugiot/subscriptions","organizations_url":"https://api.github.com/users/slugiot/orgs","repos_url":"https://api.github.com/users/slugiot/repos","events_url":"https://api.github.com/users/slugiot/events{/privacy}","received_events_url":"https://api.github.com/users/slugiot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/slugiot/slugiot-server","description":"","fork":false,"url":"https://api.github.com/repos/slugiot/slugiot-server","forks_url":"https://api.github.com/repos/slugiot/slugiot-server/forks","keys_url":"https://api.github.com/repos/slugiot/slugiot-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/slugiot/slugiot-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/slugiot/slugiot-server/teams","hooks_url":"https://api.github.com/repos/slugiot/slugiot-server/hooks","issue_events_url":"https://api.github.com/repos/slugiot/slugiot-server/issues/events{/number}","events_url":"https://api.github.com/repos/slugiot/slugiot-server/events","assignees_url":"https://api.github.com/repos/slugiot/slugiot-server/assignees{/user}","branches_url":"https://api.github.com/repos/slugiot/slugiot-server/branches{/branch}","tags_url":"https://api.github.com/repos/slugiot/slugiot-server/tags","blobs_url":"https://api.github.com/repos/slugiot/slugiot-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/slugiot/slugiot-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/slugiot/slugiot-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/slugiot/slugiot-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/slugiot/slugiot-server/statuses/{sha}","languages_url":"https://api.github.com/repos/slugiot/slugiot-server/languages","stargazers_url":"https://api.github.com/repos/slugiot/slugiot-server/stargazers","contributors_url":"https://api.github.com/repos/slugiot/slugiot-server/contributors","subscribers_url":"https://api.github.com/repos/slugiot/slugiot-server/subscribers","subscription_url":"https://api.github.com/repos/slugiot/slugiot-server/subscription","commits_url":"https://api.github.com/repos/slugiot/slugiot-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/slugiot/slugiot-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/slugiot/slugiot-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/slugiot/slugiot-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/slugiot/slugiot-server/contents/{+path}","compare_url":"https://api.github.com/repos/slugiot/slugiot-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/slugiot/slugiot-server/merges","archive_url":"https://api.github.com/repos/slugiot/slugiot-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/slugiot/slugiot-server/downloads","issues_url":"https://api.github.com/repos/slugiot/slugiot-server/issues{/number}","pulls_url":"https://api.github.com/repos/slugiot/slugiot-server/pulls{/number}","milestones_url":"https://api.github.com/repos/slugiot/slugiot-server/milestones{/number}","notifications_url":"https://api.github.com/repos/slugiot/slugiot-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/slugiot/slugiot-server/labels{/name}","releases_url":"https://api.github.com/repos/slugiot/slugiot-server/releases{/id}","deployments_url":"https://api.github.com/repos/slugiot/slugiot-server/deployments","created_at":"2016-04-12T19:53:50Z","updated_at":"2016-04-20T00:18:47Z","pushed_at":"2016-04-26T19:55:10Z","git_url":"git://github.com/slugiot/slugiot-server.git","ssh_url":"git@github.com:slugiot/slugiot-server.git","clone_url":"https://github.com/slugiot/slugiot-server.git","svn_url":"https://github.com/slugiot/slugiot-server","homepage":null,"size":34765,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":3,"forks":3,"open_issues":3,"watchers":2,"default_branch":"master_slugiot"}},"base":{"label":"slugiot:master_slugiot","ref":"master_slugiot","sha":"1128e3ab8294e940aebeb480ddb7659908cfe4cc","user":{"login":"slugiot","id":18412481,"avatar_url":"https://avatars.githubusercontent.com/u/18412481?v=3","gravatar_id":"","url":"https://api.github.com/users/slugiot","html_url":"https://github.com/slugiot","followers_url":"https://api.github.com/users/slugiot/followers","following_url":"https://api.github.com/users/slugiot/following{/other_user}","gists_url":"https://api.github.com/users/slugiot/gists{/gist_id}","starred_url":"https://api.github.com/users/slugiot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slugiot/subscriptions","organizations_url":"https://api.github.com/users/slugiot/orgs","repos_url":"https://api.github.com/users/slugiot/repos","events_url":"https://api.github.com/users/slugiot/events{/privacy}","received_events_url":"https://api.github.com/users/slugiot/received_events","type":"Organization","site_admin":false},"repo":{"id":56093310,"name":"slugiot-server","full_name":"slugiot/slugiot-server","owner":{"login":"slugiot","id":18412481,"avatar_url":"https://avatars.githubusercontent.com/u/18412481?v=3","gravatar_id":"","url":"https://api.github.com/users/slugiot","html_url":"https://github.com/slugiot","followers_url":"https://api.github.com/users/slugiot/followers","following_url":"https://api.github.com/users/slugiot/following{/other_user}","gists_url":"https://api.github.com/users/slugiot/gists{/gist_id}","starred_url":"https://api.github.com/users/slugiot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slugiot/subscriptions","organizations_url":"https://api.github.com/users/slugiot/orgs","repos_url":"https://api.github.com/users/slugiot/repos","events_url":"https://api.github.com/users/slugiot/events{/privacy}","received_events_url":"https://api.github.com/users/slugiot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/slugiot/slugiot-server","description":"","fork":false,"url":"https://api.github.com/repos/slugiot/slugiot-server","forks_url":"https://api.github.com/repos/slugiot/slugiot-server/forks","keys_url":"https://api.github.com/repos/slugiot/slugiot-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/slugiot/slugiot-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/slugiot/slugiot-server/teams","hooks_url":"https://api.github.com/repos/slugiot/slugiot-server/hooks","issue_events_url":"https://api.github.com/repos/slugiot/slugiot-server/issues/events{/number}","events_url":"https://api.github.com/repos/slugiot/slugiot-server/events","assignees_url":"https://api.github.com/repos/slugiot/slugiot-server/assignees{/user}","branches_url":"https://api.github.com/repos/slugiot/slugiot-server/branches{/branch}","tags_url":"https://api.github.com/repos/slugiot/slugiot-server/tags","blobs_url":"https://api.github.com/repos/slugiot/slugiot-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/slugiot/slugiot-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/slugiot/slugiot-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/slugiot/slugiot-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/slugiot/slugiot-server/statuses/{sha}","languages_url":"https://api.github.com/repos/slugiot/slugiot-server/languages","stargazers_url":"https://api.github.com/repos/slugiot/slugiot-server/stargazers","contributors_url":"https://api.github.com/repos/slugiot/slugiot-server/contributors","subscribers_url":"https://api.github.com/repos/slugiot/slugiot-server/subscribers","subscription_url":"https://api.github.com/repos/slugiot/slugiot-server/subscription","commits_url":"https://api.github.com/repos/slugiot/slugiot-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/slugiot/slugiot-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/slugiot/slugiot-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/slugiot/slugiot-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/slugiot/slugiot-server/contents/{+path}","compare_url":"https://api.github.com/repos/slugiot/slugiot-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/slugiot/slugiot-server/merges","archive_url":"https://api.github.com/repos/slugiot/slugiot-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/slugiot/slugiot-server/downloads","issues_url":"https://api.github.com/repos/slugiot/slugiot-server/issues{/number}","pulls_url":"https://api.github.com/repos/slugiot/slugiot-server/pulls{/number}","milestones_url":"https://api.github.com/repos/slugiot/slugiot-server/milestones{/number}","notifications_url":"https://api.github.com/repos/slugiot/slugiot-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/slugiot/slugiot-server/labels{/name}","releases_url":"https://api.github.com/repos/slugiot/slugiot-server/releases{/id}","deployments_url":"https://api.github.com/repos/slugiot/slugiot-server/deployments","created_at":"2016-04-12T19:53:50Z","updated_at":"2016-04-20T00:18:47Z","pushed_at":"2016-04-26T19:55:10Z","git_url":"git://github.com/slugiot/slugiot-server.git","ssh_url":"git@github.com:slugiot/slugiot-server.git","clone_url":"https://github.com/slugiot/slugiot-server.git","svn_url":"https://github.com/slugiot/slugiot-server","homepage":null,"size":34765,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":3,"forks":3,"open_issues":3,"watchers":2,"default_branch":"master_slugiot"}},"_links":{"self":{"href":"https://api.github.com/repos/slugiot/slugiot-server/pulls/17"},"html":{"href":"https://github.com/slugiot/slugiot-server/pull/17"},"issue":{"href":"https://api.github.com/repos/slugiot/slugiot-server/issues/17"},"comments":{"href":"https://api.github.com/repos/slugiot/slugiot-server/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/slugiot/slugiot-server/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/slugiot/slugiot-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/slugiot/slugiot-server/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/slugiot/slugiot-server/statuses/7f3dfb2c1241f6620d8d3b796467b8a9fa2bc165"}}}}