{"action":"created","comment":{"url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/comments/42495259","id":42495259,"diff_hunk":"@@ -147,6 +148,66 @@ def update_partner_library():\n             added, skipped, source)\n \n \n+@task(name='tasks.requeue_missed_searches', ignore_result=True)\n+def requeue_missed_searches():\n+    \"\"\"\n+    Determine which saved searches should have been sent in the past but have\n+    not. Send those individually or in digests as appropriate.\n+    \"\"\"\n+    today = datetime.today()\n+    day_of_week = str(today.isoweekday())\n+    day_of_month = today.day\n+\n+    # We have lists of every day in the week and every day of the month.\n+    # To exclude searches that will be sent later today, we need to filter\n+    # today out of those lists.\n+    not_today = lambda day: (lambda choice: choice != day)\n+    days_of_week = filter(not_today(day_of_week),\n+                          [choice[0] for choice in DOW_CHOICES])\n+    days_of_month = filter(not_today(day_of_month),\n+                           [choice[0] for choice in DOM_CHOICES])\n+\n+    q = Q()\n+    for day in days_of_week:\n+        days_ago = today.isoweekday() - int(day)\n+        if days_ago < 0:\n+            days_ago = 7 - days_ago\n+        q = q | (Q(frequency='W', day_of_week=day) &\n+                 (Q(last_sent__lt=today - timedelta(days=days_ago)) |\n+                  Q(last_sent__isnull=True)))\n+    for day in days_of_month:\n+        days_ago = day_of_month - day\n+        if days_ago < 0:\n+            days_ago = 31 - days_ago","path":"tasks.py","position":null,"original_position":44,"commit_id":"ba81f4229c2bad18f452d5b2f2cb2043742544e6","original_commit_id":"43798610d6fd1658ef2bd89d6228d3e68b5bd6f3","user":{"login":"tdphillips","id":3379265,"avatar_url":"https://avatars.githubusercontent.com/u/3379265?v=3","gravatar_id":"","url":"https://api.github.com/users/tdphillips","html_url":"https://github.com/tdphillips","followers_url":"https://api.github.com/users/tdphillips/followers","following_url":"https://api.github.com/users/tdphillips/following{/other_user}","gists_url":"https://api.github.com/users/tdphillips/gists{/gist_id}","starred_url":"https://api.github.com/users/tdphillips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdphillips/subscriptions","organizations_url":"https://api.github.com/users/tdphillips/orgs","repos_url":"https://api.github.com/users/tdphillips/repos","events_url":"https://api.github.com/users/tdphillips/events{/privacy}","received_events_url":"https://api.github.com/users/tdphillips/received_events","type":"User","site_admin":false},"body":"I think I've fixed the math.","created_at":"2015-10-20T13:36:17Z","updated_at":"2015-10-20T13:36:17Z","html_url":"https://github.com/DirectEmployers/MyJobs/pull/1821#discussion_r42495259","pull_request_url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1821","_links":{"self":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/comments/42495259"},"html":{"href":"https://github.com/DirectEmployers/MyJobs/pull/1821#discussion_r42495259"},"pull_request":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1821"}}},"pull_request":{"url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1821","id":47817546,"html_url":"https://github.com/DirectEmployers/MyJobs/pull/1821","diff_url":"https://github.com/DirectEmployers/MyJobs/pull/1821.diff","patch_url":"https://github.com/DirectEmployers/MyJobs/pull/1821.patch","issue_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/1821","number":1821,"state":"open","locked":false,"title":"Allow requeuing of all unsent saved searches [PD-1811]","user":{"login":"tdphillips","id":3379265,"avatar_url":"https://avatars.githubusercontent.com/u/3379265?v=3","gravatar_id":"","url":"https://api.github.com/users/tdphillips","html_url":"https://github.com/tdphillips","followers_url":"https://api.github.com/users/tdphillips/followers","following_url":"https://api.github.com/users/tdphillips/following{/other_user}","gists_url":"https://api.github.com/users/tdphillips/gists{/gist_id}","starred_url":"https://api.github.com/users/tdphillips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdphillips/subscriptions","organizations_url":"https://api.github.com/users/tdphillips/orgs","repos_url":"https://api.github.com/users/tdphillips/repos","events_url":"https://api.github.com/users/tdphillips/events{/privacy}","received_events_url":"https://api.github.com/users/tdphillips/received_events","type":"User","site_admin":false},"body":"Awaiting responses on the ticket. In the meantime, the new task can be examined.\r\n\r\nAll tests pass.","created_at":"2015-10-15T17:35:53Z","updated_at":"2015-10-20T13:36:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"01feca4d0e15605fb3a39973867d50c0a1819336","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1821/commits","review_comments_url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1821/comments","review_comment_url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/1821/comments","statuses_url":"https://api.github.com/repos/DirectEmployers/MyJobs/statuses/ba81f4229c2bad18f452d5b2f2cb2043742544e6","head":{"label":"DirectEmployers:send-missed-saved-searches","ref":"send-missed-saved-searches","sha":"ba81f4229c2bad18f452d5b2f2cb2043742544e6","user":{"login":"DirectEmployers","id":381171,"avatar_url":"https://avatars.githubusercontent.com/u/381171?v=3","gravatar_id":"","url":"https://api.github.com/users/DirectEmployers","html_url":"https://github.com/DirectEmployers","followers_url":"https://api.github.com/users/DirectEmployers/followers","following_url":"https://api.github.com/users/DirectEmployers/following{/other_user}","gists_url":"https://api.github.com/users/DirectEmployers/gists{/gist_id}","starred_url":"https://api.github.com/users/DirectEmployers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DirectEmployers/subscriptions","organizations_url":"https://api.github.com/users/DirectEmployers/orgs","repos_url":"https://api.github.com/users/DirectEmployers/repos","events_url":"https://api.github.com/users/DirectEmployers/events{/privacy}","received_events_url":"https://api.github.com/users/DirectEmployers/received_events","type":"Organization","site_admin":false},"repo":{"id":2867982,"name":"MyJobs","full_name":"DirectEmployers/MyJobs","owner":{"login":"DirectEmployers","id":381171,"avatar_url":"https://avatars.githubusercontent.com/u/381171?v=3","gravatar_id":"","url":"https://api.github.com/users/DirectEmployers","html_url":"https://github.com/DirectEmployers","followers_url":"https://api.github.com/users/DirectEmployers/followers","following_url":"https://api.github.com/users/DirectEmployers/following{/other_user}","gists_url":"https://api.github.com/users/DirectEmployers/gists{/gist_id}","starred_url":"https://api.github.com/users/DirectEmployers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DirectEmployers/subscriptions","organizations_url":"https://api.github.com/users/DirectEmployers/orgs","repos_url":"https://api.github.com/users/DirectEmployers/repos","events_url":"https://api.github.com/users/DirectEmployers/events{/privacy}","received_events_url":"https://api.github.com/users/DirectEmployers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DirectEmployers/MyJobs","description":"Multi-user website designed to assist job seekers in their search for employment","fork":false,"url":"https://api.github.com/repos/DirectEmployers/MyJobs","forks_url":"https://api.github.com/repos/DirectEmployers/MyJobs/forks","keys_url":"https://api.github.com/repos/DirectEmployers/MyJobs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DirectEmployers/MyJobs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DirectEmployers/MyJobs/teams","hooks_url":"https://api.github.com/repos/DirectEmployers/MyJobs/hooks","issue_events_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/events{/number}","events_url":"https://api.github.com/repos/DirectEmployers/MyJobs/events","assignees_url":"https://api.github.com/repos/DirectEmployers/MyJobs/assignees{/user}","branches_url":"https://api.github.com/repos/DirectEmployers/MyJobs/branches{/branch}","tags_url":"https://api.github.com/repos/DirectEmployers/MyJobs/tags","blobs_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/refs{/sha}","trees_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DirectEmployers/MyJobs/statuses/{sha}","languages_url":"https://api.github.com/repos/DirectEmployers/MyJobs/languages","stargazers_url":"https://api.github.com/repos/DirectEmployers/MyJobs/stargazers","contributors_url":"https://api.github.com/repos/DirectEmployers/MyJobs/contributors","subscribers_url":"https://api.github.com/repos/DirectEmployers/MyJobs/subscribers","subscription_url":"https://api.github.com/repos/DirectEmployers/MyJobs/subscription","commits_url":"https://api.github.com/repos/DirectEmployers/MyJobs/commits{/sha}","git_commits_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/commits{/sha}","comments_url":"https://api.github.com/repos/DirectEmployers/MyJobs/comments{/number}","issue_comment_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/comments{/number}","contents_url":"https://api.github.com/repos/DirectEmployers/MyJobs/contents/{+path}","compare_url":"https://api.github.com/repos/DirectEmployers/MyJobs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DirectEmployers/MyJobs/merges","archive_url":"https://api.github.com/repos/DirectEmployers/MyJobs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DirectEmployers/MyJobs/downloads","issues_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues{/number}","pulls_url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls{/number}","milestones_url":"https://api.github.com/repos/DirectEmployers/MyJobs/milestones{/number}","notifications_url":"https://api.github.com/repos/DirectEmployers/MyJobs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DirectEmployers/MyJobs/labels{/name}","releases_url":"https://api.github.com/repos/DirectEmployers/MyJobs/releases{/id}","created_at":"2011-11-28T15:22:36Z","updated_at":"2015-06-22T16:37:22Z","pushed_at":"2015-10-20T13:35:04Z","git_url":"git://github.com/DirectEmployers/MyJobs.git","ssh_url":"git@github.com:DirectEmployers/MyJobs.git","clone_url":"https://github.com/DirectEmployers/MyJobs.git","svn_url":"https://github.com/DirectEmployers/MyJobs","homepage":"http://my.jobs","size":34999,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":8,"forks":9,"open_issues":8,"watchers":5,"default_branch":"quality-control"}},"base":{"label":"DirectEmployers:quality-control","ref":"quality-control","sha":"4f7303cb7ffb2bf1047cb6b3cd1c48cc24434f57","user":{"login":"DirectEmployers","id":381171,"avatar_url":"https://avatars.githubusercontent.com/u/381171?v=3","gravatar_id":"","url":"https://api.github.com/users/DirectEmployers","html_url":"https://github.com/DirectEmployers","followers_url":"https://api.github.com/users/DirectEmployers/followers","following_url":"https://api.github.com/users/DirectEmployers/following{/other_user}","gists_url":"https://api.github.com/users/DirectEmployers/gists{/gist_id}","starred_url":"https://api.github.com/users/DirectEmployers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DirectEmployers/subscriptions","organizations_url":"https://api.github.com/users/DirectEmployers/orgs","repos_url":"https://api.github.com/users/DirectEmployers/repos","events_url":"https://api.github.com/users/DirectEmployers/events{/privacy}","received_events_url":"https://api.github.com/users/DirectEmployers/received_events","type":"Organization","site_admin":false},"repo":{"id":2867982,"name":"MyJobs","full_name":"DirectEmployers/MyJobs","owner":{"login":"DirectEmployers","id":381171,"avatar_url":"https://avatars.githubusercontent.com/u/381171?v=3","gravatar_id":"","url":"https://api.github.com/users/DirectEmployers","html_url":"https://github.com/DirectEmployers","followers_url":"https://api.github.com/users/DirectEmployers/followers","following_url":"https://api.github.com/users/DirectEmployers/following{/other_user}","gists_url":"https://api.github.com/users/DirectEmployers/gists{/gist_id}","starred_url":"https://api.github.com/users/DirectEmployers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DirectEmployers/subscriptions","organizations_url":"https://api.github.com/users/DirectEmployers/orgs","repos_url":"https://api.github.com/users/DirectEmployers/repos","events_url":"https://api.github.com/users/DirectEmployers/events{/privacy}","received_events_url":"https://api.github.com/users/DirectEmployers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DirectEmployers/MyJobs","description":"Multi-user website designed to assist job seekers in their search for employment","fork":false,"url":"https://api.github.com/repos/DirectEmployers/MyJobs","forks_url":"https://api.github.com/repos/DirectEmployers/MyJobs/forks","keys_url":"https://api.github.com/repos/DirectEmployers/MyJobs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DirectEmployers/MyJobs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DirectEmployers/MyJobs/teams","hooks_url":"https://api.github.com/repos/DirectEmployers/MyJobs/hooks","issue_events_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/events{/number}","events_url":"https://api.github.com/repos/DirectEmployers/MyJobs/events","assignees_url":"https://api.github.com/repos/DirectEmployers/MyJobs/assignees{/user}","branches_url":"https://api.github.com/repos/DirectEmployers/MyJobs/branches{/branch}","tags_url":"https://api.github.com/repos/DirectEmployers/MyJobs/tags","blobs_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/refs{/sha}","trees_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DirectEmployers/MyJobs/statuses/{sha}","languages_url":"https://api.github.com/repos/DirectEmployers/MyJobs/languages","stargazers_url":"https://api.github.com/repos/DirectEmployers/MyJobs/stargazers","contributors_url":"https://api.github.com/repos/DirectEmployers/MyJobs/contributors","subscribers_url":"https://api.github.com/repos/DirectEmployers/MyJobs/subscribers","subscription_url":"https://api.github.com/repos/DirectEmployers/MyJobs/subscription","commits_url":"https://api.github.com/repos/DirectEmployers/MyJobs/commits{/sha}","git_commits_url":"https://api.github.com/repos/DirectEmployers/MyJobs/git/commits{/sha}","comments_url":"https://api.github.com/repos/DirectEmployers/MyJobs/comments{/number}","issue_comment_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/comments{/number}","contents_url":"https://api.github.com/repos/DirectEmployers/MyJobs/contents/{+path}","compare_url":"https://api.github.com/repos/DirectEmployers/MyJobs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DirectEmployers/MyJobs/merges","archive_url":"https://api.github.com/repos/DirectEmployers/MyJobs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DirectEmployers/MyJobs/downloads","issues_url":"https://api.github.com/repos/DirectEmployers/MyJobs/issues{/number}","pulls_url":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls{/number}","milestones_url":"https://api.github.com/repos/DirectEmployers/MyJobs/milestones{/number}","notifications_url":"https://api.github.com/repos/DirectEmployers/MyJobs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DirectEmployers/MyJobs/labels{/name}","releases_url":"https://api.github.com/repos/DirectEmployers/MyJobs/releases{/id}","created_at":"2011-11-28T15:22:36Z","updated_at":"2015-06-22T16:37:22Z","pushed_at":"2015-10-20T13:35:04Z","git_url":"git://github.com/DirectEmployers/MyJobs.git","ssh_url":"git@github.com:DirectEmployers/MyJobs.git","clone_url":"https://github.com/DirectEmployers/MyJobs.git","svn_url":"https://github.com/DirectEmployers/MyJobs","homepage":"http://my.jobs","size":34999,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":8,"forks":9,"open_issues":8,"watchers":5,"default_branch":"quality-control"}},"_links":{"self":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1821"},"html":{"href":"https://github.com/DirectEmployers/MyJobs/pull/1821"},"issue":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/1821"},"comments":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/issues/1821/comments"},"review_comments":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1821/comments"},"review_comment":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/pulls/1821/commits"},"statuses":{"href":"https://api.github.com/repos/DirectEmployers/MyJobs/statuses/ba81f4229c2bad18f452d5b2f2cb2043742544e6"}}}}