{"action":"created","comment":{"url":"https://api.github.com/repos/artsy/metaphysics/pulls/comments/59044280","id":59044280,"diff_hunk":"@@ -0,0 +1,151 @@\n+import gravity from '../../lib/loaders/gravity';\n+import {\n+  keys,\n+  map,\n+  sortBy,\n+  first,\n+  filter,\n+} from 'lodash';\n+import Artwork from '../artwork/index';\n+import {\n+  GraphQLList,\n+  GraphQLObjectType,\n+  GraphQLString,\n+} from 'graphql';\n+\n+const RESULTS_SIZE = 15;\n+\n+const featuredFair = () => {\n+  return gravity('fairs', { size: 5, status: 'running' }).then((fairs) => {\n+    if (fairs) {\n+      return first(sortBy(fairs, ({ banner_size }) =>\n+        ['x-large', 'large', 'medium', 'small', 'x-small'].indexOf(banner_size)\n+      ));\n+    }\n+  });\n+};\n+\n+const featuredAuction = () => {\n+  return gravity('sales', { live: true, size: 1 }).then((sales) => {\n+    if (sales) {\n+      return first(sales);\n+    }\n+  });\n+};\n+\n+const moduleTitle = {\n+  active_bids: () => 'Your Active Bids',\n+  followed_artists: () => 'Works by Artists you Follow',\n+  followed_galleries: () => 'Works from Galleries you Follow',\n+  saved_works: () => 'Recently Saved Works',\n+  recommended_works: () => 'Recommended Works for You',\n+  live_auctions: () => {\n+    return featuredAuction().then(({ name }) => {\n+      return `At auction: ${name}`;\n+    });\n+  },\n+  current_fairs: () => {\n+    return featuredFair().then(({ name }) => {\n+      return `Art Fair: ${name}`;\n+    });\n+  },\n+  related_artists: () => 'Works by Related Artists',\n+  genes: () => 'Works from Gene you Follow',\n+};\n+\n+const moduleResults = {\n+  active_bids: () => [],\n+  followed_artists: (accessToken) => {\n+    return gravity\n+      .with(accessToken)('me/follow/artists/artworks', {\n+        for_sale: true,\n+        size: RESULTS_SIZE,\n+      });\n+  },\n+  followed_galleries: (accessToken) => {\n+    return gravity.with(accessToken)('me/follow/profiles/artworks', {\n+      for_sale: true,\n+      size: RESULTS_SIZE,\n+    });\n+  },\n+  saved_works: (accessToken) => {\n+    return gravity.with(accessToken)('me').then((user) => {\n+      return gravity\n+        .with(accessToken)('collection/saved-artwork/artworks', {\n+          size: RESULTS_SIZE,\n+          user_id: user.id,\n+        });\n+    }).catch(() => {});\n+  },\n+  recommended_works: (accessToken) => {\n+    return gravity.with(accessToken)('me/suggested/artworks/homepage', { limit: RESULTS_SIZE });\n+  },\n+  live_auctions: () => {\n+    return featuredAuction().then(({ id }) => {\n+      return gravity(`sale/${id}/sale_artworks`, { size: RESULTS_SIZE });\n+    });\n+  },\n+  current_fairs: () => {\n+    return featuredFair().then(({ id }) => {\n+      return gravity('filter/artworks', {\n+        fair_id: id,\n+        for_sale: true,\n+        size: RESULTS_SIZE,\n+      }).then(({ hits }) => hits);\n+    });\n+  },\n+  related_artists: () => [],\n+  genes: () => [],\n+};","path":"schema/me/home_page_modules.js","position":99,"original_position":99,"commit_id":"46402bb0a96f0a877b26cc88efa722724867b6b2","original_commit_id":"46402bb0a96f0a877b26cc88efa722724867b6b2","user":{"login":"dzucconi","id":112297,"avatar_url":"https://avatars.githubusercontent.com/u/112297?v=3","gravatar_id":"","url":"https://api.github.com/users/dzucconi","html_url":"https://github.com/dzucconi","followers_url":"https://api.github.com/users/dzucconi/followers","following_url":"https://api.github.com/users/dzucconi/following{/other_user}","gists_url":"https://api.github.com/users/dzucconi/gists{/gist_id}","starred_url":"https://api.github.com/users/dzucconi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzucconi/subscriptions","organizations_url":"https://api.github.com/users/dzucconi/orgs","repos_url":"https://api.github.com/users/dzucconi/repos","events_url":"https://api.github.com/users/dzucconi/events{/privacy}","received_events_url":"https://api.github.com/users/dzucconi/received_events","type":"User","site_admin":false},"body":"I'd consider writing these like:\r\n```\r\nconst modules = {\r\n  my_key: {\r\n    title: () => {},\r\n    fetch: () => {},\r\n  }\r\n};\r\n```\r\n\r\nThough I second @alloy's point—maybe the titles don't need to be returned anyway","created_at":"2016-04-08T15:37:29Z","updated_at":"2016-04-08T15:37:29Z","html_url":"https://github.com/artsy/metaphysics/pull/184#discussion_r59044280","pull_request_url":"https://api.github.com/repos/artsy/metaphysics/pulls/184","_links":{"self":{"href":"https://api.github.com/repos/artsy/metaphysics/pulls/comments/59044280"},"html":{"href":"https://github.com/artsy/metaphysics/pull/184#discussion_r59044280"},"pull_request":{"href":"https://api.github.com/repos/artsy/metaphysics/pulls/184"}}},"pull_request":{"url":"https://api.github.com/repos/artsy/metaphysics/pulls/184","id":65705692,"html_url":"https://github.com/artsy/metaphysics/pull/184","diff_url":"https://github.com/artsy/metaphysics/pull/184.diff","patch_url":"https://github.com/artsy/metaphysics/pull/184.patch","issue_url":"https://api.github.com/repos/artsy/metaphysics/issues/184","number":184,"state":"open","locked":false,"title":"@dzucconi - [WIP] home page modules (rails)","user":{"login":"broskoski","id":821469,"avatar_url":"https://avatars.githubusercontent.com/u/821469?v=3","gravatar_id":"","url":"https://api.github.com/users/broskoski","html_url":"https://github.com/broskoski","followers_url":"https://api.github.com/users/broskoski/followers","following_url":"https://api.github.com/users/broskoski/following{/other_user}","gists_url":"https://api.github.com/users/broskoski/gists{/gist_id}","starred_url":"https://api.github.com/users/broskoski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broskoski/subscriptions","organizations_url":"https://api.github.com/users/broskoski/orgs","repos_url":"https://api.github.com/users/broskoski/repos","events_url":"https://api.github.com/users/broskoski/events{/privacy}","received_events_url":"https://api.github.com/users/broskoski/received_events","type":"User","site_admin":false},"body":"cc @alloy @mzikherman \r\n\r\nStill working on this but want to keep some feedback before I get too deep in. \r\n\r\nMy current thinking is:\r\n\r\n### 1. On initial load\r\n\r\n```\r\nquery {\r\n  me{\r\n    id\r\n    home_page_modules{\r\n      key\r\n      display\r\n      title\r\n    }\r\n  }\r\n}\r\n```\r\n(would return something like):\r\n\r\n```\r\n{\r\n  \"data\": {\r\n    \"me\": {\r\n      \"id\": \"547e891d7261691220dc0000\",\r\n      \"home_page_modules\": [\r\n        {\r\n          \"key\": \"followed_artists\",\r\n          \"display\": \"true\",\r\n          \"title\": \"Works by Artists you Follow\"\r\n        },\r\n        {\r\n          \"key\": \"followed_galleries\",\r\n          \"display\": \"true\",\r\n          \"title\": \"Works from Galleries you Follow\"\r\n        },\r\n        {\r\n          \"key\": \"saved_works\",\r\n          \"display\": \"true\",\r\n          \"title\": \"Recently Saved Works\"\r\n        },\r\n        {\r\n          \"key\": \"recommended_works\",\r\n          \"display\": \"true\",\r\n          \"title\": \"Recommended Works for You\"\r\n        },\r\n        {\r\n          \"key\": \"live_auctions\",\r\n          \"display\": \"true\",\r\n          \"title\": \"At auction: Art in General: Benefit Auction 2016\"\r\n        },\r\n        {\r\n          \"key\": \"current_fairs\",\r\n          \"display\": \"true\",\r\n          \"title\": \"Art Fair: SP-Arte 2016\"\r\n        },\r\n        {\r\n          \"key\": \"related_artists\",\r\n          \"display\": \"true\",\r\n          \"title\": \"Works by Related Artists\"\r\n        }\r\n      ]\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### 2. Then client side, for each key returned: \r\n\r\n```\r\nquery {\r\n  me{\r\n    id\r\n    home_page_modules(include_keys: [\"recommended_works\"]){\r\n      results{\r\n        id\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nThis way, each rail has all the information it needs to render itself.\r\n\r\nThere's some weird things about this implementation (most obviously, passing the `accessToken` around), so feel free to let me know where things are non-optimal.\r\n\r\n","created_at":"2016-04-07T21:49:08Z","updated_at":"2016-04-08T15:37:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0cddebbd00f2aaf72eb637b524f5b19e495108d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/artsy/metaphysics/pulls/184/commits","review_comments_url":"https://api.github.com/repos/artsy/metaphysics/pulls/184/comments","review_comment_url":"https://api.github.com/repos/artsy/metaphysics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/artsy/metaphysics/issues/184/comments","statuses_url":"https://api.github.com/repos/artsy/metaphysics/statuses/46402bb0a96f0a877b26cc88efa722724867b6b2","head":{"label":"broskoski:home-page-modules","ref":"home-page-modules","sha":"46402bb0a96f0a877b26cc88efa722724867b6b2","user":{"login":"broskoski","id":821469,"avatar_url":"https://avatars.githubusercontent.com/u/821469?v=3","gravatar_id":"","url":"https://api.github.com/users/broskoski","html_url":"https://github.com/broskoski","followers_url":"https://api.github.com/users/broskoski/followers","following_url":"https://api.github.com/users/broskoski/following{/other_user}","gists_url":"https://api.github.com/users/broskoski/gists{/gist_id}","starred_url":"https://api.github.com/users/broskoski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broskoski/subscriptions","organizations_url":"https://api.github.com/users/broskoski/orgs","repos_url":"https://api.github.com/users/broskoski/repos","events_url":"https://api.github.com/users/broskoski/events{/privacy}","received_events_url":"https://api.github.com/users/broskoski/received_events","type":"User","site_admin":false},"repo":{"id":47644047,"name":"metaphysics","full_name":"broskoski/metaphysics","owner":{"login":"broskoski","id":821469,"avatar_url":"https://avatars.githubusercontent.com/u/821469?v=3","gravatar_id":"","url":"https://api.github.com/users/broskoski","html_url":"https://github.com/broskoski","followers_url":"https://api.github.com/users/broskoski/followers","following_url":"https://api.github.com/users/broskoski/following{/other_user}","gists_url":"https://api.github.com/users/broskoski/gists{/gist_id}","starred_url":"https://api.github.com/users/broskoski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broskoski/subscriptions","organizations_url":"https://api.github.com/users/broskoski/orgs","repos_url":"https://api.github.com/users/broskoski/repos","events_url":"https://api.github.com/users/broskoski/events{/privacy}","received_events_url":"https://api.github.com/users/broskoski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/broskoski/metaphysics","description":"Artsy's GraphQL API","fork":true,"url":"https://api.github.com/repos/broskoski/metaphysics","forks_url":"https://api.github.com/repos/broskoski/metaphysics/forks","keys_url":"https://api.github.com/repos/broskoski/metaphysics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/broskoski/metaphysics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/broskoski/metaphysics/teams","hooks_url":"https://api.github.com/repos/broskoski/metaphysics/hooks","issue_events_url":"https://api.github.com/repos/broskoski/metaphysics/issues/events{/number}","events_url":"https://api.github.com/repos/broskoski/metaphysics/events","assignees_url":"https://api.github.com/repos/broskoski/metaphysics/assignees{/user}","branches_url":"https://api.github.com/repos/broskoski/metaphysics/branches{/branch}","tags_url":"https://api.github.com/repos/broskoski/metaphysics/tags","blobs_url":"https://api.github.com/repos/broskoski/metaphysics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/broskoski/metaphysics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/broskoski/metaphysics/git/refs{/sha}","trees_url":"https://api.github.com/repos/broskoski/metaphysics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/broskoski/metaphysics/statuses/{sha}","languages_url":"https://api.github.com/repos/broskoski/metaphysics/languages","stargazers_url":"https://api.github.com/repos/broskoski/metaphysics/stargazers","contributors_url":"https://api.github.com/repos/broskoski/metaphysics/contributors","subscribers_url":"https://api.github.com/repos/broskoski/metaphysics/subscribers","subscription_url":"https://api.github.com/repos/broskoski/metaphysics/subscription","commits_url":"https://api.github.com/repos/broskoski/metaphysics/commits{/sha}","git_commits_url":"https://api.github.com/repos/broskoski/metaphysics/git/commits{/sha}","comments_url":"https://api.github.com/repos/broskoski/metaphysics/comments{/number}","issue_comment_url":"https://api.github.com/repos/broskoski/metaphysics/issues/comments{/number}","contents_url":"https://api.github.com/repos/broskoski/metaphysics/contents/{+path}","compare_url":"https://api.github.com/repos/broskoski/metaphysics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/broskoski/metaphysics/merges","archive_url":"https://api.github.com/repos/broskoski/metaphysics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/broskoski/metaphysics/downloads","issues_url":"https://api.github.com/repos/broskoski/metaphysics/issues{/number}","pulls_url":"https://api.github.com/repos/broskoski/metaphysics/pulls{/number}","milestones_url":"https://api.github.com/repos/broskoski/metaphysics/milestones{/number}","notifications_url":"https://api.github.com/repos/broskoski/metaphysics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/broskoski/metaphysics/labels{/name}","releases_url":"https://api.github.com/repos/broskoski/metaphysics/releases{/id}","deployments_url":"https://api.github.com/repos/broskoski/metaphysics/deployments","created_at":"2015-12-08T19:22:54Z","updated_at":"2016-01-15T17:06:04Z","pushed_at":"2016-04-07T22:08:25Z","git_url":"git://github.com/broskoski/metaphysics.git","ssh_url":"git@github.com:broskoski/metaphysics.git","clone_url":"https://github.com/broskoski/metaphysics.git","svn_url":"https://github.com/broskoski/metaphysics","homepage":"","size":374,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"artsy:master","ref":"master","sha":"c9a7110ceddd6bf832f9fc6b9ca419cd97a32efe","user":{"login":"artsy","id":546231,"avatar_url":"https://avatars.githubusercontent.com/u/546231?v=3","gravatar_id":"","url":"https://api.github.com/users/artsy","html_url":"https://github.com/artsy","followers_url":"https://api.github.com/users/artsy/followers","following_url":"https://api.github.com/users/artsy/following{/other_user}","gists_url":"https://api.github.com/users/artsy/gists{/gist_id}","starred_url":"https://api.github.com/users/artsy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artsy/subscriptions","organizations_url":"https://api.github.com/users/artsy/orgs","repos_url":"https://api.github.com/users/artsy/repos","events_url":"https://api.github.com/users/artsy/events{/privacy}","received_events_url":"https://api.github.com/users/artsy/received_events","type":"Organization","site_admin":false},"repo":{"id":42728510,"name":"metaphysics","full_name":"artsy/metaphysics","owner":{"login":"artsy","id":546231,"avatar_url":"https://avatars.githubusercontent.com/u/546231?v=3","gravatar_id":"","url":"https://api.github.com/users/artsy","html_url":"https://github.com/artsy","followers_url":"https://api.github.com/users/artsy/followers","following_url":"https://api.github.com/users/artsy/following{/other_user}","gists_url":"https://api.github.com/users/artsy/gists{/gist_id}","starred_url":"https://api.github.com/users/artsy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artsy/subscriptions","organizations_url":"https://api.github.com/users/artsy/orgs","repos_url":"https://api.github.com/users/artsy/repos","events_url":"https://api.github.com/users/artsy/events{/privacy}","received_events_url":"https://api.github.com/users/artsy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/artsy/metaphysics","description":"Artsy's GraphQL API","fork":false,"url":"https://api.github.com/repos/artsy/metaphysics","forks_url":"https://api.github.com/repos/artsy/metaphysics/forks","keys_url":"https://api.github.com/repos/artsy/metaphysics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/artsy/metaphysics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/artsy/metaphysics/teams","hooks_url":"https://api.github.com/repos/artsy/metaphysics/hooks","issue_events_url":"https://api.github.com/repos/artsy/metaphysics/issues/events{/number}","events_url":"https://api.github.com/repos/artsy/metaphysics/events","assignees_url":"https://api.github.com/repos/artsy/metaphysics/assignees{/user}","branches_url":"https://api.github.com/repos/artsy/metaphysics/branches{/branch}","tags_url":"https://api.github.com/repos/artsy/metaphysics/tags","blobs_url":"https://api.github.com/repos/artsy/metaphysics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/artsy/metaphysics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/artsy/metaphysics/git/refs{/sha}","trees_url":"https://api.github.com/repos/artsy/metaphysics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/artsy/metaphysics/statuses/{sha}","languages_url":"https://api.github.com/repos/artsy/metaphysics/languages","stargazers_url":"https://api.github.com/repos/artsy/metaphysics/stargazers","contributors_url":"https://api.github.com/repos/artsy/metaphysics/contributors","subscribers_url":"https://api.github.com/repos/artsy/metaphysics/subscribers","subscription_url":"https://api.github.com/repos/artsy/metaphysics/subscription","commits_url":"https://api.github.com/repos/artsy/metaphysics/commits{/sha}","git_commits_url":"https://api.github.com/repos/artsy/metaphysics/git/commits{/sha}","comments_url":"https://api.github.com/repos/artsy/metaphysics/comments{/number}","issue_comment_url":"https://api.github.com/repos/artsy/metaphysics/issues/comments{/number}","contents_url":"https://api.github.com/repos/artsy/metaphysics/contents/{+path}","compare_url":"https://api.github.com/repos/artsy/metaphysics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/artsy/metaphysics/merges","archive_url":"https://api.github.com/repos/artsy/metaphysics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/artsy/metaphysics/downloads","issues_url":"https://api.github.com/repos/artsy/metaphysics/issues{/number}","pulls_url":"https://api.github.com/repos/artsy/metaphysics/pulls{/number}","milestones_url":"https://api.github.com/repos/artsy/metaphysics/milestones{/number}","notifications_url":"https://api.github.com/repos/artsy/metaphysics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/artsy/metaphysics/labels{/name}","releases_url":"https://api.github.com/repos/artsy/metaphysics/releases{/id}","deployments_url":"https://api.github.com/repos/artsy/metaphysics/deployments","created_at":"2015-09-18T14:51:48Z","updated_at":"2016-03-30T16:58:54Z","pushed_at":"2016-04-07T22:08:25Z","git_url":"git://github.com/artsy/metaphysics.git","ssh_url":"git@github.com:artsy/metaphysics.git","clone_url":"https://github.com/artsy/metaphysics.git","svn_url":"https://github.com/artsy/metaphysics","homepage":"","size":404,"stargazers_count":24,"watchers_count":24,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":13,"forks":10,"open_issues":13,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/artsy/metaphysics/pulls/184"},"html":{"href":"https://github.com/artsy/metaphysics/pull/184"},"issue":{"href":"https://api.github.com/repos/artsy/metaphysics/issues/184"},"comments":{"href":"https://api.github.com/repos/artsy/metaphysics/issues/184/comments"},"review_comments":{"href":"https://api.github.com/repos/artsy/metaphysics/pulls/184/comments"},"review_comment":{"href":"https://api.github.com/repos/artsy/metaphysics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/artsy/metaphysics/pulls/184/commits"},"statuses":{"href":"https://api.github.com/repos/artsy/metaphysics/statuses/46402bb0a96f0a877b26cc88efa722724867b6b2"}}}}