{"action":"created","comment":{"url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/comments/151544828","pull_request_review_id":77272290,"id":151544828,"diff_hunk":"@@ -4,9 +4,32 @@ class DeleteOldApplications\n     include Sidekiq::Worker\n \n     def perform\n-      records = EducationBenefitsClaim.where(\"processed_at < '#{2.months.ago}'\")\n-      logger.info(\"Deleting #{records.count} old 22-1990s\")\n-      records.delete_all\n+      edu_claim_ids = []\n+      saved_claim_ids = []\n+\n+      # Remove old education benefits claims and saved claims older than 2 months\n+      EducationBenefitsClaim.eager_load(:saved_claim)\n+                            .where(\"processed_at < '#{2.months.ago}'\")\n+                            .find_each do |record|\n+        edu_claim_ids << record.id\n+        saved_claim_ids << record&.saved_claim.id\n+      end\n+\n+      # Remove saved claims with no matching education benefits claim","path":"app/workers/education_form/delete_old_applications.rb","position":18,"original_position":18,"commit_id":"16ea6950affeb91864a1ef2c688414d525554661","original_commit_id":"16ea6950affeb91864a1ef2c688414d525554661","user":{"login":"lihanli","id":830084,"avatar_url":"https://avatars3.githubusercontent.com/u/830084?v=4","gravatar_id":"","url":"https://api.github.com/users/lihanli","html_url":"https://github.com/lihanli","followers_url":"https://api.github.com/users/lihanli/followers","following_url":"https://api.github.com/users/lihanli/following{/other_user}","gists_url":"https://api.github.com/users/lihanli/gists{/gist_id}","starred_url":"https://api.github.com/users/lihanli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lihanli/subscriptions","organizations_url":"https://api.github.com/users/lihanli/orgs","repos_url":"https://api.github.com/users/lihanli/repos","events_url":"https://api.github.com/users/lihanli/events{/privacy}","received_events_url":"https://api.github.com/users/lihanli/received_events","type":"User","site_admin":false},"body":"i think this should be moved to a rake task. once this job is deleting saved claims along with edu claims then we should be able to run the task once and never have any more orphaned saved claims","created_at":"2017-11-16T21:40:43Z","updated_at":"2017-11-16T21:40:43Z","html_url":"https://github.com/department-of-veterans-affairs/vets-api/pull/1526#discussion_r151544828","pull_request_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1526","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/comments/151544828"},"html":{"href":"https://github.com/department-of-veterans-affairs/vets-api/pull/1526#discussion_r151544828"},"pull_request":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1526"}}},"pull_request":{"url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1526","id":152141056,"html_url":"https://github.com/department-of-veterans-affairs/vets-api/pull/1526","diff_url":"https://github.com/department-of-veterans-affairs/vets-api/pull/1526.diff","patch_url":"https://github.com/department-of-veterans-affairs/vets-api/pull/1526.patch","issue_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/1526","number":1526,"state":"open","locked":false,"title":"Fix \"Delete Old Claims\" job","user":{"login":"rlbaker","id":967417,"avatar_url":"https://avatars0.githubusercontent.com/u/967417?v=4","gravatar_id":"","url":"https://api.github.com/users/rlbaker","html_url":"https://github.com/rlbaker","followers_url":"https://api.github.com/users/rlbaker/followers","following_url":"https://api.github.com/users/rlbaker/following{/other_user}","gists_url":"https://api.github.com/users/rlbaker/gists{/gist_id}","starred_url":"https://api.github.com/users/rlbaker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlbaker/subscriptions","organizations_url":"https://api.github.com/users/rlbaker/orgs","repos_url":"https://api.github.com/users/rlbaker/repos","events_url":"https://api.github.com/users/rlbaker/events{/privacy}","received_events_url":"https://api.github.com/users/rlbaker/received_events","type":"User","site_admin":false},"body":"Updates the \"Delete Old Claims\" job to remove old saved claims as well in addition to the education benefits claims. Also removes saved claims that do not have a matching education benefits claim.\r\n\r\nhttps://github.com/department-of-veterans-affairs/vets.gov-team/issues/5743","created_at":"2017-11-13T02:34:30Z","updated_at":"2017-11-16T21:40:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8d16263e3bc8805384b0a27c1e9cc4dca92e848c","assignee":null,"assignees":[],"requested_reviewers":[{"login":"jbalboni","id":634932,"avatar_url":"https://avatars2.githubusercontent.com/u/634932?v=4","gravatar_id":"","url":"https://api.github.com/users/jbalboni","html_url":"https://github.com/jbalboni","followers_url":"https://api.github.com/users/jbalboni/followers","following_url":"https://api.github.com/users/jbalboni/following{/other_user}","gists_url":"https://api.github.com/users/jbalboni/gists{/gist_id}","starred_url":"https://api.github.com/users/jbalboni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbalboni/subscriptions","organizations_url":"https://api.github.com/users/jbalboni/orgs","repos_url":"https://api.github.com/users/jbalboni/repos","events_url":"https://api.github.com/users/jbalboni/events{/privacy}","received_events_url":"https://api.github.com/users/jbalboni/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1526/commits","review_comments_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1526/comments","review_comment_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/1526/comments","statuses_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/statuses/16ea6950affeb91864a1ef2c688414d525554661","head":{"label":"department-of-veterans-affairs:update-delete-old-claims-job","ref":"update-delete-old-claims-job","sha":"16ea6950affeb91864a1ef2c688414d525554661","user":{"login":"department-of-veterans-affairs","id":5421563,"avatar_url":"https://avatars1.githubusercontent.com/u/5421563?v=4","gravatar_id":"","url":"https://api.github.com/users/department-of-veterans-affairs","html_url":"https://github.com/department-of-veterans-affairs","followers_url":"https://api.github.com/users/department-of-veterans-affairs/followers","following_url":"https://api.github.com/users/department-of-veterans-affairs/following{/other_user}","gists_url":"https://api.github.com/users/department-of-veterans-affairs/gists{/gist_id}","starred_url":"https://api.github.com/users/department-of-veterans-affairs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/department-of-veterans-affairs/subscriptions","organizations_url":"https://api.github.com/users/department-of-veterans-affairs/orgs","repos_url":"https://api.github.com/users/department-of-veterans-affairs/repos","events_url":"https://api.github.com/users/department-of-veterans-affairs/events{/privacy}","received_events_url":"https://api.github.com/users/department-of-veterans-affairs/received_events","type":"Organization","site_admin":false},"repo":{"id":62409417,"name":"vets-api","full_name":"department-of-veterans-affairs/vets-api","owner":{"login":"department-of-veterans-affairs","id":5421563,"avatar_url":"https://avatars1.githubusercontent.com/u/5421563?v=4","gravatar_id":"","url":"https://api.github.com/users/department-of-veterans-affairs","html_url":"https://github.com/department-of-veterans-affairs","followers_url":"https://api.github.com/users/department-of-veterans-affairs/followers","following_url":"https://api.github.com/users/department-of-veterans-affairs/following{/other_user}","gists_url":"https://api.github.com/users/department-of-veterans-affairs/gists{/gist_id}","starred_url":"https://api.github.com/users/department-of-veterans-affairs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/department-of-veterans-affairs/subscriptions","organizations_url":"https://api.github.com/users/department-of-veterans-affairs/orgs","repos_url":"https://api.github.com/users/department-of-veterans-affairs/repos","events_url":"https://api.github.com/users/department-of-veterans-affairs/events{/privacy}","received_events_url":"https://api.github.com/users/department-of-veterans-affairs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/department-of-veterans-affairs/vets-api","description":"API for vets.gov","fork":false,"url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api","forks_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/forks","keys_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/teams","hooks_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/hooks","issue_events_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/events{/number}","events_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/events","assignees_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/assignees{/user}","branches_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/branches{/branch}","tags_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/tags","blobs_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/statuses/{sha}","languages_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/languages","stargazers_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/stargazers","contributors_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/contributors","subscribers_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/subscribers","subscription_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/subscription","commits_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/contents/{+path}","compare_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/merges","archive_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/downloads","issues_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues{/number}","pulls_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls{/number}","milestones_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/milestones{/number}","notifications_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/labels{/name}","releases_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/releases{/id}","deployments_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/deployments","created_at":"2016-07-01T17:33:19Z","updated_at":"2017-11-15T04:47:12Z","pushed_at":"2017-11-16T21:32:21Z","git_url":"git://github.com/department-of-veterans-affairs/vets-api.git","ssh_url":"git@github.com:department-of-veterans-affairs/vets-api.git","clone_url":"https://github.com/department-of-veterans-affairs/vets-api.git","svn_url":"https://github.com/department-of-veterans-affairs/vets-api","homepage":null,"size":19404,"stargazers_count":23,"watchers_count":23,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"archived":false,"open_issues_count":23,"forks":10,"open_issues":23,"watchers":23,"default_branch":"master"}},"base":{"label":"department-of-veterans-affairs:master","ref":"master","sha":"65b1eb09596ffd27eadfbb914598ab520a203cbd","user":{"login":"department-of-veterans-affairs","id":5421563,"avatar_url":"https://avatars1.githubusercontent.com/u/5421563?v=4","gravatar_id":"","url":"https://api.github.com/users/department-of-veterans-affairs","html_url":"https://github.com/department-of-veterans-affairs","followers_url":"https://api.github.com/users/department-of-veterans-affairs/followers","following_url":"https://api.github.com/users/department-of-veterans-affairs/following{/other_user}","gists_url":"https://api.github.com/users/department-of-veterans-affairs/gists{/gist_id}","starred_url":"https://api.github.com/users/department-of-veterans-affairs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/department-of-veterans-affairs/subscriptions","organizations_url":"https://api.github.com/users/department-of-veterans-affairs/orgs","repos_url":"https://api.github.com/users/department-of-veterans-affairs/repos","events_url":"https://api.github.com/users/department-of-veterans-affairs/events{/privacy}","received_events_url":"https://api.github.com/users/department-of-veterans-affairs/received_events","type":"Organization","site_admin":false},"repo":{"id":62409417,"name":"vets-api","full_name":"department-of-veterans-affairs/vets-api","owner":{"login":"department-of-veterans-affairs","id":5421563,"avatar_url":"https://avatars1.githubusercontent.com/u/5421563?v=4","gravatar_id":"","url":"https://api.github.com/users/department-of-veterans-affairs","html_url":"https://github.com/department-of-veterans-affairs","followers_url":"https://api.github.com/users/department-of-veterans-affairs/followers","following_url":"https://api.github.com/users/department-of-veterans-affairs/following{/other_user}","gists_url":"https://api.github.com/users/department-of-veterans-affairs/gists{/gist_id}","starred_url":"https://api.github.com/users/department-of-veterans-affairs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/department-of-veterans-affairs/subscriptions","organizations_url":"https://api.github.com/users/department-of-veterans-affairs/orgs","repos_url":"https://api.github.com/users/department-of-veterans-affairs/repos","events_url":"https://api.github.com/users/department-of-veterans-affairs/events{/privacy}","received_events_url":"https://api.github.com/users/department-of-veterans-affairs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/department-of-veterans-affairs/vets-api","description":"API for vets.gov","fork":false,"url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api","forks_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/forks","keys_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/teams","hooks_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/hooks","issue_events_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/events{/number}","events_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/events","assignees_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/assignees{/user}","branches_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/branches{/branch}","tags_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/tags","blobs_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/statuses/{sha}","languages_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/languages","stargazers_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/stargazers","contributors_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/contributors","subscribers_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/subscribers","subscription_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/subscription","commits_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/contents/{+path}","compare_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/merges","archive_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/downloads","issues_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues{/number}","pulls_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls{/number}","milestones_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/milestones{/number}","notifications_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/labels{/name}","releases_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/releases{/id}","deployments_url":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/deployments","created_at":"2016-07-01T17:33:19Z","updated_at":"2017-11-15T04:47:12Z","pushed_at":"2017-11-16T21:32:21Z","git_url":"git://github.com/department-of-veterans-affairs/vets-api.git","ssh_url":"git@github.com:department-of-veterans-affairs/vets-api.git","clone_url":"https://github.com/department-of-veterans-affairs/vets-api.git","svn_url":"https://github.com/department-of-veterans-affairs/vets-api","homepage":null,"size":19404,"stargazers_count":23,"watchers_count":23,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"archived":false,"open_issues_count":23,"forks":10,"open_issues":23,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1526"},"html":{"href":"https://github.com/department-of-veterans-affairs/vets-api/pull/1526"},"issue":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/1526"},"comments":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/issues/1526/comments"},"review_comments":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1526/comments"},"review_comment":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/pulls/1526/commits"},"statuses":{"href":"https://api.github.com/repos/department-of-veterans-affairs/vets-api/statuses/16ea6950affeb91864a1ef2c688414d525554661"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"lihanli"}}