Skip to content

Commit bbb782d

Browse files
committed
Updated dist
1 parent 3206c4e commit bbb782d

File tree

4 files changed

+307
-7
lines changed

4 files changed

+307
-7
lines changed

dist/av-core-mini.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/av-core.js

Lines changed: 151 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(function(root) {
22
root.AV = root.AV || {};
3-
root.AV.VERSION = "js0.5.6";
3+
root.AV.VERSION = "js0.5.7";
44
}(this));
55

66
// Underscore.js 1.4.4
@@ -9067,5 +9067,155 @@
90679067
var AV = root.AV;
90689068
var _ = AV._;
90699069

9070+
/**
9071+
* @namespace 包含了使用了 LeanCloud
9072+
* <a href='/docs/insight_guide.html'>离线数据分析功能</a>的函数。
9073+
* <p><strong><em>
9074+
* 部分函数仅在云引擎运行环境下有效。
9075+
* </em></strong></p>
9076+
*/
9077+
AV.Insight = AV.Insight || {};
9078+
9079+
_.extend(AV.Insight, /** @lends AV.Insight */ {
9080+
9081+
/**
9082+
* 开始一个 Insight 任务。结果里将返回 Job id,你可以拿得到的 id 使用
9083+
* AV.Insight.JobQuery 查询任务状态和结果。
9084+
* @param {Object} jobConfig 任务配置的 JSON 对象,例如:<code><pre>
9085+
* { "sql" : "select count(*) as c,gender from _User group by gender",
9086+
* "saveAs": {
9087+
* "className" : "UserGender",
9088+
* "limit": 1
9089+
* }
9090+
* }
9091+
* </pre></code>
9092+
* sql 指定任务执行的 SQL 语句, saveAs(可选) 指定将结果保存在哪张表里,limit 最大 1000。
9093+
* @param {Object} options A Backbone-style options object
9094+
* options.success, if set, should be a function to handle a successful
9095+
* call to a cloud function. options.error should be a function that
9096+
* handles an error running the cloud function. Both functions are
9097+
* optional. Both functions take a single argument.
9098+
* @return {AV.Promise} A promise that will be resolved with the result
9099+
* of the function.
9100+
*/
9101+
startJob: function(jobConfig, options) {
9102+
if(!jobConfig || !jobConfig.sql) {
9103+
throw new Error('Please provide the sql to run the job.');
9104+
}
9105+
var data = {
9106+
jobConfig: jobConfig,
9107+
appId: AV.applicationId
9108+
}
9109+
var request = AV._request("bigquery", 'jobs', null, 'POST',
9110+
AV._encode(data, null, true));
9111+
9112+
return request.then(function(resp) {
9113+
return AV._decode(null, resp).id;
9114+
})._thenRunCallbacks(options);
9115+
},
9116+
9117+
/**
9118+
* 监听 Insight 任务事件,目前仅支持 end 事件,表示任务完成。
9119+
* <p><strong><em>
9120+
* 仅在云引擎运行环境下有效。
9121+
* </em></strong></p>
9122+
* @param {String} event 监听的事件,目前仅支持 'end' ,表示任务完成
9123+
* @param {Function} 监听回调函数,接收 (err, id) 两个参数,err 表示错误信息,
9124+
* id 表示任务 id。接下来你可以拿这个 id 使用AV.Insight.JobQuery 查询任务状态和结果。
9125+
*
9126+
*/
9127+
on: function(event, cb) {
9128+
}
9129+
});
9130+
9131+
/**
9132+
* 创建一个对象,用于查询 Insight 任务状态和结果。
9133+
* @class
9134+
* @param {String} id 任务 id
9135+
* @since 0.5.5
9136+
*/
9137+
AV.Insight.JobQuery = function(id, className) {
9138+
if(!id) {
9139+
throw new Error('Please provide the job id.');
9140+
}
9141+
this.id = id;
9142+
this.className = className;
9143+
this._skip = 0;
9144+
this._limit = 100;
9145+
};
9146+
9147+
AV.Insight.JobQuery.prototype = {
9148+
9149+
/**
9150+
* Sets the number of results to skip before returning any results.
9151+
* This is useful for pagination.
9152+
* Default is to skip zero results.
9153+
* @param {Number} n the number of results to skip.
9154+
* @return {AV.Query} Returns the query, so you can chain this call.
9155+
*/
9156+
skip: function(n) {
9157+
this._skip = n;
9158+
return this;
9159+
},
9160+
9161+
/**
9162+
* Sets the limit of the number of results to return. The default limit is
9163+
* 100, with a maximum of 1000 results being returned at a time.
9164+
* @param {Number} n the number of results to limit to.
9165+
* @return {AV.Query} Returns the query, so you can chain this call.
9166+
*/
9167+
limit: function(n) {
9168+
this._limit = n;
9169+
return this;
9170+
},
9171+
9172+
/**
9173+
* 查询任务状态和结果,任务结果为一个 JSON 对象,包括 status 表示任务状态, totalCount 表示总数,
9174+
* results 数组表示任务结果数组,previewCount 表示可以返回的结果总数,任务的开始和截止时间
9175+
* startTime、endTime 等信息。
9176+
*
9177+
* @param {Object} options A Backbone-style options object
9178+
* options.success, if set, should be a function to handle a successful
9179+
* call to a cloud function. options.error should be a function that
9180+
* handles an error running the cloud function. Both functions are
9181+
* optional. Both functions take a single argument.
9182+
* @return {AV.Promise} A promise that will be resolved with the result
9183+
* of the function.
9184+
*
9185+
*/
9186+
find: function(options) {
9187+
var params = {
9188+
skip: this._skip,
9189+
limit: this._limit
9190+
};
9191+
9192+
var request = AV._request("bigquery", 'jobs', this.id, "GET",
9193+
params);
9194+
var self = this;
9195+
return request.then(function(response) {
9196+
if(response.error) {
9197+
return AV.Promise.error(new AV.Error(response.code, response.error));
9198+
}
9199+
return AV.Promise.as(response);
9200+
})._thenRunCallbacks(options);
9201+
}
9202+
9203+
};
9204+
9205+
}(this));
9206+
9207+
(function(root) {
9208+
root.AV = root.AV || {};
9209+
var AV = root.AV;
9210+
var _ = AV._;
9211+
9212+
/**
9213+
* @namespace 包含了使用了 LeanCloud
9214+
* <a href='/docs/insight_guide.html'>离线数据分析功能</a>的函数,本模块已经废弃,
9215+
* 请使用 AV.Insight 。
9216+
* <p><strong><em>
9217+
* 部分函数仅在云引擎运行环境下有效。
9218+
* </em></strong></p>
9219+
*/
90709220
AV.BigQuery = AV.Insight || {};
90719221
}(this));

dist/av-mini.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/av.js

Lines changed: 151 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(function(root) {
22
root.AV = root.AV || {};
3-
root.AV.VERSION = "js0.5.6";
3+
root.AV.VERSION = "js0.5.7";
44
}(this));
55

66
// Underscore.js 1.4.4
@@ -9067,6 +9067,156 @@
90679067
var AV = root.AV;
90689068
var _ = AV._;
90699069

9070+
/**
9071+
* @namespace 包含了使用了 LeanCloud
9072+
* <a href='/docs/insight_guide.html'>离线数据分析功能</a>的函数。
9073+
* <p><strong><em>
9074+
* 部分函数仅在云引擎运行环境下有效。
9075+
* </em></strong></p>
9076+
*/
9077+
AV.Insight = AV.Insight || {};
9078+
9079+
_.extend(AV.Insight, /** @lends AV.Insight */ {
9080+
9081+
/**
9082+
* 开始一个 Insight 任务。结果里将返回 Job id,你可以拿得到的 id 使用
9083+
* AV.Insight.JobQuery 查询任务状态和结果。
9084+
* @param {Object} jobConfig 任务配置的 JSON 对象,例如:<code><pre>
9085+
* { "sql" : "select count(*) as c,gender from _User group by gender",
9086+
* "saveAs": {
9087+
* "className" : "UserGender",
9088+
* "limit": 1
9089+
* }
9090+
* }
9091+
* </pre></code>
9092+
* sql 指定任务执行的 SQL 语句, saveAs(可选) 指定将结果保存在哪张表里,limit 最大 1000。
9093+
* @param {Object} options A Backbone-style options object
9094+
* options.success, if set, should be a function to handle a successful
9095+
* call to a cloud function. options.error should be a function that
9096+
* handles an error running the cloud function. Both functions are
9097+
* optional. Both functions take a single argument.
9098+
* @return {AV.Promise} A promise that will be resolved with the result
9099+
* of the function.
9100+
*/
9101+
startJob: function(jobConfig, options) {
9102+
if(!jobConfig || !jobConfig.sql) {
9103+
throw new Error('Please provide the sql to run the job.');
9104+
}
9105+
var data = {
9106+
jobConfig: jobConfig,
9107+
appId: AV.applicationId
9108+
}
9109+
var request = AV._request("bigquery", 'jobs', null, 'POST',
9110+
AV._encode(data, null, true));
9111+
9112+
return request.then(function(resp) {
9113+
return AV._decode(null, resp).id;
9114+
})._thenRunCallbacks(options);
9115+
},
9116+
9117+
/**
9118+
* 监听 Insight 任务事件,目前仅支持 end 事件,表示任务完成。
9119+
* <p><strong><em>
9120+
* 仅在云引擎运行环境下有效。
9121+
* </em></strong></p>
9122+
* @param {String} event 监听的事件,目前仅支持 'end' ,表示任务完成
9123+
* @param {Function} 监听回调函数,接收 (err, id) 两个参数,err 表示错误信息,
9124+
* id 表示任务 id。接下来你可以拿这个 id 使用AV.Insight.JobQuery 查询任务状态和结果。
9125+
*
9126+
*/
9127+
on: function(event, cb) {
9128+
}
9129+
});
9130+
9131+
/**
9132+
* 创建一个对象,用于查询 Insight 任务状态和结果。
9133+
* @class
9134+
* @param {String} id 任务 id
9135+
* @since 0.5.5
9136+
*/
9137+
AV.Insight.JobQuery = function(id, className) {
9138+
if(!id) {
9139+
throw new Error('Please provide the job id.');
9140+
}
9141+
this.id = id;
9142+
this.className = className;
9143+
this._skip = 0;
9144+
this._limit = 100;
9145+
};
9146+
9147+
AV.Insight.JobQuery.prototype = {
9148+
9149+
/**
9150+
* Sets the number of results to skip before returning any results.
9151+
* This is useful for pagination.
9152+
* Default is to skip zero results.
9153+
* @param {Number} n the number of results to skip.
9154+
* @return {AV.Query} Returns the query, so you can chain this call.
9155+
*/
9156+
skip: function(n) {
9157+
this._skip = n;
9158+
return this;
9159+
},
9160+
9161+
/**
9162+
* Sets the limit of the number of results to return. The default limit is
9163+
* 100, with a maximum of 1000 results being returned at a time.
9164+
* @param {Number} n the number of results to limit to.
9165+
* @return {AV.Query} Returns the query, so you can chain this call.
9166+
*/
9167+
limit: function(n) {
9168+
this._limit = n;
9169+
return this;
9170+
},
9171+
9172+
/**
9173+
* 查询任务状态和结果,任务结果为一个 JSON 对象,包括 status 表示任务状态, totalCount 表示总数,
9174+
* results 数组表示任务结果数组,previewCount 表示可以返回的结果总数,任务的开始和截止时间
9175+
* startTime、endTime 等信息。
9176+
*
9177+
* @param {Object} options A Backbone-style options object
9178+
* options.success, if set, should be a function to handle a successful
9179+
* call to a cloud function. options.error should be a function that
9180+
* handles an error running the cloud function. Both functions are
9181+
* optional. Both functions take a single argument.
9182+
* @return {AV.Promise} A promise that will be resolved with the result
9183+
* of the function.
9184+
*
9185+
*/
9186+
find: function(options) {
9187+
var params = {
9188+
skip: this._skip,
9189+
limit: this._limit
9190+
};
9191+
9192+
var request = AV._request("bigquery", 'jobs', this.id, "GET",
9193+
params);
9194+
var self = this;
9195+
return request.then(function(response) {
9196+
if(response.error) {
9197+
return AV.Promise.error(new AV.Error(response.code, response.error));
9198+
}
9199+
return AV.Promise.as(response);
9200+
})._thenRunCallbacks(options);
9201+
}
9202+
9203+
};
9204+
9205+
}(this));
9206+
9207+
(function(root) {
9208+
root.AV = root.AV || {};
9209+
var AV = root.AV;
9210+
var _ = AV._;
9211+
9212+
/**
9213+
* @namespace 包含了使用了 LeanCloud
9214+
* <a href='/docs/insight_guide.html'>离线数据分析功能</a>的函数,本模块已经废弃,
9215+
* 请使用 AV.Insight 。
9216+
* <p><strong><em>
9217+
* 部分函数仅在云引擎运行环境下有效。
9218+
* </em></strong></p>
9219+
*/
90709220
AV.BigQuery = AV.Insight || {};
90719221
}(this));
90729222

0 commit comments

Comments
 (0)