{"action":"created","comment":{"url":"https://api.github.com/repos/leancloud/javascript-sdk/pulls/comments/35184897","id":35184897,"diff_hunk":"@@ -0,0 +1,141 @@\n+(function(root) {\n+  root.AV = root.AV || {};\n+  var AV = root.AV;\n+  var _ = AV._;\n+\n+  /**\n+   * @namespace 包含了使用了 LeanCloud\n+   *  <a href='/docs/leanInsight_guide.html'>离线数据分析功能</a>的函数。\n+   * <p><strong><em>\n+   *   部分函数仅在云引擎运行环境下有效。\n+   * </em></strong></p>\n+   */\n+  AV.Insight = AV.Insight || {};\n+\n+  _.extend(AV.Insight, /** @lends AV.Insight */ {\n+\n+    /**\n+     * 开始一个 Insight 任务。结果里将返回 Job id，你可以拿得到的 id 使用\n+     * AV.Insight.JobQuery 查询任务状态和结果。\n+     * @param {Object} jobConfig 任务配置的 JSON 对象，例如：<code><pre>\n+     *                   { \"sql\" : \"select count(*) as c,gender from _User group by gender\",\n+     *                     \"saveAs\": {\n+     *                         \"className\" : \"UserGender\",\n+     *                         \"limit\": 1\n+     *                      }\n+     *                   }\n+     *                  </pre></code>\n+     *               sql 指定任务执行的 SQL 语句， saveAs（可选） 指定将结果保存在哪张表里，limit 最大 1000。\n+     * @param {Object} options A Backbone-style options object\n+     * options.success, if set, should be a function to handle a successful\n+     * call to a cloud function.  options.error should be a function that\n+     * handles an error running the cloud function.  Both functions are\n+     * optional.  Both functions take a single argument.\n+     * @return {AV.Promise} A promise that will be resolved with the result\n+     * of the function.\n+     */\n+    startJob: function(jobConfig, options) {\n+      if(!jobConfig || !jobConfig.sql) {\n+        throw new Error('Please provide the sql to run the job.');\n+      }\n+      var data = {\n+        jobConfig: jobConfig,\n+        appId: AV.applicationId\n+      }\n+      var request = AV._request(\"insight\", 'jobs', null, 'POST',\n+                                   AV._encode(data, null, true));\n+\n+      return request.then(function(resp) {\n+        return AV._decode(null, resp).id;\n+      })._thenRunCallbacks(options);\n+    },\n+\n+    /**\n+     * 监听 Insight 任务事件，目前仅支持 end 事件，表示任务完成。\n+     *  <p><strong><em>\n+     *     仅在云引擎运行环境下有效。\n+     *  </em></strong></p>\n+     * @param {String} event 监听的事件，目前仅支持 'end' ，表示任务完成\n+     * @param {Function} 监听回调函数，接收 (err, id) 两个参数，err 表示错误信息，\n+     *                   id 表示任务 id。接下来你可以拿这个 id 使用AV.Insight.JobQuery 查询任务状态和结果。\n+     *\n+     */\n+    on: function(event, cb) {","path":"lib/insight.js","position":63,"original_position":63,"commit_id":"bbe2b7a45491027d2ad5c7f6eb8f681299756b13","original_commit_id":"d75e73f4d9093dd87b9f89a6ad98b11b1c88fc98","user":{"login":"killme2008","id":14142,"avatar_url":"https://avatars.githubusercontent.com/u/14142?v=3","gravatar_id":"","url":"https://api.github.com/users/killme2008","html_url":"https://github.com/killme2008","followers_url":"https://api.github.com/users/killme2008/followers","following_url":"https://api.github.com/users/killme2008/following{/other_user}","gists_url":"https://api.github.com/users/killme2008/gists{/gist_id}","starred_url":"https://api.github.com/users/killme2008/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/killme2008/subscriptions","organizations_url":"https://api.github.com/users/killme2008/orgs","repos_url":"https://api.github.com/users/killme2008/repos","events_url":"https://api.github.com/users/killme2008/events{/privacy}","received_events_url":"https://api.github.com/users/killme2008/received_events","type":"User","site_admin":false},"body":"这里只是为了生成文档，那个方法在云代码里实现，客户端无法实现。","created_at":"2015-07-22T06:30:44Z","updated_at":"2015-07-22T06:30:44Z","html_url":"https://github.com/leancloud/javascript-sdk/pull/110#discussion_r35184897","pull_request_url":"https://api.github.com/repos/leancloud/javascript-sdk/pulls/110","_links":{"self":{"href":"https://api.github.com/repos/leancloud/javascript-sdk/pulls/comments/35184897"},"html":{"href":"https://github.com/leancloud/javascript-sdk/pull/110#discussion_r35184897"},"pull_request":{"href":"https://api.github.com/repos/leancloud/javascript-sdk/pulls/110"}}},"pull_request":{"url":"https://api.github.com/repos/leancloud/javascript-sdk/pulls/110","id":40224629,"html_url":"https://github.com/leancloud/javascript-sdk/pull/110","diff_url":"https://github.com/leancloud/javascript-sdk/pull/110.diff","patch_url":"https://github.com/leancloud/javascript-sdk/pull/110.patch","issue_url":"https://api.github.com/repos/leancloud/javascript-sdk/issues/110","number":110,"state":"closed","locked":false,"title":"add leaninsight sdk","user":{"login":"jwfing","id":985038,"avatar_url":"https://avatars.githubusercontent.com/u/985038?v=3","gravatar_id":"","url":"https://api.github.com/users/jwfing","html_url":"https://github.com/jwfing","followers_url":"https://api.github.com/users/jwfing/followers","following_url":"https://api.github.com/users/jwfing/following{/other_user}","gists_url":"https://api.github.com/users/jwfing/gists{/gist_id}","starred_url":"https://api.github.com/users/jwfing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwfing/subscriptions","organizations_url":"https://api.github.com/users/jwfing/orgs","repos_url":"https://api.github.com/users/jwfing/repos","events_url":"https://api.github.com/users/jwfing/events{/privacy}","received_events_url":"https://api.github.com/users/jwfing/received_events","type":"User","site_admin":false},"body":"@killme2008 ","created_at":"2015-07-17T12:03:22Z","updated_at":"2015-07-22T06:30:44Z","closed_at":"2015-07-22T06:30:22Z","merged_at":"2015-07-22T06:30:22Z","merge_commit_sha":"caade5f4154b543f11b1f4b6fbdd0e3a35f16ec8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/leancloud/javascript-sdk/pulls/110/commits","review_comments_url":"https://api.github.com/repos/leancloud/javascript-sdk/pulls/110/comments","review_comment_url":"https://api.github.com/repos/leancloud/javascript-sdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/leancloud/javascript-sdk/issues/110/comments","statuses_url":"https://api.github.com/repos/leancloud/javascript-sdk/statuses/bbe2b7a45491027d2ad5c7f6eb8f681299756b13","head":{"label":"jwfing:master","ref":"master","sha":"bbe2b7a45491027d2ad5c7f6eb8f681299756b13","user":{"login":"jwfing","id":985038,"avatar_url":"https://avatars.githubusercontent.com/u/985038?v=3","gravatar_id":"","url":"https://api.github.com/users/jwfing","html_url":"https://github.com/jwfing","followers_url":"https://api.github.com/users/jwfing/followers","following_url":"https://api.github.com/users/jwfing/following{/other_user}","gists_url":"https://api.github.com/users/jwfing/gists{/gist_id}","starred_url":"https://api.github.com/users/jwfing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwfing/subscriptions","organizations_url":"https://api.github.com/users/jwfing/orgs","repos_url":"https://api.github.com/users/jwfing/repos","events_url":"https://api.github.com/users/jwfing/events{/privacy}","received_events_url":"https://api.github.com/users/jwfing/received_events","type":"User","site_admin":false},"repo":{"id":39252053,"name":"javascript-sdk","full_name":"jwfing/javascript-sdk","owner":{"login":"jwfing","id":985038,"avatar_url":"https://avatars.githubusercontent.com/u/985038?v=3","gravatar_id":"","url":"https://api.github.com/users/jwfing","html_url":"https://github.com/jwfing","followers_url":"https://api.github.com/users/jwfing/followers","following_url":"https://api.github.com/users/jwfing/following{/other_user}","gists_url":"https://api.github.com/users/jwfing/gists{/gist_id}","starred_url":"https://api.github.com/users/jwfing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwfing/subscriptions","organizations_url":"https://api.github.com/users/jwfing/orgs","repos_url":"https://api.github.com/users/jwfing/repos","events_url":"https://api.github.com/users/jwfing/events{/privacy}","received_events_url":"https://api.github.com/users/jwfing/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jwfing/javascript-sdk","description":"LeanCloud JavaScript SDK","fork":true,"url":"https://api.github.com/repos/jwfing/javascript-sdk","forks_url":"https://api.github.com/repos/jwfing/javascript-sdk/forks","keys_url":"https://api.github.com/repos/jwfing/javascript-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jwfing/javascript-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jwfing/javascript-sdk/teams","hooks_url":"https://api.github.com/repos/jwfing/javascript-sdk/hooks","issue_events_url":"https://api.github.com/repos/jwfing/javascript-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/jwfing/javascript-sdk/events","assignees_url":"https://api.github.com/repos/jwfing/javascript-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/jwfing/javascript-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/jwfing/javascript-sdk/tags","blobs_url":"https://api.github.com/repos/jwfing/javascript-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jwfing/javascript-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jwfing/javascript-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/jwfing/javascript-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jwfing/javascript-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/jwfing/javascript-sdk/languages","stargazers_url":"https://api.github.com/repos/jwfing/javascript-sdk/stargazers","contributors_url":"https://api.github.com/repos/jwfing/javascript-sdk/contributors","subscribers_url":"https://api.github.com/repos/jwfing/javascript-sdk/subscribers","subscription_url":"https://api.github.com/repos/jwfing/javascript-sdk/subscription","commits_url":"https://api.github.com/repos/jwfing/javascript-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/jwfing/javascript-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/jwfing/javascript-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/jwfing/javascript-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/jwfing/javascript-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/jwfing/javascript-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jwfing/javascript-sdk/merges","archive_url":"https://api.github.com/repos/jwfing/javascript-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jwfing/javascript-sdk/downloads","issues_url":"https://api.github.com/repos/jwfing/javascript-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/jwfing/javascript-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/jwfing/javascript-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/jwfing/javascript-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jwfing/javascript-sdk/labels{/name}","releases_url":"https://api.github.com/repos/jwfing/javascript-sdk/releases{/id}","created_at":"2015-07-17T12:01:58Z","updated_at":"2015-07-17T12:01:59Z","pushed_at":"2015-07-21T13:47:56Z","git_url":"git://github.com/jwfing/javascript-sdk.git","ssh_url":"git@github.com:jwfing/javascript-sdk.git","clone_url":"https://github.com/jwfing/javascript-sdk.git","svn_url":"https://github.com/jwfing/javascript-sdk","homepage":"http://leancloud.cn/","size":6185,"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":"leancloud:master","ref":"master","sha":"8c54df42ed542f4ea0e29844f4dffe941c734fb5","user":{"login":"leancloud","id":6660518,"avatar_url":"https://avatars.githubusercontent.com/u/6660518?v=3","gravatar_id":"","url":"https://api.github.com/users/leancloud","html_url":"https://github.com/leancloud","followers_url":"https://api.github.com/users/leancloud/followers","following_url":"https://api.github.com/users/leancloud/following{/other_user}","gists_url":"https://api.github.com/users/leancloud/gists{/gist_id}","starred_url":"https://api.github.com/users/leancloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leancloud/subscriptions","organizations_url":"https://api.github.com/users/leancloud/orgs","repos_url":"https://api.github.com/users/leancloud/repos","events_url":"https://api.github.com/users/leancloud/events{/privacy}","received_events_url":"https://api.github.com/users/leancloud/received_events","type":"Organization","site_admin":false},"repo":{"id":21419780,"name":"javascript-sdk","full_name":"leancloud/javascript-sdk","owner":{"login":"leancloud","id":6660518,"avatar_url":"https://avatars.githubusercontent.com/u/6660518?v=3","gravatar_id":"","url":"https://api.github.com/users/leancloud","html_url":"https://github.com/leancloud","followers_url":"https://api.github.com/users/leancloud/followers","following_url":"https://api.github.com/users/leancloud/following{/other_user}","gists_url":"https://api.github.com/users/leancloud/gists{/gist_id}","starred_url":"https://api.github.com/users/leancloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leancloud/subscriptions","organizations_url":"https://api.github.com/users/leancloud/orgs","repos_url":"https://api.github.com/users/leancloud/repos","events_url":"https://api.github.com/users/leancloud/events{/privacy}","received_events_url":"https://api.github.com/users/leancloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/leancloud/javascript-sdk","description":"LeanCloud JavaScript SDK","fork":false,"url":"https://api.github.com/repos/leancloud/javascript-sdk","forks_url":"https://api.github.com/repos/leancloud/javascript-sdk/forks","keys_url":"https://api.github.com/repos/leancloud/javascript-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leancloud/javascript-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leancloud/javascript-sdk/teams","hooks_url":"https://api.github.com/repos/leancloud/javascript-sdk/hooks","issue_events_url":"https://api.github.com/repos/leancloud/javascript-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/leancloud/javascript-sdk/events","assignees_url":"https://api.github.com/repos/leancloud/javascript-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/leancloud/javascript-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/leancloud/javascript-sdk/tags","blobs_url":"https://api.github.com/repos/leancloud/javascript-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leancloud/javascript-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leancloud/javascript-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/leancloud/javascript-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leancloud/javascript-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/leancloud/javascript-sdk/languages","stargazers_url":"https://api.github.com/repos/leancloud/javascript-sdk/stargazers","contributors_url":"https://api.github.com/repos/leancloud/javascript-sdk/contributors","subscribers_url":"https://api.github.com/repos/leancloud/javascript-sdk/subscribers","subscription_url":"https://api.github.com/repos/leancloud/javascript-sdk/subscription","commits_url":"https://api.github.com/repos/leancloud/javascript-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/leancloud/javascript-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/leancloud/javascript-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/leancloud/javascript-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/leancloud/javascript-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/leancloud/javascript-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leancloud/javascript-sdk/merges","archive_url":"https://api.github.com/repos/leancloud/javascript-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leancloud/javascript-sdk/downloads","issues_url":"https://api.github.com/repos/leancloud/javascript-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/leancloud/javascript-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/leancloud/javascript-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/leancloud/javascript-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leancloud/javascript-sdk/labels{/name}","releases_url":"https://api.github.com/repos/leancloud/javascript-sdk/releases{/id}","created_at":"2014-07-02T10:06:21Z","updated_at":"2015-07-20T15:37:11Z","pushed_at":"2015-07-22T06:30:22Z","git_url":"git://github.com/leancloud/javascript-sdk.git","ssh_url":"git@github.com:leancloud/javascript-sdk.git","clone_url":"https://github.com/leancloud/javascript-sdk.git","svn_url":"https://github.com/leancloud/javascript-sdk","homepage":"http://leancloud.cn/","size":6185,"stargazers_count":42,"watchers_count":42,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":15,"forks":23,"open_issues":15,"watchers":42,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/leancloud/javascript-sdk/pulls/110"},"html":{"href":"https://github.com/leancloud/javascript-sdk/pull/110"},"issue":{"href":"https://api.github.com/repos/leancloud/javascript-sdk/issues/110"},"comments":{"href":"https://api.github.com/repos/leancloud/javascript-sdk/issues/110/comments"},"review_comments":{"href":"https://api.github.com/repos/leancloud/javascript-sdk/pulls/110/comments"},"review_comment":{"href":"https://api.github.com/repos/leancloud/javascript-sdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/leancloud/javascript-sdk/pulls/110/commits"},"statuses":{"href":"https://api.github.com/repos/leancloud/javascript-sdk/statuses/bbe2b7a45491027d2ad5c7f6eb8f681299756b13"}}}}