{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/131145083","pull_request_review_id":54096889,"id":131145083,"diff_hunk":"@@ -103,13 +106,22 @@ def banner_path(self):\n             return None\n \n     def update_search(self):\n-        from website.search.search import update_institution\n+        from website.search.search import update_institution, update_node\n         from website.search.exceptions import SearchUnavailableError\n+\n         try:\n             update_institution(self)\n         except SearchUnavailableError as e:\n             logger.exception(e)\n \n+        saved_fields = self.get_dirty_fields()\n+        if saved_fields and bool(self.pk):\n+            for node in self.nodes.filter(is_deleted=False):\n+                try:\n+                    update_node(node, async=False)","path":"osf/models/institution.py","position":34,"original_position":34,"commit_id":"5e86f8efc5460bd45d3ff75836443178e9c89fae","original_commit_id":"5e86f8efc5460bd45d3ff75836443178e9c89fae","user":{"login":"sloria","id":2379650,"avatar_url":"https://avatars2.githubusercontent.com/u/2379650?v=4","gravatar_id":"","url":"https://api.github.com/users/sloria","html_url":"https://github.com/sloria","followers_url":"https://api.github.com/users/sloria/followers","following_url":"https://api.github.com/users/sloria/following{/other_user}","gists_url":"https://api.github.com/users/sloria/gists{/gist_id}","starred_url":"https://api.github.com/users/sloria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sloria/subscriptions","organizations_url":"https://api.github.com/users/sloria/orgs","repos_url":"https://api.github.com/users/sloria/repos","events_url":"https://api.github.com/users/sloria/events{/privacy}","received_events_url":"https://api.github.com/users/sloria/received_events","type":"User","site_admin":false},"body":"Thanks","created_at":"2017-08-03T13:45:04Z","updated_at":"2017-08-03T13:45:04Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/7477#discussion_r131145083","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7477","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/131145083"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/7477#discussion_r131145083"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7477"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7477","id":131124581,"html_url":"https://github.com/CenterForOpenScience/osf.io/pull/7477","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/7477.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/7477.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7477","number":7477,"state":"closed","locked":false,"title":"[feature] Add DirtyFieldsMixin to Institution Model [OSF-8244]","user":{"login":"caseyrollins","id":7913604,"avatar_url":"https://avatars0.githubusercontent.com/u/7913604?v=4","gravatar_id":"","url":"https://api.github.com/users/caseyrollins","html_url":"https://github.com/caseyrollins","followers_url":"https://api.github.com/users/caseyrollins/followers","following_url":"https://api.github.com/users/caseyrollins/following{/other_user}","gists_url":"https://api.github.com/users/caseyrollins/gists{/gist_id}","starred_url":"https://api.github.com/users/caseyrollins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseyrollins/subscriptions","organizations_url":"https://api.github.com/users/caseyrollins/orgs","repos_url":"https://api.github.com/users/caseyrollins/repos","events_url":"https://api.github.com/users/caseyrollins/events{/privacy}","received_events_url":"https://api.github.com/users/caseyrollins/received_events","type":"User","site_admin":false},"body":"#### Purpose\r\n- Optimizes `scripts.populate_institutions` \r\n- Removes the call to `update_node` for every affiliated node of every institution updated/created in the script. Instead, nodes will be updated in search if the institution is actually changed on save, i.e. if the name of an institution is changed in the populate script.\r\n\r\n#### Changes\r\n- Add `DirtyFieldsMixin` to `Institution` model. \r\n- Update `Insitution.save()` to check for changed fields before calling `update_node` for all affiliated nodes. \r\n\r\n#### Side Effects\r\n- Whenever an Institution is saved (with a changed field, such as `name`), `update_node` will be called for every node affiliated with that institution. In theory, this shouldn't be a problem because `scripts.populate_institutions` is the only place where institutions are updated.\r\n\r\n#### Ticket\r\n- [OSF-8244](https://openscience.atlassian.net/browse/OSF-8244)\r\n","created_at":"2017-07-18T15:55:47Z","updated_at":"2017-08-03T13:45:04Z","closed_at":"2017-08-01T20:23:54Z","merged_at":"2017-08-01T20:23:54Z","merge_commit_sha":"2afdfab9957d882d53b024ae070350e716956324","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7477/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7477/comments","review_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7477/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/5e86f8efc5460bd45d3ff75836443178e9c89fae","head":{"label":"caseyrollins:feature/optimize-populate-insts","ref":"feature/optimize-populate-insts","sha":"5e86f8efc5460bd45d3ff75836443178e9c89fae","user":{"login":"caseyrollins","id":7913604,"avatar_url":"https://avatars0.githubusercontent.com/u/7913604?v=4","gravatar_id":"","url":"https://api.github.com/users/caseyrollins","html_url":"https://github.com/caseyrollins","followers_url":"https://api.github.com/users/caseyrollins/followers","following_url":"https://api.github.com/users/caseyrollins/following{/other_user}","gists_url":"https://api.github.com/users/caseyrollins/gists{/gist_id}","starred_url":"https://api.github.com/users/caseyrollins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseyrollins/subscriptions","organizations_url":"https://api.github.com/users/caseyrollins/orgs","repos_url":"https://api.github.com/users/caseyrollins/repos","events_url":"https://api.github.com/users/caseyrollins/events{/privacy}","received_events_url":"https://api.github.com/users/caseyrollins/received_events","type":"User","site_admin":false},"repo":{"id":26963858,"name":"osf.io","full_name":"caseyrollins/osf.io","owner":{"login":"caseyrollins","id":7913604,"avatar_url":"https://avatars0.githubusercontent.com/u/7913604?v=4","gravatar_id":"","url":"https://api.github.com/users/caseyrollins","html_url":"https://github.com/caseyrollins","followers_url":"https://api.github.com/users/caseyrollins/followers","following_url":"https://api.github.com/users/caseyrollins/following{/other_user}","gists_url":"https://api.github.com/users/caseyrollins/gists{/gist_id}","starred_url":"https://api.github.com/users/caseyrollins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseyrollins/subscriptions","organizations_url":"https://api.github.com/users/caseyrollins/orgs","repos_url":"https://api.github.com/users/caseyrollins/repos","events_url":"https://api.github.com/users/caseyrollins/events{/privacy}","received_events_url":"https://api.github.com/users/caseyrollins/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/caseyrollins/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/caseyrollins/osf.io","forks_url":"https://api.github.com/repos/caseyrollins/osf.io/forks","keys_url":"https://api.github.com/repos/caseyrollins/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caseyrollins/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caseyrollins/osf.io/teams","hooks_url":"https://api.github.com/repos/caseyrollins/osf.io/hooks","issue_events_url":"https://api.github.com/repos/caseyrollins/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/caseyrollins/osf.io/events","assignees_url":"https://api.github.com/repos/caseyrollins/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/caseyrollins/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/caseyrollins/osf.io/tags","blobs_url":"https://api.github.com/repos/caseyrollins/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caseyrollins/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caseyrollins/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/caseyrollins/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caseyrollins/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/caseyrollins/osf.io/languages","stargazers_url":"https://api.github.com/repos/caseyrollins/osf.io/stargazers","contributors_url":"https://api.github.com/repos/caseyrollins/osf.io/contributors","subscribers_url":"https://api.github.com/repos/caseyrollins/osf.io/subscribers","subscription_url":"https://api.github.com/repos/caseyrollins/osf.io/subscription","commits_url":"https://api.github.com/repos/caseyrollins/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/caseyrollins/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/caseyrollins/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/caseyrollins/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/caseyrollins/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/caseyrollins/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caseyrollins/osf.io/merges","archive_url":"https://api.github.com/repos/caseyrollins/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caseyrollins/osf.io/downloads","issues_url":"https://api.github.com/repos/caseyrollins/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/caseyrollins/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/caseyrollins/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/caseyrollins/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caseyrollins/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/caseyrollins/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/caseyrollins/osf.io/deployments","created_at":"2014-11-21T14:49:09Z","updated_at":"2016-01-20T14:34:47Z","pushed_at":"2017-08-03T13:44:01Z","git_url":"git://github.com/caseyrollins/osf.io.git","ssh_url":"git@github.com:caseyrollins/osf.io.git","clone_url":"https://github.com/caseyrollins/osf.io.git","svn_url":"https://github.com/caseyrollins/osf.io","homepage":"http://osf.io","size":155052,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"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":"develop"}},"base":{"label":"CenterForOpenScience:develop","ref":"develop","sha":"a1fe639ee977c3425d7b951aef82dfa0b18ba8f3","user":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars1.githubusercontent.com/u/3344584?v=4","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"repo":{"id":10199599,"name":"osf.io","full_name":"CenterForOpenScience/osf.io","owner":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars1.githubusercontent.com/u/3344584?v=4","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CenterForOpenScience/osf.io","description":"Facilitating Open Science","fork":false,"url":"https://api.github.com/repos/CenterForOpenScience/osf.io","forks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/forks","keys_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/teams","hooks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/hooks","issue_events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/events","assignees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/tags","blobs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/languages","stargazers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/stargazers","contributors_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contributors","subscribers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscribers","subscription_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscription","commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/merges","archive_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/downloads","issues_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/deployments","created_at":"2013-05-21T15:53:37Z","updated_at":"2017-08-03T08:22:46Z","pushed_at":"2017-08-03T13:21:54Z","git_url":"git://github.com/CenterForOpenScience/osf.io.git","ssh_url":"git@github.com:CenterForOpenScience/osf.io.git","clone_url":"https://github.com/CenterForOpenScience/osf.io.git","svn_url":"https://github.com/CenterForOpenScience/osf.io","homepage":"https://osf.io","size":156686,"stargazers_count":352,"watchers_count":352,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":230,"mirror_url":null,"open_issues_count":264,"forks":230,"open_issues":264,"watchers":352,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7477"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/7477"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7477"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7477/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7477/comments"},"review_comment":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7477/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/5e86f8efc5460bd45d3ff75836443178e9c89fae"}}}}
{"actor":{"display_login":"sloria"}}