{"action":"created","comment":{"url":"https://api.github.com/repos/dmsimard/ara/pulls/comments/66303995","id":66303995,"diff_hunk":"@@ -85,13 +87,39 @@ def __init__(self):\n \n     def get_or_create_host(self, hostname):\n         try:\n-            host = models.Host.query.filter_by(name=hostname).one()\n+            host = (models.Host.query\n+                    .filter_by(name=hostname)\n+                    .filter_by(playbook_id=self.playbook.id)\n+                    .one())\n         except models.NoResultFound:\n-            host = models.Host(name=hostname)\n+            host = models.Host(name=hostname, playbook=self.playbook)\n             db.session.add(host)\n \n         return host\n \n+    def get_or_create_file(self, path):\n+        try:\n+            file_ = (models.File.query\n+                     .filter_by(path=path)\n+                     .filter_by(playbook_id=self.playbook.id)\n+                     .one())\n+        except models.NoResultFound:\n+            file_ = models.File(path=path, playbook=self.playbook)\n+            db.session.add(file_)\n+\n+            # LKS: should collecting content be optional?\n+            with open(path, 'r') as fd:\n+                sha1 = hashlib.sha1(fd.read()).hexdigest()","path":"ara/callback/log_ara.py","position":45,"original_position":45,"commit_id":"a56bacd663998b5e16dcb7cf0d8fb748c969c42c","original_commit_id":"3d4fd3cfde22c80d644dd63f71a0a039dfa68767","user":{"login":"dmsimard","id":1291204,"avatar_url":"https://avatars.githubusercontent.com/u/1291204?v=3","gravatar_id":"","url":"https://api.github.com/users/dmsimard","html_url":"https://github.com/dmsimard","followers_url":"https://api.github.com/users/dmsimard/followers","following_url":"https://api.github.com/users/dmsimard/following{/other_user}","gists_url":"https://api.github.com/users/dmsimard/gists{/gist_id}","starred_url":"https://api.github.com/users/dmsimard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmsimard/subscriptions","organizations_url":"https://api.github.com/users/dmsimard/orgs","repos_url":"https://api.github.com/users/dmsimard/repos","events_url":"https://api.github.com/users/dmsimard/events{/privacy}","received_events_url":"https://api.github.com/users/dmsimard/received_events","type":"User","site_admin":false},"body":"I don't have a strong opinion. If we feel we're going to be using the sha1 call in too many places, it should go in utils. This is just two places for the time being (model and here) but will it be used elsewhere as well ?","created_at":"2016-06-08T17:46:43Z","updated_at":"2016-06-08T17:46:43Z","html_url":"https://github.com/dmsimard/ara/pull/105#discussion_r66303995","pull_request_url":"https://api.github.com/repos/dmsimard/ara/pulls/105","_links":{"self":{"href":"https://api.github.com/repos/dmsimard/ara/pulls/comments/66303995"},"html":{"href":"https://github.com/dmsimard/ara/pull/105#discussion_r66303995"},"pull_request":{"href":"https://api.github.com/repos/dmsimard/ara/pulls/105"}}},"pull_request":{"url":"https://api.github.com/repos/dmsimard/ara/pulls/105","id":72591961,"html_url":"https://github.com/dmsimard/ara/pull/105","diff_url":"https://github.com/dmsimard/ara/pull/105.diff","patch_url":"https://github.com/dmsimard/ara/pull/105.patch","issue_url":"https://api.github.com/repos/dmsimard/ara/issues/105","number":105,"state":"open","locked":false,"title":"handling hosts and files sanely","user":{"login":"larsks","id":82622,"avatar_url":"https://avatars.githubusercontent.com/u/82622?v=3","gravatar_id":"","url":"https://api.github.com/users/larsks","html_url":"https://github.com/larsks","followers_url":"https://api.github.com/users/larsks/followers","following_url":"https://api.github.com/users/larsks/following{/other_user}","gists_url":"https://api.github.com/users/larsks/gists{/gist_id}","starred_url":"https://api.github.com/users/larsks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larsks/subscriptions","organizations_url":"https://api.github.com/users/larsks/orgs","repos_url":"https://api.github.com/users/larsks/repos","events_url":"https://api.github.com/users/larsks/events{/privacy}","received_events_url":"https://api.github.com/users/larsks/received_events","type":"User","site_admin":false},"body":"**DO NOT MERGE**\r\n\r\nthis change introduces database schema changes necessary to support\r\nboth #102 and #103:\r\n\r\n- Hosts are now only unique within a playbook run (so you can have\r\n  multiple hosts with the same name in the hosts table as long as they\r\n  are associated with different top-level playbooks).\r\n\r\n- Files are treated the same way.  Each task is linked to a file, and\r\n  filenames are unique within a playbook run, but we don't assume that\r\n  /path/to/your/tasks.yml in one run is the same in another run.\r\n\r\nThis includes the necessary changes to the callback plugin to support\r\nthe new schema.\r\n\r\n**This commit does not contain web ui updates**","created_at":"2016-06-04T03:49:02Z","updated_at":"2016-06-08T17:46:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0dfc63b5721193712c5bc0e55f7cf8e21bb83bbe","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dmsimard/ara/pulls/105/commits","review_comments_url":"https://api.github.com/repos/dmsimard/ara/pulls/105/comments","review_comment_url":"https://api.github.com/repos/dmsimard/ara/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dmsimard/ara/issues/105/comments","statuses_url":"https://api.github.com/repos/dmsimard/ara/statuses/a56bacd663998b5e16dcb7cf0d8fb748c969c42c","head":{"label":"larsks:feature/database-scheming","ref":"feature/database-scheming","sha":"a56bacd663998b5e16dcb7cf0d8fb748c969c42c","user":{"login":"larsks","id":82622,"avatar_url":"https://avatars.githubusercontent.com/u/82622?v=3","gravatar_id":"","url":"https://api.github.com/users/larsks","html_url":"https://github.com/larsks","followers_url":"https://api.github.com/users/larsks/followers","following_url":"https://api.github.com/users/larsks/following{/other_user}","gists_url":"https://api.github.com/users/larsks/gists{/gist_id}","starred_url":"https://api.github.com/users/larsks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larsks/subscriptions","organizations_url":"https://api.github.com/users/larsks/orgs","repos_url":"https://api.github.com/users/larsks/repos","events_url":"https://api.github.com/users/larsks/events{/privacy}","received_events_url":"https://api.github.com/users/larsks/received_events","type":"User","site_admin":false},"repo":{"id":58513542,"name":"ara","full_name":"larsks/ara","owner":{"login":"larsks","id":82622,"avatar_url":"https://avatars.githubusercontent.com/u/82622?v=3","gravatar_id":"","url":"https://api.github.com/users/larsks","html_url":"https://github.com/larsks","followers_url":"https://api.github.com/users/larsks/followers","following_url":"https://api.github.com/users/larsks/following{/other_user}","gists_url":"https://api.github.com/users/larsks/gists{/gist_id}","starred_url":"https://api.github.com/users/larsks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larsks/subscriptions","organizations_url":"https://api.github.com/users/larsks/orgs","repos_url":"https://api.github.com/users/larsks/repos","events_url":"https://api.github.com/users/larsks/events{/privacy}","received_events_url":"https://api.github.com/users/larsks/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/larsks/ara","description":"ARA - Ansible Run Analysis","fork":true,"url":"https://api.github.com/repos/larsks/ara","forks_url":"https://api.github.com/repos/larsks/ara/forks","keys_url":"https://api.github.com/repos/larsks/ara/keys{/key_id}","collaborators_url":"https://api.github.com/repos/larsks/ara/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/larsks/ara/teams","hooks_url":"https://api.github.com/repos/larsks/ara/hooks","issue_events_url":"https://api.github.com/repos/larsks/ara/issues/events{/number}","events_url":"https://api.github.com/repos/larsks/ara/events","assignees_url":"https://api.github.com/repos/larsks/ara/assignees{/user}","branches_url":"https://api.github.com/repos/larsks/ara/branches{/branch}","tags_url":"https://api.github.com/repos/larsks/ara/tags","blobs_url":"https://api.github.com/repos/larsks/ara/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/larsks/ara/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/larsks/ara/git/refs{/sha}","trees_url":"https://api.github.com/repos/larsks/ara/git/trees{/sha}","statuses_url":"https://api.github.com/repos/larsks/ara/statuses/{sha}","languages_url":"https://api.github.com/repos/larsks/ara/languages","stargazers_url":"https://api.github.com/repos/larsks/ara/stargazers","contributors_url":"https://api.github.com/repos/larsks/ara/contributors","subscribers_url":"https://api.github.com/repos/larsks/ara/subscribers","subscription_url":"https://api.github.com/repos/larsks/ara/subscription","commits_url":"https://api.github.com/repos/larsks/ara/commits{/sha}","git_commits_url":"https://api.github.com/repos/larsks/ara/git/commits{/sha}","comments_url":"https://api.github.com/repos/larsks/ara/comments{/number}","issue_comment_url":"https://api.github.com/repos/larsks/ara/issues/comments{/number}","contents_url":"https://api.github.com/repos/larsks/ara/contents/{+path}","compare_url":"https://api.github.com/repos/larsks/ara/compare/{base}...{head}","merges_url":"https://api.github.com/repos/larsks/ara/merges","archive_url":"https://api.github.com/repos/larsks/ara/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/larsks/ara/downloads","issues_url":"https://api.github.com/repos/larsks/ara/issues{/number}","pulls_url":"https://api.github.com/repos/larsks/ara/pulls{/number}","milestones_url":"https://api.github.com/repos/larsks/ara/milestones{/number}","notifications_url":"https://api.github.com/repos/larsks/ara/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/larsks/ara/labels{/name}","releases_url":"https://api.github.com/repos/larsks/ara/releases{/id}","deployments_url":"https://api.github.com/repos/larsks/ara/deployments","created_at":"2016-05-11T04:10:03Z","updated_at":"2016-05-11T04:10:04Z","pushed_at":"2016-06-07T18:42:33Z","git_url":"git://github.com/larsks/ara.git","ssh_url":"git@github.com:larsks/ara.git","clone_url":"https://github.com/larsks/ara.git","svn_url":"https://github.com/larsks/ara","homepage":"","size":937,"stargazers_count":0,"watchers_count":0,"language":"HTML","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":"dmsimard:master","ref":"master","sha":"81207b924ba730466d3253976712e81fa0815de1","user":{"login":"dmsimard","id":1291204,"avatar_url":"https://avatars.githubusercontent.com/u/1291204?v=3","gravatar_id":"","url":"https://api.github.com/users/dmsimard","html_url":"https://github.com/dmsimard","followers_url":"https://api.github.com/users/dmsimard/followers","following_url":"https://api.github.com/users/dmsimard/following{/other_user}","gists_url":"https://api.github.com/users/dmsimard/gists{/gist_id}","starred_url":"https://api.github.com/users/dmsimard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmsimard/subscriptions","organizations_url":"https://api.github.com/users/dmsimard/orgs","repos_url":"https://api.github.com/users/dmsimard/repos","events_url":"https://api.github.com/users/dmsimard/events{/privacy}","received_events_url":"https://api.github.com/users/dmsimard/received_events","type":"User","site_admin":false},"repo":{"id":58235533,"name":"ara","full_name":"dmsimard/ara","owner":{"login":"dmsimard","id":1291204,"avatar_url":"https://avatars.githubusercontent.com/u/1291204?v=3","gravatar_id":"","url":"https://api.github.com/users/dmsimard","html_url":"https://github.com/dmsimard","followers_url":"https://api.github.com/users/dmsimard/followers","following_url":"https://api.github.com/users/dmsimard/following{/other_user}","gists_url":"https://api.github.com/users/dmsimard/gists{/gist_id}","starred_url":"https://api.github.com/users/dmsimard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmsimard/subscriptions","organizations_url":"https://api.github.com/users/dmsimard/orgs","repos_url":"https://api.github.com/users/dmsimard/repos","events_url":"https://api.github.com/users/dmsimard/events{/privacy}","received_events_url":"https://api.github.com/users/dmsimard/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dmsimard/ara","description":"ARA - Ansible Run Analysis","fork":false,"url":"https://api.github.com/repos/dmsimard/ara","forks_url":"https://api.github.com/repos/dmsimard/ara/forks","keys_url":"https://api.github.com/repos/dmsimard/ara/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dmsimard/ara/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dmsimard/ara/teams","hooks_url":"https://api.github.com/repos/dmsimard/ara/hooks","issue_events_url":"https://api.github.com/repos/dmsimard/ara/issues/events{/number}","events_url":"https://api.github.com/repos/dmsimard/ara/events","assignees_url":"https://api.github.com/repos/dmsimard/ara/assignees{/user}","branches_url":"https://api.github.com/repos/dmsimard/ara/branches{/branch}","tags_url":"https://api.github.com/repos/dmsimard/ara/tags","blobs_url":"https://api.github.com/repos/dmsimard/ara/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dmsimard/ara/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dmsimard/ara/git/refs{/sha}","trees_url":"https://api.github.com/repos/dmsimard/ara/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dmsimard/ara/statuses/{sha}","languages_url":"https://api.github.com/repos/dmsimard/ara/languages","stargazers_url":"https://api.github.com/repos/dmsimard/ara/stargazers","contributors_url":"https://api.github.com/repos/dmsimard/ara/contributors","subscribers_url":"https://api.github.com/repos/dmsimard/ara/subscribers","subscription_url":"https://api.github.com/repos/dmsimard/ara/subscription","commits_url":"https://api.github.com/repos/dmsimard/ara/commits{/sha}","git_commits_url":"https://api.github.com/repos/dmsimard/ara/git/commits{/sha}","comments_url":"https://api.github.com/repos/dmsimard/ara/comments{/number}","issue_comment_url":"https://api.github.com/repos/dmsimard/ara/issues/comments{/number}","contents_url":"https://api.github.com/repos/dmsimard/ara/contents/{+path}","compare_url":"https://api.github.com/repos/dmsimard/ara/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dmsimard/ara/merges","archive_url":"https://api.github.com/repos/dmsimard/ara/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dmsimard/ara/downloads","issues_url":"https://api.github.com/repos/dmsimard/ara/issues{/number}","pulls_url":"https://api.github.com/repos/dmsimard/ara/pulls{/number}","milestones_url":"https://api.github.com/repos/dmsimard/ara/milestones{/number}","notifications_url":"https://api.github.com/repos/dmsimard/ara/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dmsimard/ara/labels{/name}","releases_url":"https://api.github.com/repos/dmsimard/ara/releases{/id}","deployments_url":"https://api.github.com/repos/dmsimard/ara/deployments","created_at":"2016-05-06T21:20:24Z","updated_at":"2016-06-08T17:01:26Z","pushed_at":"2016-06-08T14:36:09Z","git_url":"git://github.com/dmsimard/ara.git","ssh_url":"git@github.com:dmsimard/ara.git","clone_url":"https://github.com/dmsimard/ara.git","svn_url":"https://github.com/dmsimard/ara","homepage":"","size":948,"stargazers_count":36,"watchers_count":36,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":16,"forks":5,"open_issues":16,"watchers":36,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dmsimard/ara/pulls/105"},"html":{"href":"https://github.com/dmsimard/ara/pull/105"},"issue":{"href":"https://api.github.com/repos/dmsimard/ara/issues/105"},"comments":{"href":"https://api.github.com/repos/dmsimard/ara/issues/105/comments"},"review_comments":{"href":"https://api.github.com/repos/dmsimard/ara/pulls/105/comments"},"review_comment":{"href":"https://api.github.com/repos/dmsimard/ara/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dmsimard/ara/pulls/105/commits"},"statuses":{"href":"https://api.github.com/repos/dmsimard/ara/statuses/a56bacd663998b5e16dcb7cf0d8fb748c969c42c"}}}}
{"actor":{"display_login":"dmsimard"}}