{"action":"created","issue":{"url":"https://api.github.com/repos/artsy/exchange/issues/124","repository_url":"https://api.github.com/repos/artsy/exchange","labels_url":"https://api.github.com/repos/artsy/exchange/issues/124/labels{/name}","comments_url":"https://api.github.com/repos/artsy/exchange/issues/124/comments","events_url":"https://api.github.com/repos/artsy/exchange/issues/124/events","html_url":"https://github.com/artsy/exchange/pull/124","id":353568177,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwNTg2Nzc5","number":124,"title":"Record timestamp when order enters a new state","user":{"login":"williardx","id":4432348,"node_id":"MDQ6VXNlcjQ0MzIzNDg=","avatar_url":"https://avatars1.githubusercontent.com/u/4432348?v=4","gravatar_id":"","url":"https://api.github.com/users/williardx","html_url":"https://github.com/williardx","followers_url":"https://api.github.com/users/williardx/followers","following_url":"https://api.github.com/users/williardx/following{/other_user}","gists_url":"https://api.github.com/users/williardx/gists{/gist_id}","starred_url":"https://api.github.com/users/williardx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/williardx/subscriptions","organizations_url":"https://api.github.com/users/williardx/orgs","repos_url":"https://api.github.com/users/williardx/repos","events_url":"https://api.github.com/users/williardx/events{/privacy}","received_events_url":"https://api.github.com/users/williardx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"ashkan18","id":1230819,"node_id":"MDQ6VXNlcjEyMzA4MTk=","avatar_url":"https://avatars0.githubusercontent.com/u/1230819?v=4","gravatar_id":"","url":"https://api.github.com/users/ashkan18","html_url":"https://github.com/ashkan18","followers_url":"https://api.github.com/users/ashkan18/followers","following_url":"https://api.github.com/users/ashkan18/following{/other_user}","gists_url":"https://api.github.com/users/ashkan18/gists{/gist_id}","starred_url":"https://api.github.com/users/ashkan18/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashkan18/subscriptions","organizations_url":"https://api.github.com/users/ashkan18/orgs","repos_url":"https://api.github.com/users/ashkan18/repos","events_url":"https://api.github.com/users/ashkan18/events{/privacy}","received_events_url":"https://api.github.com/users/ashkan18/received_events","type":"User","site_admin":false},"assignees":[{"login":"ashkan18","id":1230819,"node_id":"MDQ6VXNlcjEyMzA4MTk=","avatar_url":"https://avatars0.githubusercontent.com/u/1230819?v=4","gravatar_id":"","url":"https://api.github.com/users/ashkan18","html_url":"https://github.com/ashkan18","followers_url":"https://api.github.com/users/ashkan18/followers","following_url":"https://api.github.com/users/ashkan18/following{/other_user}","gists_url":"https://api.github.com/users/ashkan18/gists{/gist_id}","starred_url":"https://api.github.com/users/ashkan18/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashkan18/subscriptions","organizations_url":"https://api.github.com/users/ashkan18/orgs","repos_url":"https://api.github.com/users/ashkan18/repos","events_url":"https://api.github.com/users/ashkan18/events{/privacy}","received_events_url":"https://api.github.com/users/ashkan18/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2018-08-23T21:54:50Z","updated_at":"2018-08-24T13:54:15Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/artsy/exchange/pulls/124","html_url":"https://github.com/artsy/exchange/pull/124","diff_url":"https://github.com/artsy/exchange/pull/124.diff","patch_url":"https://github.com/artsy/exchange/pull/124.patch"},"body":"This PR addresses [PLATFORM-773](https://artsyproduct.atlassian.net/browse/PLATFORM-773) and updates a timestamp when an order becomes abandoned, submitted, approved, rejected or fulfilled.\r\n\r\nMetaphysics PR forthcoming!\r\n\r\n### What Changed\r\n- Adds 5 new datetime columns to the orders table: `abandoned_at`, `submitted_at`, `approved_at`, `rejected_at` and `fulfilled_at`.\r\n- Sets `order.$STATE_at` for each state except pending whenever the state changes.\r\n- Adds `submitted_at`, `approved_at`, `rejected_at` and `fulfilled_at` to the GraphQL schema."},"comment":{"url":"https://api.github.com/repos/artsy/exchange/issues/comments/415765855","html_url":"https://github.com/artsy/exchange/pull/124#issuecomment-415765855","issue_url":"https://api.github.com/repos/artsy/exchange/issues/124","id":415765855,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNTc2NTg1NQ==","user":{"login":"jonallured","id":79799,"node_id":"MDQ6VXNlcjc5Nzk5","avatar_url":"https://avatars3.githubusercontent.com/u/79799?v=4","gravatar_id":"","url":"https://api.github.com/users/jonallured","html_url":"https://github.com/jonallured","followers_url":"https://api.github.com/users/jonallured/followers","following_url":"https://api.github.com/users/jonallured/following{/other_user}","gists_url":"https://api.github.com/users/jonallured/gists{/gist_id}","starred_url":"https://api.github.com/users/jonallured/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonallured/subscriptions","organizations_url":"https://api.github.com/users/jonallured/orgs","repos_url":"https://api.github.com/users/jonallured/repos","events_url":"https://api.github.com/users/jonallured/events{/privacy}","received_events_url":"https://api.github.com/users/jonallured/received_events","type":"User","site_admin":false},"created_at":"2018-08-24T13:54:15Z","updated_at":"2018-08-24T13:54:15Z","author_association":"MEMBER","body":"Another idea here is to use PaperTrail. @joeyAghion has a good point that when we hit use cases that allow an order to go back and forth between states, the timestamp fields added here won't tell the whole story about the states of an order. I took a quick look on staging to see what I could come up with, check this out:\r\n\r\n```ruby\r\n> order = Order.find 180\r\n> order.state\r\n=> \"fulfilled\"\r\n> submitted_versions = order.versions.select { |v| v.event == 'update' && v.object['state'] == 'submitted' }\r\n> submitted_versions.map { |v| v.object['state_updated_at'] }\r\n=> [\"2018-08-22T16:43:50.062Z\", \"2018-08-22T16:43:50.062Z\"]\r\n```\r\n\r\nPaperTrail stores the before as documented in the table here:\r\n\r\nhttps://github.com/paper-trail-gem/paper_trail#1c-basic-usage\r\n\r\nSo that means the versions matching my `select` above are the before states, not the changes - not ideal, but...I noticed that PaperTrail has an optional feature for storing the diff:\r\n\r\nhttps://github.com/paper-trail-gem/paper_trail#3c-diffing-versions\r\n\r\nI think it would probably be a good idea to add the `object_changes` column as they suggest.\r\n\r\nAnyway, I guess why I'm interested in this approach is that we're already storing this info, so let's use it! If not for this, then why are we using PaperTrail on Exchange?!"}}
{"actor":{"display_login":"jonallured"}}