{"action":"created","comment":{"url":"https://api.github.com/repos/Chorus/chorus/pulls/comments/40984142","id":40984142,"diff_hunk":"@@ -0,0 +1,59 @@\n+class ChiasmApiDatasetsController < ApplicationController\n+  include DataSourceAuth\n+\n+  # Returns the column metadata in this form:\n+  # [{ 'name': 'age',          'type': 'number'},\n+  #  { 'name': 'capital_gain', 'type': 'number'},\n+  #  { 'name': 'capital_loss', 'type': 'number'}]\n+  def show_column_data\n+    dataset = Dataset.find(params[:dataset_id])\n+\n+    column_types_map = [\n+        {:chorus_type => /integer/, :chiasm_type => 'number'},\n+        {:chorus_type => /varying/, :chiasm_type => 'string'}\n+    ]\n+\n+    column_data = dataset.column_data.sort_by { |col| col.name }.collect { |col|\n+      convert_chorus_to_chiasm_type = column_types_map.find { |h| h[:chorus_type].match col.data_type }\n+      chiasm_type = convert_chorus_to_chiasm_type[:chiasm_type]\n+\n+      {name: col.name, type: chiasm_type}\n+    }\n+\n+    render :json => column_data\n+  end\n+\n+  # Returns the data itself, in CSV form:\n+  # sepal_length,sepal_width,petal_length,petal_width,class\n+  # 5.1,3.5,1.4,0.2,setosa\n+  # 4.9,3.0,1.4,0.2,setosa\n+  def show_data\n+    dataset = Dataset.find(params[:dataset_id])\n+\n+    # TODO Curran / Mike Souza: pass 'check_id' in from Backbone ...\n+    check_id = rand(0..1000000)\n+\n+    @connection = dataset.connect_with(authorized_account(dataset))\n+    @sql_generator = @connection.visualization_sql_generator\n+\n+    # TODO Curran / Michael Thyen -- passing in :foo so we have the option to pass multiple named options,\n+    # otherwise we can clean it up (just pass dataset)\n+    row_sql = @sql_generator.random_sampling_sql(:dataset => dataset, :foo => 'bar')\n+\n+    # TODO Curran / Mike Souza see VisLegacy -> VisualizationsController#destroy -- the query must be cancellable for\n+    # a reason, we will probably need to wire up something equivalent, passing the 'check_id' along\n+    # as a key for the cancelling of query.\n+    result = CancelableQuery.new(@connection, check_id, current_user).execute(row_sql)","path":"components/vis_chiasm/app/controllers/chiasm_api_datasets_controller.rb","position":46,"original_position":46,"commit_id":"d73fd53cdf395aba950d8925cc7a9aae4d5874d4","original_commit_id":"d73fd53cdf395aba950d8925cc7a9aae4d5874d4","user":{"login":"kevin-alpine","id":12001313,"avatar_url":"https://avatars.githubusercontent.com/u/12001313?v=3","gravatar_id":"","url":"https://api.github.com/users/kevin-alpine","html_url":"https://github.com/kevin-alpine","followers_url":"https://api.github.com/users/kevin-alpine/followers","following_url":"https://api.github.com/users/kevin-alpine/following{/other_user}","gists_url":"https://api.github.com/users/kevin-alpine/gists{/gist_id}","starred_url":"https://api.github.com/users/kevin-alpine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevin-alpine/subscriptions","organizations_url":"https://api.github.com/users/kevin-alpine/orgs","repos_url":"https://api.github.com/users/kevin-alpine/repos","events_url":"https://api.github.com/users/kevin-alpine/events{/privacy}","received_events_url":"https://api.github.com/users/kevin-alpine/received_events","type":"User","site_admin":false},"body":"@curran, @midnighteuler, @mthyen note this method: it's the heart of the 'random_sampling' api ... I put some notes inline for you guys.","created_at":"2015-10-02T01:01:11Z","updated_at":"2015-10-02T01:01:11Z","html_url":"https://github.com/Chorus/chorus/pull/173#discussion_r40984142","pull_request_url":"https://api.github.com/repos/Chorus/chorus/pulls/173","_links":{"self":{"href":"https://api.github.com/repos/Chorus/chorus/pulls/comments/40984142"},"html":{"href":"https://github.com/Chorus/chorus/pull/173#discussion_r40984142"},"pull_request":{"href":"https://api.github.com/repos/Chorus/chorus/pulls/173"}}},"pull_request":{"url":"https://api.github.com/repos/Chorus/chorus/pulls/173","id":46594241,"html_url":"https://github.com/Chorus/chorus/pull/173","diff_url":"https://github.com/Chorus/chorus/pull/173.diff","patch_url":"https://github.com/Chorus/chorus/pull/173.patch","issue_url":"https://api.github.com/repos/Chorus/chorus/issues/173","number":173,"state":"open","locked":false,"title":"Making VisChiasm work (REVIEW 4th, MERGE 1st)","user":{"login":"kevin-alpine","id":12001313,"avatar_url":"https://avatars.githubusercontent.com/u/12001313?v=3","gravatar_id":"","url":"https://api.github.com/users/kevin-alpine","html_url":"https://github.com/kevin-alpine","followers_url":"https://api.github.com/users/kevin-alpine/followers","following_url":"https://api.github.com/users/kevin-alpine/following{/other_user}","gists_url":"https://api.github.com/users/kevin-alpine/gists{/gist_id}","starred_url":"https://api.github.com/users/kevin-alpine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevin-alpine/subscriptions","organizations_url":"https://api.github.com/users/kevin-alpine/orgs","repos_url":"https://api.github.com/users/kevin-alpine/repos","events_url":"https://api.github.com/users/kevin-alpine/events{/privacy}","received_events_url":"https://api.github.com/users/kevin-alpine/received_events","type":"User","site_admin":false},"body":"In this PR I add two APIs that will return the data that Curran needs ... you can access them at these two URLs:\r\nhttp://localhost:3000/datasets/62270/chiasm_api_datasets/show_data\r\nhttp://localhost:3000/datasets/62270/chiasm_api_datasets/show_column_data\r\n_... where 62270 is a dataset ID._\r\n\r\nI also catch the VisChiasm component up to where the integration that @midnighteuler & @curran  were working on in master, is at ... (I copied over the work that was in master, into the VisChiasm component.)\r\n\r\nNow that we have sorted out the files that are concerned with Visualization, we can see that a lot of the Backbone code is broken right now in this component.  I went through and added TODOs and comments asking @curran  & @midnighteuler to adapt the code to be useful again or to delete it.\r\n\r\nIn the guts of the Rails sever-side query generating code, I deleted a lot of the files which had to do with \"presentation specific\" database queries ... and just replaced this with a 'random_sample' query method ... for @mthyen to fill in.  (I have removed all the \"models\" and \"presenters\" and it's all done very simply (for now) inline in the controller.)\r\n\r\nBy looking through this PR we can now see:\r\n* Where to put the random_sampling database-specific queries.\r\n* What backbone files are involved with visualizations and how they're broken now ...\r\n\r\nAdditionally since we still have the VisLegacy component which will not be altered, we can delete and munge this code as much as we like and, if it all goes south, we can just switch back to using the VisLegacy component and take time we need to make VisChiasm good.\r\n\r\nI will discuss this work with @curran, @midnighteuler, and @mthyen tomorrow when I am back in the office.","created_at":"2015-10-02T00:55:12Z","updated_at":"2015-10-02T01:01:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ae8d23700e34cee3abae9471101ea31a0bfb0d70","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Chorus/chorus/pulls/173/commits","review_comments_url":"https://api.github.com/repos/Chorus/chorus/pulls/173/comments","review_comment_url":"https://api.github.com/repos/Chorus/chorus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Chorus/chorus/issues/173/comments","statuses_url":"https://api.github.com/repos/Chorus/chorus/statuses/d73fd53cdf395aba950d8925cc7a9aae4d5874d4","head":{"label":"Chorus:vis_chiasm","ref":"vis_chiasm","sha":"d73fd53cdf395aba950d8925cc7a9aae4d5874d4","user":{"login":"Chorus","id":5614676,"avatar_url":"https://avatars.githubusercontent.com/u/5614676?v=3","gravatar_id":"","url":"https://api.github.com/users/Chorus","html_url":"https://github.com/Chorus","followers_url":"https://api.github.com/users/Chorus/followers","following_url":"https://api.github.com/users/Chorus/following{/other_user}","gists_url":"https://api.github.com/users/Chorus/gists{/gist_id}","starred_url":"https://api.github.com/users/Chorus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chorus/subscriptions","organizations_url":"https://api.github.com/users/Chorus/orgs","repos_url":"https://api.github.com/users/Chorus/repos","events_url":"https://api.github.com/users/Chorus/events{/privacy}","received_events_url":"https://api.github.com/users/Chorus/received_events","type":"Organization","site_admin":false},"repo":{"id":2751440,"name":"chorus","full_name":"Chorus/chorus","owner":{"login":"Chorus","id":5614676,"avatar_url":"https://avatars.githubusercontent.com/u/5614676?v=3","gravatar_id":"","url":"https://api.github.com/users/Chorus","html_url":"https://github.com/Chorus","followers_url":"https://api.github.com/users/Chorus/followers","following_url":"https://api.github.com/users/Chorus/following{/other_user}","gists_url":"https://api.github.com/users/Chorus/gists{/gist_id}","starred_url":"https://api.github.com/users/Chorus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chorus/subscriptions","organizations_url":"https://api.github.com/users/Chorus/orgs","repos_url":"https://api.github.com/users/Chorus/repos","events_url":"https://api.github.com/users/Chorus/events{/privacy}","received_events_url":"https://api.github.com/users/Chorus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Chorus/chorus","description":"Chorus allows customers, partners, developers, and data scientists to collaboratively realize the potential of Big Data.","fork":false,"url":"https://api.github.com/repos/Chorus/chorus","forks_url":"https://api.github.com/repos/Chorus/chorus/forks","keys_url":"https://api.github.com/repos/Chorus/chorus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Chorus/chorus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Chorus/chorus/teams","hooks_url":"https://api.github.com/repos/Chorus/chorus/hooks","issue_events_url":"https://api.github.com/repos/Chorus/chorus/issues/events{/number}","events_url":"https://api.github.com/repos/Chorus/chorus/events","assignees_url":"https://api.github.com/repos/Chorus/chorus/assignees{/user}","branches_url":"https://api.github.com/repos/Chorus/chorus/branches{/branch}","tags_url":"https://api.github.com/repos/Chorus/chorus/tags","blobs_url":"https://api.github.com/repos/Chorus/chorus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Chorus/chorus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Chorus/chorus/git/refs{/sha}","trees_url":"https://api.github.com/repos/Chorus/chorus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Chorus/chorus/statuses/{sha}","languages_url":"https://api.github.com/repos/Chorus/chorus/languages","stargazers_url":"https://api.github.com/repos/Chorus/chorus/stargazers","contributors_url":"https://api.github.com/repos/Chorus/chorus/contributors","subscribers_url":"https://api.github.com/repos/Chorus/chorus/subscribers","subscription_url":"https://api.github.com/repos/Chorus/chorus/subscription","commits_url":"https://api.github.com/repos/Chorus/chorus/commits{/sha}","git_commits_url":"https://api.github.com/repos/Chorus/chorus/git/commits{/sha}","comments_url":"https://api.github.com/repos/Chorus/chorus/comments{/number}","issue_comment_url":"https://api.github.com/repos/Chorus/chorus/issues/comments{/number}","contents_url":"https://api.github.com/repos/Chorus/chorus/contents/{+path}","compare_url":"https://api.github.com/repos/Chorus/chorus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Chorus/chorus/merges","archive_url":"https://api.github.com/repos/Chorus/chorus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Chorus/chorus/downloads","issues_url":"https://api.github.com/repos/Chorus/chorus/issues{/number}","pulls_url":"https://api.github.com/repos/Chorus/chorus/pulls{/number}","milestones_url":"https://api.github.com/repos/Chorus/chorus/milestones{/number}","notifications_url":"https://api.github.com/repos/Chorus/chorus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Chorus/chorus/labels{/name}","releases_url":"https://api.github.com/repos/Chorus/chorus/releases{/id}","created_at":"2011-11-10T20:30:13Z","updated_at":"2015-09-16T10:39:46Z","pushed_at":"2015-10-02T00:55:12Z","git_url":"git://github.com/Chorus/chorus.git","ssh_url":"git@github.com:Chorus/chorus.git","clone_url":"https://github.com/Chorus/chorus.git","svn_url":"https://github.com/Chorus/chorus","homepage":"","size":859965,"stargazers_count":160,"watchers_count":160,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":69,"mirror_url":null,"open_issues_count":15,"forks":69,"open_issues":15,"watchers":160,"default_branch":"master"}},"base":{"label":"Chorus:vis_chiasm_copy_step","ref":"vis_chiasm_copy_step","sha":"9538041690d50c69d9f941cd1f7bd58105d224d8","user":{"login":"Chorus","id":5614676,"avatar_url":"https://avatars.githubusercontent.com/u/5614676?v=3","gravatar_id":"","url":"https://api.github.com/users/Chorus","html_url":"https://github.com/Chorus","followers_url":"https://api.github.com/users/Chorus/followers","following_url":"https://api.github.com/users/Chorus/following{/other_user}","gists_url":"https://api.github.com/users/Chorus/gists{/gist_id}","starred_url":"https://api.github.com/users/Chorus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chorus/subscriptions","organizations_url":"https://api.github.com/users/Chorus/orgs","repos_url":"https://api.github.com/users/Chorus/repos","events_url":"https://api.github.com/users/Chorus/events{/privacy}","received_events_url":"https://api.github.com/users/Chorus/received_events","type":"Organization","site_admin":false},"repo":{"id":2751440,"name":"chorus","full_name":"Chorus/chorus","owner":{"login":"Chorus","id":5614676,"avatar_url":"https://avatars.githubusercontent.com/u/5614676?v=3","gravatar_id":"","url":"https://api.github.com/users/Chorus","html_url":"https://github.com/Chorus","followers_url":"https://api.github.com/users/Chorus/followers","following_url":"https://api.github.com/users/Chorus/following{/other_user}","gists_url":"https://api.github.com/users/Chorus/gists{/gist_id}","starred_url":"https://api.github.com/users/Chorus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chorus/subscriptions","organizations_url":"https://api.github.com/users/Chorus/orgs","repos_url":"https://api.github.com/users/Chorus/repos","events_url":"https://api.github.com/users/Chorus/events{/privacy}","received_events_url":"https://api.github.com/users/Chorus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Chorus/chorus","description":"Chorus allows customers, partners, developers, and data scientists to collaboratively realize the potential of Big Data.","fork":false,"url":"https://api.github.com/repos/Chorus/chorus","forks_url":"https://api.github.com/repos/Chorus/chorus/forks","keys_url":"https://api.github.com/repos/Chorus/chorus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Chorus/chorus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Chorus/chorus/teams","hooks_url":"https://api.github.com/repos/Chorus/chorus/hooks","issue_events_url":"https://api.github.com/repos/Chorus/chorus/issues/events{/number}","events_url":"https://api.github.com/repos/Chorus/chorus/events","assignees_url":"https://api.github.com/repos/Chorus/chorus/assignees{/user}","branches_url":"https://api.github.com/repos/Chorus/chorus/branches{/branch}","tags_url":"https://api.github.com/repos/Chorus/chorus/tags","blobs_url":"https://api.github.com/repos/Chorus/chorus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Chorus/chorus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Chorus/chorus/git/refs{/sha}","trees_url":"https://api.github.com/repos/Chorus/chorus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Chorus/chorus/statuses/{sha}","languages_url":"https://api.github.com/repos/Chorus/chorus/languages","stargazers_url":"https://api.github.com/repos/Chorus/chorus/stargazers","contributors_url":"https://api.github.com/repos/Chorus/chorus/contributors","subscribers_url":"https://api.github.com/repos/Chorus/chorus/subscribers","subscription_url":"https://api.github.com/repos/Chorus/chorus/subscription","commits_url":"https://api.github.com/repos/Chorus/chorus/commits{/sha}","git_commits_url":"https://api.github.com/repos/Chorus/chorus/git/commits{/sha}","comments_url":"https://api.github.com/repos/Chorus/chorus/comments{/number}","issue_comment_url":"https://api.github.com/repos/Chorus/chorus/issues/comments{/number}","contents_url":"https://api.github.com/repos/Chorus/chorus/contents/{+path}","compare_url":"https://api.github.com/repos/Chorus/chorus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Chorus/chorus/merges","archive_url":"https://api.github.com/repos/Chorus/chorus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Chorus/chorus/downloads","issues_url":"https://api.github.com/repos/Chorus/chorus/issues{/number}","pulls_url":"https://api.github.com/repos/Chorus/chorus/pulls{/number}","milestones_url":"https://api.github.com/repos/Chorus/chorus/milestones{/number}","notifications_url":"https://api.github.com/repos/Chorus/chorus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Chorus/chorus/labels{/name}","releases_url":"https://api.github.com/repos/Chorus/chorus/releases{/id}","created_at":"2011-11-10T20:30:13Z","updated_at":"2015-09-16T10:39:46Z","pushed_at":"2015-10-02T00:55:12Z","git_url":"git://github.com/Chorus/chorus.git","ssh_url":"git@github.com:Chorus/chorus.git","clone_url":"https://github.com/Chorus/chorus.git","svn_url":"https://github.com/Chorus/chorus","homepage":"","size":859965,"stargazers_count":160,"watchers_count":160,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":69,"mirror_url":null,"open_issues_count":15,"forks":69,"open_issues":15,"watchers":160,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Chorus/chorus/pulls/173"},"html":{"href":"https://github.com/Chorus/chorus/pull/173"},"issue":{"href":"https://api.github.com/repos/Chorus/chorus/issues/173"},"comments":{"href":"https://api.github.com/repos/Chorus/chorus/issues/173/comments"},"review_comments":{"href":"https://api.github.com/repos/Chorus/chorus/pulls/173/comments"},"review_comment":{"href":"https://api.github.com/repos/Chorus/chorus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Chorus/chorus/pulls/173/commits"},"statuses":{"href":"https://api.github.com/repos/Chorus/chorus/statuses/d73fd53cdf395aba950d8925cc7a9aae4d5874d4"}}}}