{"action":"created","comment":{"url":"https://api.github.com/repos/duke-libraries/ddr-models/pulls/comments/46313302","id":46313302,"diff_hunk":"@@ -4,8 +4,20 @@ module HasChildren\n \n       def first_child\n         child_class = self.class.reflect_on_association(:children).klass\n-        solr_field = child_class.reflect_on_association(:parent).solr_key\n-        child_class.where(solr_field => id).order(\"#{Ddr::Index::Fields::LOCAL_ID} ASC\").first\n+        if has_struct_metadata?\n+          child_class.find(first_id_from_struct_map)\n+        else\n+          solr_field = child_class.reflect_on_association(:parent).solr_key\n+          child_class.where(solr_field => id).order(\"#{Ddr::Index::Fields::LOCAL_ID} ASC\").first\n+        end\n+      end\n+\n+      private\n+\n+      def first_id_from_struct_map","path":"lib/ddr/models/has_children.rb","position":16,"original_position":16,"commit_id":"0bb344276e0b9a693579ea560d7ae43e0415591e","original_commit_id":"0bb344276e0b9a693579ea560d7ae43e0415591e","user":{"login":"dchandekstark","id":137925,"avatar_url":"https://avatars.githubusercontent.com/u/137925?v=3","gravatar_id":"","url":"https://api.github.com/users/dchandekstark","html_url":"https://github.com/dchandekstark","followers_url":"https://api.github.com/users/dchandekstark/followers","following_url":"https://api.github.com/users/dchandekstark/following{/other_user}","gists_url":"https://api.github.com/users/dchandekstark/gists{/gist_id}","starred_url":"https://api.github.com/users/dchandekstark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dchandekstark/subscriptions","organizations_url":"https://api.github.com/users/dchandekstark/orgs","repos_url":"https://api.github.com/users/dchandekstark/repos","events_url":"https://api.github.com/users/dchandekstark/events{/privacy}","received_events_url":"https://api.github.com/users/dchandekstark/received_events","type":"User","site_admin":false},"body":"I have a mild feeling that this (or part of this) method belongs in the `Structure` class.","created_at":"2015-12-01T17:59:15Z","updated_at":"2015-12-01T17:59:15Z","html_url":"https://github.com/duke-libraries/ddr-models/pull/480#discussion_r46313302","pull_request_url":"https://api.github.com/repos/duke-libraries/ddr-models/pulls/480","_links":{"self":{"href":"https://api.github.com/repos/duke-libraries/ddr-models/pulls/comments/46313302"},"html":{"href":"https://github.com/duke-libraries/ddr-models/pull/480#discussion_r46313302"},"pull_request":{"href":"https://api.github.com/repos/duke-libraries/ddr-models/pulls/480"}}},"pull_request":{"url":"https://api.github.com/repos/duke-libraries/ddr-models/pulls/480","id":52278767,"html_url":"https://github.com/duke-libraries/ddr-models/pull/480","diff_url":"https://github.com/duke-libraries/ddr-models/pull/480.diff","patch_url":"https://github.com/duke-libraries/ddr-models/pull/480.patch","issue_url":"https://api.github.com/repos/duke-libraries/ddr-models/issues/480","number":480,"state":"open","locked":false,"title":"154 first child use struct metadata","user":{"login":"coblej","id":2104923,"avatar_url":"https://avatars.githubusercontent.com/u/2104923?v=3","gravatar_id":"","url":"https://api.github.com/users/coblej","html_url":"https://github.com/coblej","followers_url":"https://api.github.com/users/coblej/followers","following_url":"https://api.github.com/users/coblej/following{/other_user}","gists_url":"https://api.github.com/users/coblej/gists{/gist_id}","starred_url":"https://api.github.com/users/coblej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coblej/subscriptions","organizations_url":"https://api.github.com/users/coblej/orgs","repos_url":"https://api.github.com/users/coblej/repos","events_url":"https://api.github.com/users/coblej/events{/privacy}","received_events_url":"https://api.github.com/users/coblej/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-01T16:16:46Z","updated_at":"2015-12-01T17:59:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8875e89f04f395773efa4975378001dfc5ad976a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/duke-libraries/ddr-models/pulls/480/commits","review_comments_url":"https://api.github.com/repos/duke-libraries/ddr-models/pulls/480/comments","review_comment_url":"https://api.github.com/repos/duke-libraries/ddr-models/pulls/comments{/number}","comments_url":"https://api.github.com/repos/duke-libraries/ddr-models/issues/480/comments","statuses_url":"https://api.github.com/repos/duke-libraries/ddr-models/statuses/0bb344276e0b9a693579ea560d7ae43e0415591e","head":{"label":"duke-libraries:154-first-child-use-struct-metadata","ref":"154-first-child-use-struct-metadata","sha":"0bb344276e0b9a693579ea560d7ae43e0415591e","user":{"login":"duke-libraries","id":2531406,"avatar_url":"https://avatars.githubusercontent.com/u/2531406?v=3","gravatar_id":"","url":"https://api.github.com/users/duke-libraries","html_url":"https://github.com/duke-libraries","followers_url":"https://api.github.com/users/duke-libraries/followers","following_url":"https://api.github.com/users/duke-libraries/following{/other_user}","gists_url":"https://api.github.com/users/duke-libraries/gists{/gist_id}","starred_url":"https://api.github.com/users/duke-libraries/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duke-libraries/subscriptions","organizations_url":"https://api.github.com/users/duke-libraries/orgs","repos_url":"https://api.github.com/users/duke-libraries/repos","events_url":"https://api.github.com/users/duke-libraries/events{/privacy}","received_events_url":"https://api.github.com/users/duke-libraries/received_events","type":"Organization","site_admin":false},"repo":{"id":24959925,"name":"ddr-models","full_name":"duke-libraries/ddr-models","owner":{"login":"duke-libraries","id":2531406,"avatar_url":"https://avatars.githubusercontent.com/u/2531406?v=3","gravatar_id":"","url":"https://api.github.com/users/duke-libraries","html_url":"https://github.com/duke-libraries","followers_url":"https://api.github.com/users/duke-libraries/followers","following_url":"https://api.github.com/users/duke-libraries/following{/other_user}","gists_url":"https://api.github.com/users/duke-libraries/gists{/gist_id}","starred_url":"https://api.github.com/users/duke-libraries/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duke-libraries/subscriptions","organizations_url":"https://api.github.com/users/duke-libraries/orgs","repos_url":"https://api.github.com/users/duke-libraries/repos","events_url":"https://api.github.com/users/duke-libraries/events{/privacy}","received_events_url":"https://api.github.com/users/duke-libraries/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/duke-libraries/ddr-models","description":"A Rails engine providing Hydra and ActiveRecord models and common services for the Duke Digital Repository.","fork":false,"url":"https://api.github.com/repos/duke-libraries/ddr-models","forks_url":"https://api.github.com/repos/duke-libraries/ddr-models/forks","keys_url":"https://api.github.com/repos/duke-libraries/ddr-models/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duke-libraries/ddr-models/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duke-libraries/ddr-models/teams","hooks_url":"https://api.github.com/repos/duke-libraries/ddr-models/hooks","issue_events_url":"https://api.github.com/repos/duke-libraries/ddr-models/issues/events{/number}","events_url":"https://api.github.com/repos/duke-libraries/ddr-models/events","assignees_url":"https://api.github.com/repos/duke-libraries/ddr-models/assignees{/user}","branches_url":"https://api.github.com/repos/duke-libraries/ddr-models/branches{/branch}","tags_url":"https://api.github.com/repos/duke-libraries/ddr-models/tags","blobs_url":"https://api.github.com/repos/duke-libraries/ddr-models/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duke-libraries/ddr-models/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duke-libraries/ddr-models/git/refs{/sha}","trees_url":"https://api.github.com/repos/duke-libraries/ddr-models/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duke-libraries/ddr-models/statuses/{sha}","languages_url":"https://api.github.com/repos/duke-libraries/ddr-models/languages","stargazers_url":"https://api.github.com/repos/duke-libraries/ddr-models/stargazers","contributors_url":"https://api.github.com/repos/duke-libraries/ddr-models/contributors","subscribers_url":"https://api.github.com/repos/duke-libraries/ddr-models/subscribers","subscription_url":"https://api.github.com/repos/duke-libraries/ddr-models/subscription","commits_url":"https://api.github.com/repos/duke-libraries/ddr-models/commits{/sha}","git_commits_url":"https://api.github.com/repos/duke-libraries/ddr-models/git/commits{/sha}","comments_url":"https://api.github.com/repos/duke-libraries/ddr-models/comments{/number}","issue_comment_url":"https://api.github.com/repos/duke-libraries/ddr-models/issues/comments{/number}","contents_url":"https://api.github.com/repos/duke-libraries/ddr-models/contents/{+path}","compare_url":"https://api.github.com/repos/duke-libraries/ddr-models/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duke-libraries/ddr-models/merges","archive_url":"https://api.github.com/repos/duke-libraries/ddr-models/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duke-libraries/ddr-models/downloads","issues_url":"https://api.github.com/repos/duke-libraries/ddr-models/issues{/number}","pulls_url":"https://api.github.com/repos/duke-libraries/ddr-models/pulls{/number}","milestones_url":"https://api.github.com/repos/duke-libraries/ddr-models/milestones{/number}","notifications_url":"https://api.github.com/repos/duke-libraries/ddr-models/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duke-libraries/ddr-models/labels{/name}","releases_url":"https://api.github.com/repos/duke-libraries/ddr-models/releases{/id}","created_at":"2014-10-08T20:40:35Z","updated_at":"2015-10-20T14:02:02Z","pushed_at":"2015-12-01T16:47:15Z","git_url":"git://github.com/duke-libraries/ddr-models.git","ssh_url":"git@github.com:duke-libraries/ddr-models.git","clone_url":"https://github.com/duke-libraries/ddr-models.git","svn_url":"https://github.com/duke-libraries/ddr-models","homepage":"","size":23003,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":52,"forks":1,"open_issues":52,"watchers":1,"default_branch":"develop"}},"base":{"label":"duke-libraries:fcrepo4","ref":"fcrepo4","sha":"70bc80b1036cffb2107219e37846cdd46a025f6e","user":{"login":"duke-libraries","id":2531406,"avatar_url":"https://avatars.githubusercontent.com/u/2531406?v=3","gravatar_id":"","url":"https://api.github.com/users/duke-libraries","html_url":"https://github.com/duke-libraries","followers_url":"https://api.github.com/users/duke-libraries/followers","following_url":"https://api.github.com/users/duke-libraries/following{/other_user}","gists_url":"https://api.github.com/users/duke-libraries/gists{/gist_id}","starred_url":"https://api.github.com/users/duke-libraries/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duke-libraries/subscriptions","organizations_url":"https://api.github.com/users/duke-libraries/orgs","repos_url":"https://api.github.com/users/duke-libraries/repos","events_url":"https://api.github.com/users/duke-libraries/events{/privacy}","received_events_url":"https://api.github.com/users/duke-libraries/received_events","type":"Organization","site_admin":false},"repo":{"id":24959925,"name":"ddr-models","full_name":"duke-libraries/ddr-models","owner":{"login":"duke-libraries","id":2531406,"avatar_url":"https://avatars.githubusercontent.com/u/2531406?v=3","gravatar_id":"","url":"https://api.github.com/users/duke-libraries","html_url":"https://github.com/duke-libraries","followers_url":"https://api.github.com/users/duke-libraries/followers","following_url":"https://api.github.com/users/duke-libraries/following{/other_user}","gists_url":"https://api.github.com/users/duke-libraries/gists{/gist_id}","starred_url":"https://api.github.com/users/duke-libraries/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duke-libraries/subscriptions","organizations_url":"https://api.github.com/users/duke-libraries/orgs","repos_url":"https://api.github.com/users/duke-libraries/repos","events_url":"https://api.github.com/users/duke-libraries/events{/privacy}","received_events_url":"https://api.github.com/users/duke-libraries/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/duke-libraries/ddr-models","description":"A Rails engine providing Hydra and ActiveRecord models and common services for the Duke Digital Repository.","fork":false,"url":"https://api.github.com/repos/duke-libraries/ddr-models","forks_url":"https://api.github.com/repos/duke-libraries/ddr-models/forks","keys_url":"https://api.github.com/repos/duke-libraries/ddr-models/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duke-libraries/ddr-models/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duke-libraries/ddr-models/teams","hooks_url":"https://api.github.com/repos/duke-libraries/ddr-models/hooks","issue_events_url":"https://api.github.com/repos/duke-libraries/ddr-models/issues/events{/number}","events_url":"https://api.github.com/repos/duke-libraries/ddr-models/events","assignees_url":"https://api.github.com/repos/duke-libraries/ddr-models/assignees{/user}","branches_url":"https://api.github.com/repos/duke-libraries/ddr-models/branches{/branch}","tags_url":"https://api.github.com/repos/duke-libraries/ddr-models/tags","blobs_url":"https://api.github.com/repos/duke-libraries/ddr-models/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duke-libraries/ddr-models/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duke-libraries/ddr-models/git/refs{/sha}","trees_url":"https://api.github.com/repos/duke-libraries/ddr-models/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duke-libraries/ddr-models/statuses/{sha}","languages_url":"https://api.github.com/repos/duke-libraries/ddr-models/languages","stargazers_url":"https://api.github.com/repos/duke-libraries/ddr-models/stargazers","contributors_url":"https://api.github.com/repos/duke-libraries/ddr-models/contributors","subscribers_url":"https://api.github.com/repos/duke-libraries/ddr-models/subscribers","subscription_url":"https://api.github.com/repos/duke-libraries/ddr-models/subscription","commits_url":"https://api.github.com/repos/duke-libraries/ddr-models/commits{/sha}","git_commits_url":"https://api.github.com/repos/duke-libraries/ddr-models/git/commits{/sha}","comments_url":"https://api.github.com/repos/duke-libraries/ddr-models/comments{/number}","issue_comment_url":"https://api.github.com/repos/duke-libraries/ddr-models/issues/comments{/number}","contents_url":"https://api.github.com/repos/duke-libraries/ddr-models/contents/{+path}","compare_url":"https://api.github.com/repos/duke-libraries/ddr-models/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duke-libraries/ddr-models/merges","archive_url":"https://api.github.com/repos/duke-libraries/ddr-models/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duke-libraries/ddr-models/downloads","issues_url":"https://api.github.com/repos/duke-libraries/ddr-models/issues{/number}","pulls_url":"https://api.github.com/repos/duke-libraries/ddr-models/pulls{/number}","milestones_url":"https://api.github.com/repos/duke-libraries/ddr-models/milestones{/number}","notifications_url":"https://api.github.com/repos/duke-libraries/ddr-models/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duke-libraries/ddr-models/labels{/name}","releases_url":"https://api.github.com/repos/duke-libraries/ddr-models/releases{/id}","created_at":"2014-10-08T20:40:35Z","updated_at":"2015-10-20T14:02:02Z","pushed_at":"2015-12-01T16:47:15Z","git_url":"git://github.com/duke-libraries/ddr-models.git","ssh_url":"git@github.com:duke-libraries/ddr-models.git","clone_url":"https://github.com/duke-libraries/ddr-models.git","svn_url":"https://github.com/duke-libraries/ddr-models","homepage":"","size":23003,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":52,"forks":1,"open_issues":52,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/duke-libraries/ddr-models/pulls/480"},"html":{"href":"https://github.com/duke-libraries/ddr-models/pull/480"},"issue":{"href":"https://api.github.com/repos/duke-libraries/ddr-models/issues/480"},"comments":{"href":"https://api.github.com/repos/duke-libraries/ddr-models/issues/480/comments"},"review_comments":{"href":"https://api.github.com/repos/duke-libraries/ddr-models/pulls/480/comments"},"review_comment":{"href":"https://api.github.com/repos/duke-libraries/ddr-models/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/duke-libraries/ddr-models/pulls/480/commits"},"statuses":{"href":"https://api.github.com/repos/duke-libraries/ddr-models/statuses/0bb344276e0b9a693579ea560d7ae43e0415591e"}}}}