{"action":"created","issue":{"url":"https://api.github.com/repos/alphagov/email-alert-api/issues/582","repository_url":"https://api.github.com/repos/alphagov/email-alert-api","labels_url":"https://api.github.com/repos/alphagov/email-alert-api/issues/582/labels{/name}","comments_url":"https://api.github.com/repos/alphagov/email-alert-api/issues/582/comments","events_url":"https://api.github.com/repos/alphagov/email-alert-api/issues/582/events","html_url":"https://github.com/alphagov/email-alert-api/pull/582","id":311940258,"number":582,"title":"Create worker to mark digest runs as complete","user":{"login":"boffbowsh","id":18276,"avatar_url":"https://avatars1.githubusercontent.com/u/18276?v=4","gravatar_id":"","url":"https://api.github.com/users/boffbowsh","html_url":"https://github.com/boffbowsh","followers_url":"https://api.github.com/users/boffbowsh/followers","following_url":"https://api.github.com/users/boffbowsh/following{/other_user}","gists_url":"https://api.github.com/users/boffbowsh/gists{/gist_id}","starred_url":"https://api.github.com/users/boffbowsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boffbowsh/subscriptions","organizations_url":"https://api.github.com/users/boffbowsh/orgs","repos_url":"https://api.github.com/users/boffbowsh/repos","events_url":"https://api.github.com/users/boffbowsh/events{/privacy}","received_events_url":"https://api.github.com/users/boffbowsh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-06T11:25:15Z","updated_at":"2018-04-06T12:30:52Z","closed_at":null,"author_association":"OWNER","pull_request":{"url":"https://api.github.com/repos/alphagov/email-alert-api/pulls/582","html_url":"https://github.com/alphagov/email-alert-api/pull/582","diff_url":"https://github.com/alphagov/email-alert-api/pull/582.diff","patch_url":"https://github.com/alphagov/email-alert-api/pull/582.patch"},"body":"After every digest email is sent, the worker checks if it was the last\r\nemail to be sent for that digest run. If it is, it marks the run as\r\ncomplete. The check required is expensive, between 2 to 4 seconds in\r\nthe database while under load. We've been unable to make Postgres use\r\nan index to speed up the operation.\r\n\r\nThis commit adds a new worker that finds all runs that haven't yet been\r\nmarked as completed, checks if all the subscribers are marked as\r\ncompleted then uses the most recent completion time as the run's\r\ncompletion time. Running this every minute will still give us accurate\r\nstatistics and will greatly reduce the load on Postgres.\r\n"},"comment":{"url":"https://api.github.com/repos/alphagov/email-alert-api/issues/comments/379238658","html_url":"https://github.com/alphagov/email-alert-api/pull/582#issuecomment-379238658","issue_url":"https://api.github.com/repos/alphagov/email-alert-api/issues/582","id":379238658,"user":{"login":"boffbowsh","id":18276,"avatar_url":"https://avatars1.githubusercontent.com/u/18276?v=4","gravatar_id":"","url":"https://api.github.com/users/boffbowsh","html_url":"https://github.com/boffbowsh","followers_url":"https://api.github.com/users/boffbowsh/followers","following_url":"https://api.github.com/users/boffbowsh/following{/other_user}","gists_url":"https://api.github.com/users/boffbowsh/gists{/gist_id}","starred_url":"https://api.github.com/users/boffbowsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boffbowsh/subscriptions","organizations_url":"https://api.github.com/users/boffbowsh/orgs","repos_url":"https://api.github.com/users/boffbowsh/repos","events_url":"https://api.github.com/users/boffbowsh/events{/privacy}","received_events_url":"https://api.github.com/users/boffbowsh/received_events","type":"User","site_admin":false},"created_at":"2018-04-06T12:30:52Z","updated_at":"2018-04-06T12:30:52Z","author_association":"OWNER","body":"I tried many different types of query and I just couldn't get Postgres to use either index (compound and the `digest_run_id` by itself)"}}
{"actor":{"display_login":"boffbowsh"}}