{"action":"created","comment":{"url":"https://api.github.com/repos/hoppinger/wp-connector/pulls/comments/25936342","id":25936342,"diff_hunk":"@@ -48,14 +48,21 @@ def create_or_update(wp_type, wp_id, preview = false)\n     # the `update_wp_cache` instance method.\n     # Removes records with unknown IDs.\n     #\n+    # TODO (dunyakirkali) clean up\n     def create_or_update_all\n-      wp_json = get_from_wp_api self.to_s.underscore.pluralize\n-      ids = wp_json.map do |json|\n-        wp_id = json['ID']\n-        where(wp_id: wp_id).first_or_create.update_wp_cache(json)\n-        wp_id\n+      page = 0\n+      while paginated_models.include?(wp_type) do\n+        puts \" page #{page}\"\n+        wp_json = get_from_wp_api(wp_type, page)\n+        break if wp_json.empty?\n+        ids = wp_json.map do |json|\n+          wp_id = json['ID']\n+          where(wp_id: wp_id).first_or_initialize.update_wp_cache(json)\n+          wp_id\n+        end\n+        where('wp_id NOT IN (?)', ids).destroy_all unless ids.empty?","path":"app/models/concerns/wp_cache.rb","position":30,"original_position":30,"commit_id":"7244099a9b48593d0df92cb7172c178762a62f24","original_commit_id":"7244099a9b48593d0df92cb7172c178762a62f24","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.","created_at":"2015-03-06T10:24:30Z","updated_at":"2015-03-06T10:24:30Z","html_url":"https://github.com/hoppinger/wp-connector/pull/23#discussion_r25936342","pull_request_url":"https://api.github.com/repos/hoppinger/wp-connector/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/hoppinger/wp-connector/pulls/comments/25936342"},"html":{"href":"https://github.com/hoppinger/wp-connector/pull/23#discussion_r25936342"},"pull_request":{"href":"https://api.github.com/repos/hoppinger/wp-connector/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/hoppinger/wp-connector/pulls/23","id":29530916,"html_url":"https://github.com/hoppinger/wp-connector/pull/23","diff_url":"https://github.com/hoppinger/wp-connector/pull/23.diff","patch_url":"https://github.com/hoppinger/wp-connector/pull/23.patch","issue_url":"https://api.github.com/repos/hoppinger/wp-connector/issues/23","number":23,"state":"open","locked":false,"title":"Feature/wp term","user":{"login":"dunyakirkali","id":698335,"avatar_url":"https://avatars.githubusercontent.com/u/698335?v=3","gravatar_id":"","url":"https://api.github.com/users/dunyakirkali","html_url":"https://github.com/dunyakirkali","followers_url":"https://api.github.com/users/dunyakirkali/followers","following_url":"https://api.github.com/users/dunyakirkali/following{/other_user}","gists_url":"https://api.github.com/users/dunyakirkali/gists{/gist_id}","starred_url":"https://api.github.com/users/dunyakirkali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dunyakirkali/subscriptions","organizations_url":"https://api.github.com/users/dunyakirkali/orgs","repos_url":"https://api.github.com/users/dunyakirkali/repos","events_url":"https://api.github.com/users/dunyakirkali/events{/privacy}","received_events_url":"https://api.github.com/users/dunyakirkali/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-18T14:52:29Z","updated_at":"2015-03-06T10:24:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e84078a7be6b253a1d68e4f3dc2d85972c0b0a55","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hoppinger/wp-connector/pulls/23/commits","review_comments_url":"https://api.github.com/repos/hoppinger/wp-connector/pulls/23/comments","review_comment_url":"https://api.github.com/repos/hoppinger/wp-connector/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hoppinger/wp-connector/issues/23/comments","statuses_url":"https://api.github.com/repos/hoppinger/wp-connector/statuses/7244099a9b48593d0df92cb7172c178762a62f24","head":{"label":"hoppinger:feature/wp_term","ref":"feature/wp_term","sha":"7244099a9b48593d0df92cb7172c178762a62f24","user":{"login":"hoppinger","id":686396,"avatar_url":"https://avatars.githubusercontent.com/u/686396?v=3","gravatar_id":"","url":"https://api.github.com/users/hoppinger","html_url":"https://github.com/hoppinger","followers_url":"https://api.github.com/users/hoppinger/followers","following_url":"https://api.github.com/users/hoppinger/following{/other_user}","gists_url":"https://api.github.com/users/hoppinger/gists{/gist_id}","starred_url":"https://api.github.com/users/hoppinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoppinger/subscriptions","organizations_url":"https://api.github.com/users/hoppinger/orgs","repos_url":"https://api.github.com/users/hoppinger/repos","events_url":"https://api.github.com/users/hoppinger/events{/privacy}","received_events_url":"https://api.github.com/users/hoppinger/received_events","type":"Organization","site_admin":false},"repo":{"id":26423010,"name":"wp-connector","full_name":"hoppinger/wp-connector","owner":{"login":"hoppinger","id":686396,"avatar_url":"https://avatars.githubusercontent.com/u/686396?v=3","gravatar_id":"","url":"https://api.github.com/users/hoppinger","html_url":"https://github.com/hoppinger","followers_url":"https://api.github.com/users/hoppinger/followers","following_url":"https://api.github.com/users/hoppinger/following{/other_user}","gists_url":"https://api.github.com/users/hoppinger/gists{/gist_id}","starred_url":"https://api.github.com/users/hoppinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoppinger/subscriptions","organizations_url":"https://api.github.com/users/hoppinger/orgs","repos_url":"https://api.github.com/users/hoppinger/repos","events_url":"https://api.github.com/users/hoppinger/events{/privacy}","received_events_url":"https://api.github.com/users/hoppinger/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hoppinger/wp-connector","description":"Use Rails on top of WP: Manage content from WP; customize, extend, optimize and serve the visitors from Rails.","fork":false,"url":"https://api.github.com/repos/hoppinger/wp-connector","forks_url":"https://api.github.com/repos/hoppinger/wp-connector/forks","keys_url":"https://api.github.com/repos/hoppinger/wp-connector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hoppinger/wp-connector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hoppinger/wp-connector/teams","hooks_url":"https://api.github.com/repos/hoppinger/wp-connector/hooks","issue_events_url":"https://api.github.com/repos/hoppinger/wp-connector/issues/events{/number}","events_url":"https://api.github.com/repos/hoppinger/wp-connector/events","assignees_url":"https://api.github.com/repos/hoppinger/wp-connector/assignees{/user}","branches_url":"https://api.github.com/repos/hoppinger/wp-connector/branches{/branch}","tags_url":"https://api.github.com/repos/hoppinger/wp-connector/tags","blobs_url":"https://api.github.com/repos/hoppinger/wp-connector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hoppinger/wp-connector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hoppinger/wp-connector/git/refs{/sha}","trees_url":"https://api.github.com/repos/hoppinger/wp-connector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hoppinger/wp-connector/statuses/{sha}","languages_url":"https://api.github.com/repos/hoppinger/wp-connector/languages","stargazers_url":"https://api.github.com/repos/hoppinger/wp-connector/stargazers","contributors_url":"https://api.github.com/repos/hoppinger/wp-connector/contributors","subscribers_url":"https://api.github.com/repos/hoppinger/wp-connector/subscribers","subscription_url":"https://api.github.com/repos/hoppinger/wp-connector/subscription","commits_url":"https://api.github.com/repos/hoppinger/wp-connector/commits{/sha}","git_commits_url":"https://api.github.com/repos/hoppinger/wp-connector/git/commits{/sha}","comments_url":"https://api.github.com/repos/hoppinger/wp-connector/comments{/number}","issue_comment_url":"https://api.github.com/repos/hoppinger/wp-connector/issues/comments{/number}","contents_url":"https://api.github.com/repos/hoppinger/wp-connector/contents/{+path}","compare_url":"https://api.github.com/repos/hoppinger/wp-connector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hoppinger/wp-connector/merges","archive_url":"https://api.github.com/repos/hoppinger/wp-connector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hoppinger/wp-connector/downloads","issues_url":"https://api.github.com/repos/hoppinger/wp-connector/issues{/number}","pulls_url":"https://api.github.com/repos/hoppinger/wp-connector/pulls{/number}","milestones_url":"https://api.github.com/repos/hoppinger/wp-connector/milestones{/number}","notifications_url":"https://api.github.com/repos/hoppinger/wp-connector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hoppinger/wp-connector/labels{/name}","releases_url":"https://api.github.com/repos/hoppinger/wp-connector/releases{/id}","created_at":"2014-11-10T05:54:37Z","updated_at":"2015-03-04T13:37:53Z","pushed_at":"2015-03-06T10:24:25Z","git_url":"git://github.com/hoppinger/wp-connector.git","ssh_url":"git@github.com:hoppinger/wp-connector.git","clone_url":"https://github.com/hoppinger/wp-connector.git","svn_url":"https://github.com/hoppinger/wp-connector","homepage":"","size":768,"stargazers_count":9,"watchers_count":9,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":7,"forks":0,"open_issues":7,"watchers":9,"default_branch":"master"}},"base":{"label":"hoppinger:master","ref":"master","sha":"2b71aa1783d0ca2e19bfd7283b652e043ed84a56","user":{"login":"hoppinger","id":686396,"avatar_url":"https://avatars.githubusercontent.com/u/686396?v=3","gravatar_id":"","url":"https://api.github.com/users/hoppinger","html_url":"https://github.com/hoppinger","followers_url":"https://api.github.com/users/hoppinger/followers","following_url":"https://api.github.com/users/hoppinger/following{/other_user}","gists_url":"https://api.github.com/users/hoppinger/gists{/gist_id}","starred_url":"https://api.github.com/users/hoppinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoppinger/subscriptions","organizations_url":"https://api.github.com/users/hoppinger/orgs","repos_url":"https://api.github.com/users/hoppinger/repos","events_url":"https://api.github.com/users/hoppinger/events{/privacy}","received_events_url":"https://api.github.com/users/hoppinger/received_events","type":"Organization","site_admin":false},"repo":{"id":26423010,"name":"wp-connector","full_name":"hoppinger/wp-connector","owner":{"login":"hoppinger","id":686396,"avatar_url":"https://avatars.githubusercontent.com/u/686396?v=3","gravatar_id":"","url":"https://api.github.com/users/hoppinger","html_url":"https://github.com/hoppinger","followers_url":"https://api.github.com/users/hoppinger/followers","following_url":"https://api.github.com/users/hoppinger/following{/other_user}","gists_url":"https://api.github.com/users/hoppinger/gists{/gist_id}","starred_url":"https://api.github.com/users/hoppinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoppinger/subscriptions","organizations_url":"https://api.github.com/users/hoppinger/orgs","repos_url":"https://api.github.com/users/hoppinger/repos","events_url":"https://api.github.com/users/hoppinger/events{/privacy}","received_events_url":"https://api.github.com/users/hoppinger/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hoppinger/wp-connector","description":"Use Rails on top of WP: Manage content from WP; customize, extend, optimize and serve the visitors from Rails.","fork":false,"url":"https://api.github.com/repos/hoppinger/wp-connector","forks_url":"https://api.github.com/repos/hoppinger/wp-connector/forks","keys_url":"https://api.github.com/repos/hoppinger/wp-connector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hoppinger/wp-connector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hoppinger/wp-connector/teams","hooks_url":"https://api.github.com/repos/hoppinger/wp-connector/hooks","issue_events_url":"https://api.github.com/repos/hoppinger/wp-connector/issues/events{/number}","events_url":"https://api.github.com/repos/hoppinger/wp-connector/events","assignees_url":"https://api.github.com/repos/hoppinger/wp-connector/assignees{/user}","branches_url":"https://api.github.com/repos/hoppinger/wp-connector/branches{/branch}","tags_url":"https://api.github.com/repos/hoppinger/wp-connector/tags","blobs_url":"https://api.github.com/repos/hoppinger/wp-connector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hoppinger/wp-connector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hoppinger/wp-connector/git/refs{/sha}","trees_url":"https://api.github.com/repos/hoppinger/wp-connector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hoppinger/wp-connector/statuses/{sha}","languages_url":"https://api.github.com/repos/hoppinger/wp-connector/languages","stargazers_url":"https://api.github.com/repos/hoppinger/wp-connector/stargazers","contributors_url":"https://api.github.com/repos/hoppinger/wp-connector/contributors","subscribers_url":"https://api.github.com/repos/hoppinger/wp-connector/subscribers","subscription_url":"https://api.github.com/repos/hoppinger/wp-connector/subscription","commits_url":"https://api.github.com/repos/hoppinger/wp-connector/commits{/sha}","git_commits_url":"https://api.github.com/repos/hoppinger/wp-connector/git/commits{/sha}","comments_url":"https://api.github.com/repos/hoppinger/wp-connector/comments{/number}","issue_comment_url":"https://api.github.com/repos/hoppinger/wp-connector/issues/comments{/number}","contents_url":"https://api.github.com/repos/hoppinger/wp-connector/contents/{+path}","compare_url":"https://api.github.com/repos/hoppinger/wp-connector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hoppinger/wp-connector/merges","archive_url":"https://api.github.com/repos/hoppinger/wp-connector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hoppinger/wp-connector/downloads","issues_url":"https://api.github.com/repos/hoppinger/wp-connector/issues{/number}","pulls_url":"https://api.github.com/repos/hoppinger/wp-connector/pulls{/number}","milestones_url":"https://api.github.com/repos/hoppinger/wp-connector/milestones{/number}","notifications_url":"https://api.github.com/repos/hoppinger/wp-connector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hoppinger/wp-connector/labels{/name}","releases_url":"https://api.github.com/repos/hoppinger/wp-connector/releases{/id}","created_at":"2014-11-10T05:54:37Z","updated_at":"2015-03-04T13:37:53Z","pushed_at":"2015-03-06T10:24:25Z","git_url":"git://github.com/hoppinger/wp-connector.git","ssh_url":"git@github.com:hoppinger/wp-connector.git","clone_url":"https://github.com/hoppinger/wp-connector.git","svn_url":"https://github.com/hoppinger/wp-connector","homepage":"","size":768,"stargazers_count":9,"watchers_count":9,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":7,"forks":0,"open_issues":7,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hoppinger/wp-connector/pulls/23"},"html":{"href":"https://github.com/hoppinger/wp-connector/pull/23"},"issue":{"href":"https://api.github.com/repos/hoppinger/wp-connector/issues/23"},"comments":{"href":"https://api.github.com/repos/hoppinger/wp-connector/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/hoppinger/wp-connector/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/hoppinger/wp-connector/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hoppinger/wp-connector/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/hoppinger/wp-connector/statuses/7244099a9b48593d0df92cb7172c178762a62f24"}}}}