GitHub PullRequestReviewCommentEvent at 2014-10-02 06:21:09
Repository: sharetribe
Actor: ovan
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/sharetribe/sharetribe/pulls/comments/18323861","id":18323861,"diff_hunk":"@@ -0,0 +1,326 @@\n+module MarketplaceService\n+  module Inbox\n+    module Entity\n+      module_function\n+\n+      def last_activity_type(inbox_item)\n+        message_was_last = if inbox_item[:last_transition_at].nil?\n+          :message\n+        elsif inbox_item[:last_message_at].nil?\n+          :transition\n+        elsif inbox_item[:last_transition_to_state] == \"free\" || inbox_item[:last_transition_to_state] == \"pending\"\n+          # Ignore \"free\" and \"pending\" transitions\n+          :message\n+        else\n+          if inbox_item[:last_message_at] > inbox_item[:last_transition_at]\n+            :message\n+          else\n+            :transition\n+          end\n+        end\n+      end\n+    end\n+\n+    module Command\n+\n+    end\n+\n+    module Query\n+      PersonModel = ::Person\n+\n+      module_function\n+\n+      def inbox_data_count(person_id, community_id)\n+        QueryHelper.query_inbox_data_count(person_id, community_id)\n+      end\n+\n+      def inbox_data(person_id, community_id, limit, offset)\n+        QueryHelper.query_inbox_data(person_id, community_id, limit, offset)\n+      end\n+\n+      def notification_count(person_id, community_id)\n+        QueryHelper.query_notification_count(person_id, community_id)\n+      end\n+    end\n+\n+    module QueryHelper\n+      PersonModel = ::Person\n+\n+      @tiny_int_to_bool = ->(tiny_int) {\n+        !(tiny_int.nil? || tiny_int == 0)\n+      }\n+\n+      common_spec = [\n+        [:conversation_id, :fixnum, :mandatory],\n+        [:last_activity_at, :str_to_time, :mandatory],\n+        [:current_is_starter, :mandatory, transform_with: @tiny_int_to_bool],\n+        [:current_id, :string, :mandatory],\n+        [:other_id, :string, :mandatory],\n+\n+        [:should_notify, :mandatory],\n+\n+        [:starter, :hash, :mandatory],\n+        [:current, :hash, :mandatory],\n+        [:other, :hash, :mandatory]\n+      ]\n+\n+      conversation_spec = [\n+        [:type, const_value: :conversation],\n+        [:last_message_at, :time, :mandatory],\n+        [:last_message_content, :string, :mandatory]\n+      ]\n+\n+      transaction_spec = [\n+        [:type, const_value: :transaction],\n+        [:transaction_id, :fixnum, :mandatory],\n+\n+        [:listing_id, :fixnum, :mandatory],\n+        [:listing_title, :string, :mandatory],\n+        [:transaction_type, :string, :mandatory],\n+\n+        [:last_transition_at, :time, :mandatory],\n+        [:last_transition_to_state, :string, :mandatory],\n+        [:last_message_at, :time, :optional],\n+        [:last_message_content, :string, :optional],\n+\n+        [:sum_cents, :fixnum, :optional],\n+        [:currency, :string, :optional],\n+\n+        [:author, :hash, :mandatory],\n+        [:waiting_feedback, :mandatory, transform_with: @tiny_int_to_bool],\n+        [:transitions, :mandatory] # Could add Array validation\n+      ]\n+\n+      InboxConvesation = EntityUtils.define_builder(*common_spec, *conversation_spec, *conversation_spec)","path":"app/services/marketplace_service/inbox.rb","position":94,"original_position":94,"commit_id":"46672f748aa95127d3184eefba481c5bf03279ad","original_commit_id":"46672f748aa95127d3184eefba481c5bf03279ad","user":{"login":"ovan","id":271845,"avatar_url":"https://avatars.githubusercontent.com/u/271845?v=2","gravatar_id":"","url":"https://api.github.com/users/ovan","html_url":"https://github.com/ovan","followers_url":"https://api.github.com/users/ovan/followers","following_url":"https://api.github.com/users/ovan/following{/other_user}","gists_url":"https://api.github.com/users/ovan/gists{/gist_id}","starred_url":"https://api.github.com/users/ovan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ovan/subscriptions","organizations_url":"https://api.github.com/users/ovan/orgs","repos_url":"https://api.github.com/users/ovan/repos","events_url":"https://api.github.com/users/ovan/events{/privacy}","received_events_url":"https://api.github.com/users/ovan/received_events","type":"User","site_admin":false},"body":"Also the name is InboxConvesation","created_at":"2014-10-02T06:21:09Z","updated_at":"2014-10-02T06:21:09Z","html_url":"https://github.com/sharetribe/sharetribe/pull/614#discussion_r18323861","pull_request_url":"https://api.github.com/repos/sharetribe/sharetribe/pulls/614","_links":{"self":{"href":"https://api.github.com/repos/sharetribe/sharetribe/pulls/comments/18323861"},"html":{"href":"https://github.com/sharetribe/sharetribe/pull/614#discussion_r18323861"},"pull_request":{"href":"https://api.github.com/repos/sharetribe/sharetribe/pulls/614"}}},"pull_request":{"url":"https://api.github.com/repos/sharetribe/sharetribe/pulls/614","id":21986620,"html_url":"https://github.com/sharetribe/sharetribe/pull/614","diff_url":"https://github.com/sharetribe/sharetribe/pull/614.diff","patch_url":"https://github.com/sharetribe/sharetribe/pull/614.patch","issue_url":"https://api.github.com/repos/sharetribe/sharetribe/issues/614","number":614,"state":"open","locked":false,"title":"Optimize inbox SQL queries","user":{"login":"rap1ds","id":429876,"avatar_url":"https://avatars.githubusercontent.com/u/429876?v=2","gravatar_id":"","url":"https://api.github.com/users/rap1ds","html_url":"https://github.com/rap1ds","followers_url":"https://api.github.com/users/rap1ds/followers","following_url":"https://api.github.com/users/rap1ds/following{/other_user}","gists_url":"https://api.github.com/users/rap1ds/gists{/gist_id}","starred_url":"https://api.github.com/users/rap1ds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rap1ds/subscriptions","organizations_url":"https://api.github.com/users/rap1ds/orgs","repos_url":"https://api.github.com/users/rap1ds/repos","events_url":"https://api.github.com/users/rap1ds/events{/privacy}","received_events_url":"https://api.github.com/users/rap1ds/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-09-30T07:42:50Z","updated_at":"2014-10-02T06:21:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d0e5983c2dd5aaa6fe672d29a6bffffbda572470","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sharetribe/sharetribe/pulls/614/commits","review_comments_url":"https://api.github.com/repos/sharetribe/sharetribe/pulls/614/comments","review_comment_url":"https://api.github.com/repos/sharetribe/sharetribe/pulls/comments/{number}","comments_url":"https://api.github.com/repos/sharetribe/sharetribe/issues/614/comments","statuses_url":"https://api.github.com/repos/sharetribe/sharetribe/statuses/46672f748aa95127d3184eefba481c5bf03279ad","head":{"label":"sharetribe:optimize-inbox","ref":"optimize-inbox","sha":"46672f748aa95127d3184eefba481c5bf03279ad","user":{"login":"sharetribe","id":1733898,"avatar_url":"https://avatars.githubusercontent.com/u/1733898?v=2","gravatar_id":"","url":"https://api.github.com/users/sharetribe","html_url":"https://github.com/sharetribe","followers_url":"https://api.github.com/users/sharetribe/followers","following_url":"https://api.github.com/users/sharetribe/following{/other_user}","gists_url":"https://api.github.com/users/sharetribe/gists{/gist_id}","starred_url":"https://api.github.com/users/sharetribe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharetribe/subscriptions","organizations_url":"https://api.github.com/users/sharetribe/orgs","repos_url":"https://api.github.com/users/sharetribe/repos","events_url":"https://api.github.com/users/sharetribe/events{/privacy}","received_events_url":"https://api.github.com/users/sharetribe/received_events","type":"Organization","site_admin":false},"repo":{"id":4447023,"name":"sharetribe","full_name":"sharetribe/sharetribe","owner":{"login":"sharetribe","id":1733898,"avatar_url":"https://avatars.githubusercontent.com/u/1733898?v=2","gravatar_id":"","url":"https://api.github.com/users/sharetribe","html_url":"https://github.com/sharetribe","followers_url":"https://api.github.com/users/sharetribe/followers","following_url":"https://api.github.com/users/sharetribe/following{/other_user}","gists_url":"https://api.github.com/users/sharetribe/gists{/gist_id}","starred_url":"https://api.github.com/users/sharetribe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharetribe/subscriptions","organizations_url":"https://api.github.com/users/sharetribe/orgs","repos_url":"https://api.github.com/users/sharetribe/repos","events_url":"https://api.github.com/users/sharetribe/events{/privacy}","received_events_url":"https://api.github.com/users/sharetribe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sharetribe/sharetribe","description":"Sharetribe is a platform for setting up your own peer-to-peer marketplace online. It's a Ruby on Rails based marketplace CMS. There's also a possibility to set up a hosted marketplace at https://www.sharetribe.com.","fork":false,"url":"https://api.github.com/repos/sharetribe/sharetribe","forks_url":"https://api.github.com/repos/sharetribe/sharetribe/forks","keys_url":"https://api.github.com/repos/sharetribe/sharetribe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sharetribe/sharetribe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sharetribe/sharetribe/teams","hooks_url":"https://api.github.com/repos/sharetribe/sharetribe/hooks","issue_events_url":"https://api.github.com/repos/sharetribe/sharetribe/issues/events{/number}","events_url":"https://api.github.com/repos/sharetribe/sharetribe/events","assignees_url":"https://api.github.com/repos/sharetribe/sharetribe/assignees{/user}","branches_url":"https://api.github.com/repos/sharetribe/sharetribe/branches{/branch}","tags_url":"https://api.github.com/repos/sharetribe/sharetribe/tags","blobs_url":"https://api.github.com/repos/sharetribe/sharetribe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sharetribe/sharetribe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sharetribe/sharetribe/git/refs{/sha}","trees_url":"https://api.github.com/repos/sharetribe/sharetribe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sharetribe/sharetribe/statuses/{sha}","languages_url":"https://api.github.com/repos/sharetribe/sharetribe/languages","stargazers_url":"https://api.github.com/repos/sharetribe/sharetribe/stargazers","contributors_url":"https://api.github.com/repos/sharetribe/sharetribe/contributors","subscribers_url":"https://api.github.com/repos/sharetribe/sharetribe/subscribers","subscription_url":"https://api.github.com/repos/sharetribe/sharetribe/subscription","commits_url":"https://api.github.com/repos/sharetribe/sharetribe/commits{/sha}","git_commits_url":"https://api.github.com/repos/sharetribe/sharetribe/git/commits{/sha}","comments_url":"https://api.github.com/repos/sharetribe/sharetribe/comments{/number}","issue_comment_url":"https://api.github.com/repos/sharetribe/sharetribe/issues/comments/{number}","contents_url":"https://api.github.com/repos/sharetribe/sharetribe/contents/{+path}","compare_url":"https://api.github.com/repos/sharetribe/sharetribe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sharetribe/sharetribe/merges","archive_url":"https://api.github.com/repos/sharetribe/sharetribe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sharetribe/sharetribe/downloads","issues_url":"https://api.github.com/repos/sharetribe/sharetribe/issues{/number}","pulls_url":"https://api.github.com/repos/sharetribe/sharetribe/pulls{/number}","milestones_url":"https://api.github.com/repos/sharetribe/sharetribe/milestones{/number}","notifications_url":"https://api.github.com/repos/sharetribe/sharetribe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sharetribe/sharetribe/labels{/name}","releases_url":"https://api.github.com/repos/sharetribe/sharetribe/releases{/id}","created_at":"2012-05-25T15:34:17Z","updated_at":"2014-09-30T16:05:04Z","pushed_at":"2014-10-01T11:17:26Z","git_url":"git://github.com/sharetribe/sharetribe.git","ssh_url":"git@github.com:sharetribe/sharetribe.git","clone_url":"https://github.com/sharetribe/sharetribe.git","svn_url":"https://github.com/sharetribe/sharetribe","homepage":"https://www.sharetribe.com","size":85008,"stargazers_count":116,"watchers_count":116,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":83,"mirror_url":null,"open_issues_count":15,"forks":83,"open_issues":15,"watchers":116,"default_branch":"master"}},"base":{"label":"sharetribe:master","ref":"master","sha":"22b27b82fba78598cf664128866a49a66df3f43a","user":{"login":"sharetribe","id":1733898,"avatar_url":"https://avatars.githubusercontent.com/u/1733898?v=2","gravatar_id":"","url":"https://api.github.com/users/sharetribe","html_url":"https://github.com/sharetribe","followers_url":"https://api.github.com/users/sharetribe/followers","following_url":"https://api.github.com/users/sharetribe/following{/other_user}","gists_url":"https://api.github.com/users/sharetribe/gists{/gist_id}","starred_url":"https://api.github.com/users/sharetribe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharetribe/subscriptions","organizations_url":"https://api.github.com/users/sharetribe/orgs","repos_url":"https://api.github.com/users/sharetribe/repos","events_url":"https://api.github.com/users/sharetribe/events{/privacy}","received_events_url":"https://api.github.com/users/sharetribe/received_events","type":"Organization","site_admin":false},"repo":{"id":4447023,"name":"sharetribe","full_name":"sharetribe/sharetribe","owner":{"login":"sharetribe","id":1733898,"avatar_url":"https://avatars.githubusercontent.com/u/1733898?v=2","gravatar_id":"","url":"https://api.github.com/users/sharetribe","html_url":"https://github.com/sharetribe","followers_url":"https://api.github.com/users/sharetribe/followers","following_url":"https://api.github.com/users/sharetribe/following{/other_user}","gists_url":"https://api.github.com/users/sharetribe/gists{/gist_id}","starred_url":"https://api.github.com/users/sharetribe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharetribe/subscriptions","organizations_url":"https://api.github.com/users/sharetribe/orgs","repos_url":"https://api.github.com/users/sharetribe/repos","events_url":"https://api.github.com/users/sharetribe/events{/privacy}","received_events_url":"https://api.github.com/users/sharetribe/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sharetribe/sharetribe","description":"Sharetribe is a platform for setting up your own peer-to-peer marketplace online. It's a Ruby on Rails based marketplace CMS. There's also a possibility to set up a hosted marketplace at https://www.sharetribe.com.","fork":false,"url":"https://api.github.com/repos/sharetribe/sharetribe","forks_url":"https://api.github.com/repos/sharetribe/sharetribe/forks","keys_url":"https://api.github.com/repos/sharetribe/sharetribe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sharetribe/sharetribe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sharetribe/sharetribe/teams","hooks_url":"https://api.github.com/repos/sharetribe/sharetribe/hooks","issue_events_url":"https://api.github.com/repos/sharetribe/sharetribe/issues/events{/number}","events_url":"https://api.github.com/repos/sharetribe/sharetribe/events","assignees_url":"https://api.github.com/repos/sharetribe/sharetribe/assignees{/user}","branches_url":"https://api.github.com/repos/sharetribe/sharetribe/branches{/branch}","tags_url":"https://api.github.com/repos/sharetribe/sharetribe/tags","blobs_url":"https://api.github.com/repos/sharetribe/sharetribe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sharetribe/sharetribe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sharetribe/sharetribe/git/refs{/sha}","trees_url":"https://api.github.com/repos/sharetribe/sharetribe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sharetribe/sharetribe/statuses/{sha}","languages_url":"https://api.github.com/repos/sharetribe/sharetribe/languages","stargazers_url":"https://api.github.com/repos/sharetribe/sharetribe/stargazers","contributors_url":"https://api.github.com/repos/sharetribe/sharetribe/contributors","subscribers_url":"https://api.github.com/repos/sharetribe/sharetribe/subscribers","subscription_url":"https://api.github.com/repos/sharetribe/sharetribe/subscription","commits_url":"https://api.github.com/repos/sharetribe/sharetribe/commits{/sha}","git_commits_url":"https://api.github.com/repos/sharetribe/sharetribe/git/commits{/sha}","comments_url":"https://api.github.com/repos/sharetribe/sharetribe/comments{/number}","issue_comment_url":"https://api.github.com/repos/sharetribe/sharetribe/issues/comments/{number}","contents_url":"https://api.github.com/repos/sharetribe/sharetribe/contents/{+path}","compare_url":"https://api.github.com/repos/sharetribe/sharetribe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sharetribe/sharetribe/merges","archive_url":"https://api.github.com/repos/sharetribe/sharetribe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sharetribe/sharetribe/downloads","issues_url":"https://api.github.com/repos/sharetribe/sharetribe/issues{/number}","pulls_url":"https://api.github.com/repos/sharetribe/sharetribe/pulls{/number}","milestones_url":"https://api.github.com/repos/sharetribe/sharetribe/milestones{/number}","notifications_url":"https://api.github.com/repos/sharetribe/sharetribe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sharetribe/sharetribe/labels{/name}","releases_url":"https://api.github.com/repos/sharetribe/sharetribe/releases{/id}","created_at":"2012-05-25T15:34:17Z","updated_at":"2014-09-30T16:05:04Z","pushed_at":"2014-10-01T11:17:26Z","git_url":"git://github.com/sharetribe/sharetribe.git","ssh_url":"git@github.com:sharetribe/sharetribe.git","clone_url":"https://github.com/sharetribe/sharetribe.git","svn_url":"https://github.com/sharetribe/sharetribe","homepage":"https://www.sharetribe.com","size":85008,"stargazers_count":116,"watchers_count":116,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":83,"mirror_url":null,"open_issues_count":15,"forks":83,"open_issues":15,"watchers":116,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sharetribe/sharetribe/pulls/614"},"html":{"href":"https://github.com/sharetribe/sharetribe/pull/614"},"issue":{"href":"https://api.github.com/repos/sharetribe/sharetribe/issues/614"},"comments":{"href":"https://api.github.com/repos/sharetribe/sharetribe/issues/614/comments"},"review_comments":{"href":"https://api.github.com/repos/sharetribe/sharetribe/pulls/614/comments"},"review_comment":{"href":"https://api.github.com/repos/sharetribe/sharetribe/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/sharetribe/sharetribe/pulls/614/commits"},"statuses":{"href":"https://api.github.com/repos/sharetribe/sharetribe/statuses/46672f748aa95127d3184eefba481c5bf03279ad"}}}}