{"action":"created","issue":{"url":"https://api.github.com/repos/eprintsug/hefce_oa/issues/27","repository_url":"https://api.github.com/repos/eprintsug/hefce_oa","labels_url":"https://api.github.com/repos/eprintsug/hefce_oa/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/eprintsug/hefce_oa/issues/27/comments","events_url":"https://api.github.com/repos/eprintsug/hefce_oa/issues/27/events","html_url":"https://github.com/eprintsug/hefce_oa/pull/27","id":139264220,"number":27,"title":"Automatic population of embargo length.","user":{"login":"wfyson","id":4145721,"avatar_url":"https://avatars.githubusercontent.com/u/4145721?v=3","gravatar_id":"","url":"https://api.github.com/users/wfyson","html_url":"https://github.com/wfyson","followers_url":"https://api.github.com/users/wfyson/followers","following_url":"https://api.github.com/users/wfyson/following{/other_user}","gists_url":"https://api.github.com/users/wfyson/gists{/gist_id}","starred_url":"https://api.github.com/users/wfyson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wfyson/subscriptions","organizations_url":"https://api.github.com/users/wfyson/orgs","repos_url":"https://api.github.com/users/wfyson/repos","events_url":"https://api.github.com/users/wfyson/events{/privacy}","received_events_url":"https://api.github.com/users/wfyson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-03-08T12:19:26Z","updated_at":"2016-03-09T14:12:47Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/eprintsug/hefce_oa/pulls/27","html_url":"https://github.com/eprintsug/hefce_oa/pull/27","diff_url":"https://github.com/eprintsug/hefce_oa/pull/27.diff","patch_url":"https://github.com/eprintsug/hefce_oa/pull/27.patch"},"body":"Fix for https://github.com/eprintsug/hefce_oa/issues/23\r\n\r\nWill try and use the published online date where possible and then the published date as per HEFCE guidance (although should it actually compare them and use the earliest rather than assume published_online will be the earliest?)."},"comment":{"url":"https://api.github.com/repos/eprintsug/hefce_oa/issues/comments/194311427","html_url":"https://github.com/eprintsug/hefce_oa/pull/27#issuecomment-194311427","issue_url":"https://api.github.com/repos/eprintsug/hefce_oa/issues/27","id":194311427,"user":{"login":"wfyson","id":4145721,"avatar_url":"https://avatars.githubusercontent.com/u/4145721?v=3","gravatar_id":"","url":"https://api.github.com/users/wfyson","html_url":"https://github.com/wfyson","followers_url":"https://api.github.com/users/wfyson/followers","following_url":"https://api.github.com/users/wfyson/following{/other_user}","gists_url":"https://api.github.com/users/wfyson/gists{/gist_id}","starred_url":"https://api.github.com/users/wfyson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wfyson/subscriptions","organizations_url":"https://api.github.com/users/wfyson/orgs","repos_url":"https://api.github.com/users/wfyson/repos","events_url":"https://api.github.com/users/wfyson/events{/privacy}","received_events_url":"https://api.github.com/users/wfyson/received_events","type":"User","site_admin":false},"created_at":"2016-03-09T14:12:47Z","updated_at":"2016-03-09T14:12:47Z","body":"Ok then, I think I have implemented the above... \r\n\r\nIn short, I get all the documents and order them with published and accepted ones coming first. We then cycle through them all and if they are published or accepted and have an embargo date set then we set that as the latest result, with any documents that have an earlier embargo beating any that have been previously set. If no embargo date has been set and the document is public we simply return there and then (as published documents are checked before accepted ones) and if no embargo date has been set and it isn't public and it's the first document we've come across we store the document to be returned (unless something better comes along)! \r\n\r\nI'm sure it can probably be implemented far more efficiently than the above but let me know what you think!"}}