{"action":"created","comment":{"url":"https://api.github.com/repos/scrapinghub/portia/pulls/comments/72134562","id":72134562,"diff_hunk":"@@ -879,6 +879,71 @@ export function makeItemsFromGroups(groups) {\n     return items;\n }\n \n+function createSelectorGenerators(structure, selectorMatcher, accumulator) {\n+    const generators = [];\n+\n+    for (let element of structure) {\n+        const {annotation, children} = element;\n+        let selectorGenerator;\n+        if (children) {\n+            selectorGenerator = ContainerSelectorGenerator.create({});\n+            selectorGenerator.addChildren(\n+                createSelectorGenerators(children, selectorMatcher, accumulator));\n+\n+        } else {\n+            selectorGenerator = AnnotationSelectorGenerator.create({\n+                selectorMatcher,\n+                annotation\n+            });\n+        }\n+        generators.push(selectorGenerator);\n+        accumulator.push([annotation, selectorGenerator]);\n+    }\n+\n+    return generators;\n+}\n+\n+export function updateStructureSelectors(structure, selectorMatcher) {\n+    const accumulator = [];\n+    createSelectorGenerators(structure, selectorMatcher, accumulator);\n+    for (let [annotation, selectorGenerator] of accumulator) {\n+        const selector = selectorGenerator.get('selector');\n+        if (selectorGenerator instanceof AnnotationSelectorGenerator) {","path":"portiaui/app/utils/selectors.js","position":127,"original_position":127,"commit_id":"dae7a7ddeec06a5a0859898ea5878c3829aedfb5","original_commit_id":"dae7a7ddeec06a5a0859898ea5878c3829aedfb5","user":{"login":"sagelliv","id":19316048,"avatar_url":"https://avatars.githubusercontent.com/u/19316048?v=3","gravatar_id":"","url":"https://api.github.com/users/sagelliv","html_url":"https://github.com/sagelliv","followers_url":"https://api.github.com/users/sagelliv/followers","following_url":"https://api.github.com/users/sagelliv/following{/other_user}","gists_url":"https://api.github.com/users/sagelliv/gists{/gist_id}","starred_url":"https://api.github.com/users/sagelliv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sagelliv/subscriptions","organizations_url":"https://api.github.com/users/sagelliv/orgs","repos_url":"https://api.github.com/users/sagelliv/repos","events_url":"https://api.github.com/users/sagelliv/events{/privacy}","received_events_url":"https://api.github.com/users/sagelliv/received_events","type":"User","site_admin":false},"body":"Can you replace these conditionals with polymorphism? Have the generator classes respond to a method which takes care of updating the structure given the annotation. In case the selector generator is not a `AnnotationSelectorGenerator` or `ContainerSelectorGenerator`, just do `this.destroy()`.","created_at":"2016-07-25T20:07:12Z","updated_at":"2016-07-25T20:07:12Z","html_url":"https://github.com/scrapinghub/portia/pull/540#discussion_r72134562","pull_request_url":"https://api.github.com/repos/scrapinghub/portia/pulls/540","_links":{"self":{"href":"https://api.github.com/repos/scrapinghub/portia/pulls/comments/72134562"},"html":{"href":"https://github.com/scrapinghub/portia/pull/540#discussion_r72134562"},"pull_request":{"href":"https://api.github.com/repos/scrapinghub/portia/pulls/540"}}},"pull_request":{"url":"https://api.github.com/repos/scrapinghub/portia/pulls/540","id":78655944,"html_url":"https://github.com/scrapinghub/portia/pull/540","diff_url":"https://github.com/scrapinghub/portia/pull/540.diff","patch_url":"https://github.com/scrapinghub/portia/pull/540.patch","issue_url":"https://api.github.com/repos/scrapinghub/portia/issues/540","number":540,"state":"open","locked":false,"title":"PORTIA-472: Explicit selector recomputation on user input","user":{"login":"michalmo","id":9825131,"avatar_url":"https://avatars.githubusercontent.com/u/9825131?v=3","gravatar_id":"","url":"https://api.github.com/users/michalmo","html_url":"https://github.com/michalmo","followers_url":"https://api.github.com/users/michalmo/followers","following_url":"https://api.github.com/users/michalmo/following{/other_user}","gists_url":"https://api.github.com/users/michalmo/gists{/gist_id}","starred_url":"https://api.github.com/users/michalmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michalmo/subscriptions","organizations_url":"https://api.github.com/users/michalmo/orgs","repos_url":"https://api.github.com/users/michalmo/repos","events_url":"https://api.github.com/users/michalmo/events{/privacy}","received_events_url":"https://api.github.com/users/michalmo/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-25T10:07:02Z","updated_at":"2016-07-25T20:07:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a223dab268b569919b1a7a7558330c8bbdaf4757","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/scrapinghub/portia/pulls/540/commits","review_comments_url":"https://api.github.com/repos/scrapinghub/portia/pulls/540/comments","review_comment_url":"https://api.github.com/repos/scrapinghub/portia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scrapinghub/portia/issues/540/comments","statuses_url":"https://api.github.com/repos/scrapinghub/portia/statuses/dae7a7ddeec06a5a0859898ea5878c3829aedfb5","head":{"label":"scrapinghub:explicit-selector-recomputation","ref":"explicit-selector-recomputation","sha":"dae7a7ddeec06a5a0859898ea5878c3829aedfb5","user":{"login":"scrapinghub","id":699596,"avatar_url":"https://avatars.githubusercontent.com/u/699596?v=3","gravatar_id":"","url":"https://api.github.com/users/scrapinghub","html_url":"https://github.com/scrapinghub","followers_url":"https://api.github.com/users/scrapinghub/followers","following_url":"https://api.github.com/users/scrapinghub/following{/other_user}","gists_url":"https://api.github.com/users/scrapinghub/gists{/gist_id}","starred_url":"https://api.github.com/users/scrapinghub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scrapinghub/subscriptions","organizations_url":"https://api.github.com/users/scrapinghub/orgs","repos_url":"https://api.github.com/users/scrapinghub/repos","events_url":"https://api.github.com/users/scrapinghub/events{/privacy}","received_events_url":"https://api.github.com/users/scrapinghub/received_events","type":"Organization","site_admin":false},"repo":{"id":17982061,"name":"portia","full_name":"scrapinghub/portia","owner":{"login":"scrapinghub","id":699596,"avatar_url":"https://avatars.githubusercontent.com/u/699596?v=3","gravatar_id":"","url":"https://api.github.com/users/scrapinghub","html_url":"https://github.com/scrapinghub","followers_url":"https://api.github.com/users/scrapinghub/followers","following_url":"https://api.github.com/users/scrapinghub/following{/other_user}","gists_url":"https://api.github.com/users/scrapinghub/gists{/gist_id}","starred_url":"https://api.github.com/users/scrapinghub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scrapinghub/subscriptions","organizations_url":"https://api.github.com/users/scrapinghub/orgs","repos_url":"https://api.github.com/users/scrapinghub/repos","events_url":"https://api.github.com/users/scrapinghub/events{/privacy}","received_events_url":"https://api.github.com/users/scrapinghub/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scrapinghub/portia","description":"Visual scraping for Scrapy","fork":false,"url":"https://api.github.com/repos/scrapinghub/portia","forks_url":"https://api.github.com/repos/scrapinghub/portia/forks","keys_url":"https://api.github.com/repos/scrapinghub/portia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scrapinghub/portia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scrapinghub/portia/teams","hooks_url":"https://api.github.com/repos/scrapinghub/portia/hooks","issue_events_url":"https://api.github.com/repos/scrapinghub/portia/issues/events{/number}","events_url":"https://api.github.com/repos/scrapinghub/portia/events","assignees_url":"https://api.github.com/repos/scrapinghub/portia/assignees{/user}","branches_url":"https://api.github.com/repos/scrapinghub/portia/branches{/branch}","tags_url":"https://api.github.com/repos/scrapinghub/portia/tags","blobs_url":"https://api.github.com/repos/scrapinghub/portia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scrapinghub/portia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scrapinghub/portia/git/refs{/sha}","trees_url":"https://api.github.com/repos/scrapinghub/portia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scrapinghub/portia/statuses/{sha}","languages_url":"https://api.github.com/repos/scrapinghub/portia/languages","stargazers_url":"https://api.github.com/repos/scrapinghub/portia/stargazers","contributors_url":"https://api.github.com/repos/scrapinghub/portia/contributors","subscribers_url":"https://api.github.com/repos/scrapinghub/portia/subscribers","subscription_url":"https://api.github.com/repos/scrapinghub/portia/subscription","commits_url":"https://api.github.com/repos/scrapinghub/portia/commits{/sha}","git_commits_url":"https://api.github.com/repos/scrapinghub/portia/git/commits{/sha}","comments_url":"https://api.github.com/repos/scrapinghub/portia/comments{/number}","issue_comment_url":"https://api.github.com/repos/scrapinghub/portia/issues/comments{/number}","contents_url":"https://api.github.com/repos/scrapinghub/portia/contents/{+path}","compare_url":"https://api.github.com/repos/scrapinghub/portia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scrapinghub/portia/merges","archive_url":"https://api.github.com/repos/scrapinghub/portia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scrapinghub/portia/downloads","issues_url":"https://api.github.com/repos/scrapinghub/portia/issues{/number}","pulls_url":"https://api.github.com/repos/scrapinghub/portia/pulls{/number}","milestones_url":"https://api.github.com/repos/scrapinghub/portia/milestones{/number}","notifications_url":"https://api.github.com/repos/scrapinghub/portia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scrapinghub/portia/labels{/name}","releases_url":"https://api.github.com/repos/scrapinghub/portia/releases{/id}","deployments_url":"https://api.github.com/repos/scrapinghub/portia/deployments","created_at":"2014-03-21T14:24:31Z","updated_at":"2016-07-25T09:59:25Z","pushed_at":"2016-07-25T14:37:30Z","git_url":"git://github.com/scrapinghub/portia.git","ssh_url":"git@github.com:scrapinghub/portia.git","clone_url":"https://github.com/scrapinghub/portia.git","svn_url":"https://github.com/scrapinghub/portia","homepage":null,"size":26405,"stargazers_count":4405,"watchers_count":4405,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":642,"mirror_url":null,"open_issues_count":88,"forks":642,"open_issues":88,"watchers":4405,"default_branch":"master"}},"base":{"label":"scrapinghub:nui-develop","ref":"nui-develop","sha":"4e57a48bd9acd81ab74412cd08e7602498cc6c5b","user":{"login":"scrapinghub","id":699596,"avatar_url":"https://avatars.githubusercontent.com/u/699596?v=3","gravatar_id":"","url":"https://api.github.com/users/scrapinghub","html_url":"https://github.com/scrapinghub","followers_url":"https://api.github.com/users/scrapinghub/followers","following_url":"https://api.github.com/users/scrapinghub/following{/other_user}","gists_url":"https://api.github.com/users/scrapinghub/gists{/gist_id}","starred_url":"https://api.github.com/users/scrapinghub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scrapinghub/subscriptions","organizations_url":"https://api.github.com/users/scrapinghub/orgs","repos_url":"https://api.github.com/users/scrapinghub/repos","events_url":"https://api.github.com/users/scrapinghub/events{/privacy}","received_events_url":"https://api.github.com/users/scrapinghub/received_events","type":"Organization","site_admin":false},"repo":{"id":17982061,"name":"portia","full_name":"scrapinghub/portia","owner":{"login":"scrapinghub","id":699596,"avatar_url":"https://avatars.githubusercontent.com/u/699596?v=3","gravatar_id":"","url":"https://api.github.com/users/scrapinghub","html_url":"https://github.com/scrapinghub","followers_url":"https://api.github.com/users/scrapinghub/followers","following_url":"https://api.github.com/users/scrapinghub/following{/other_user}","gists_url":"https://api.github.com/users/scrapinghub/gists{/gist_id}","starred_url":"https://api.github.com/users/scrapinghub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scrapinghub/subscriptions","organizations_url":"https://api.github.com/users/scrapinghub/orgs","repos_url":"https://api.github.com/users/scrapinghub/repos","events_url":"https://api.github.com/users/scrapinghub/events{/privacy}","received_events_url":"https://api.github.com/users/scrapinghub/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scrapinghub/portia","description":"Visual scraping for Scrapy","fork":false,"url":"https://api.github.com/repos/scrapinghub/portia","forks_url":"https://api.github.com/repos/scrapinghub/portia/forks","keys_url":"https://api.github.com/repos/scrapinghub/portia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scrapinghub/portia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scrapinghub/portia/teams","hooks_url":"https://api.github.com/repos/scrapinghub/portia/hooks","issue_events_url":"https://api.github.com/repos/scrapinghub/portia/issues/events{/number}","events_url":"https://api.github.com/repos/scrapinghub/portia/events","assignees_url":"https://api.github.com/repos/scrapinghub/portia/assignees{/user}","branches_url":"https://api.github.com/repos/scrapinghub/portia/branches{/branch}","tags_url":"https://api.github.com/repos/scrapinghub/portia/tags","blobs_url":"https://api.github.com/repos/scrapinghub/portia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scrapinghub/portia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scrapinghub/portia/git/refs{/sha}","trees_url":"https://api.github.com/repos/scrapinghub/portia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scrapinghub/portia/statuses/{sha}","languages_url":"https://api.github.com/repos/scrapinghub/portia/languages","stargazers_url":"https://api.github.com/repos/scrapinghub/portia/stargazers","contributors_url":"https://api.github.com/repos/scrapinghub/portia/contributors","subscribers_url":"https://api.github.com/repos/scrapinghub/portia/subscribers","subscription_url":"https://api.github.com/repos/scrapinghub/portia/subscription","commits_url":"https://api.github.com/repos/scrapinghub/portia/commits{/sha}","git_commits_url":"https://api.github.com/repos/scrapinghub/portia/git/commits{/sha}","comments_url":"https://api.github.com/repos/scrapinghub/portia/comments{/number}","issue_comment_url":"https://api.github.com/repos/scrapinghub/portia/issues/comments{/number}","contents_url":"https://api.github.com/repos/scrapinghub/portia/contents/{+path}","compare_url":"https://api.github.com/repos/scrapinghub/portia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scrapinghub/portia/merges","archive_url":"https://api.github.com/repos/scrapinghub/portia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scrapinghub/portia/downloads","issues_url":"https://api.github.com/repos/scrapinghub/portia/issues{/number}","pulls_url":"https://api.github.com/repos/scrapinghub/portia/pulls{/number}","milestones_url":"https://api.github.com/repos/scrapinghub/portia/milestones{/number}","notifications_url":"https://api.github.com/repos/scrapinghub/portia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scrapinghub/portia/labels{/name}","releases_url":"https://api.github.com/repos/scrapinghub/portia/releases{/id}","deployments_url":"https://api.github.com/repos/scrapinghub/portia/deployments","created_at":"2014-03-21T14:24:31Z","updated_at":"2016-07-25T09:59:25Z","pushed_at":"2016-07-25T14:37:30Z","git_url":"git://github.com/scrapinghub/portia.git","ssh_url":"git@github.com:scrapinghub/portia.git","clone_url":"https://github.com/scrapinghub/portia.git","svn_url":"https://github.com/scrapinghub/portia","homepage":null,"size":26405,"stargazers_count":4405,"watchers_count":4405,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":642,"mirror_url":null,"open_issues_count":88,"forks":642,"open_issues":88,"watchers":4405,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scrapinghub/portia/pulls/540"},"html":{"href":"https://github.com/scrapinghub/portia/pull/540"},"issue":{"href":"https://api.github.com/repos/scrapinghub/portia/issues/540"},"comments":{"href":"https://api.github.com/repos/scrapinghub/portia/issues/540/comments"},"review_comments":{"href":"https://api.github.com/repos/scrapinghub/portia/pulls/540/comments"},"review_comment":{"href":"https://api.github.com/repos/scrapinghub/portia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scrapinghub/portia/pulls/540/commits"},"statuses":{"href":"https://api.github.com/repos/scrapinghub/portia/statuses/dae7a7ddeec06a5a0859898ea5878c3829aedfb5"}}}}
{"actor":{"display_login":"sagelliv"}}