Parse platform 解析速率限制清理数据

Parse platform 解析速率限制清理数据,parse-platform,Parse Platform,我有很多行5K加上我有一个长列和Lat列,我想添加另一个列位置,并从长列和Lat创建一个地质点,这样我就可以通过应用程序的解析进行一些地理位置查询 我已经编写了下面的cloudCode,但由于每秒使用>30个请求,我达到了速率限制。我很高兴等待1小时,以完成这一切我想做的就是创建地质点,一旦我完成 Parse.Cloud.define("locationCleanUp", function(request, response) { var setLocation = funct

我有很多行5K加上我有一个长列和Lat列,我想添加另一个列位置,并从长列和Lat创建一个地质点,这样我就可以通过应用程序的解析进行一些地理位置查询

我已经编写了下面的cloudCode,但由于每秒使用>30个请求,我达到了速率限制。我很高兴等待1小时,以完成这一切我想做的就是创建地质点,一旦我完成

    Parse.Cloud.define("locationCleanUp", function(request, response) {

    var setLocation = function(longitude,latitude) {

        var point = new Parse.GeoPoint({latitude:latitude, longitude:longitude});

        //console.log(point);

        return point;

    };

    var query = new Parse.Query("WeatherSitelistCodes");

    query.each(

        function(result) {

            //console.log(result.get('name'));
            result.set("location",setLocation(result.get("longitude"),result.get("latitude")));
            result.save();

        },{
            success: function(result) {
                response.success("All Done!");
                //console.log(result.set("location",setLocation(result.get("longitude"),result.get("latitude"))));

            },
            error: function() {
                console.log("Error: " + error);
            }
        });
     });
任何关于如何做到这一点的提示或建议都将不胜感激


我的下一个任务是在本地清理数据,然后上传,但我已经完成了这一步…

这有点糟糕,因为parse没有提供任何帮助,解决方案对他们来说很糟糕,因为它是一个实时等待循环,如:

function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds) {
      break;
    }
  }
}
函数睡眠(毫秒){
var start=new Date().getTime();
对于(变量i=0;i<1e7;i++){
如果((新日期().getTime()-start)>毫秒){
打破
}
}
}
每次保存后都会调用它以限制总吞吐量。

谢谢danh和Wain

最后,我使用了一个每隔5分钟运行一次的后台作业,该作业查询更新日期,以查找少于今天的记录

// Use Parse.Cloud.define to define as many cloud functions as you want.
// For example:
Parse.Cloud.job("locationCleanUp", function(request, response) {

    var setLocation = function(longitude,latitude) {

        var point = new Parse.GeoPoint({latitude:latitude, longitude:longitude});

        console.log(point);

        return point;

    };

    var date = new Date("2015-05-08");
    var site = Parse.Object.extend("WeatherSitelistCodes");
    var query = new Parse.Query("WeatherSitelistCodes");
    query.lessThan("updatedAt",date);

    query.each(

        function(result) {
            var lat = parseFloat(result.get("latitude"));
            var longi = parseFloat(result.get("longitude"));
            var newLocation = setLocation(longi,lat);
            var location = JSON.stringify(result.get("location"));

            console.log("Location: " + result.get("name"));

                result.save({
                    location: newLocation
                },{
                    success: function(result) {
                        console.log("Saved!");

                    },

                    error: function(result, error) {
                        console.log("Error" + error.message);
                    }
                });

            },{
            success: function() {
            // results is an array of Parse.Object.
            console.log('Done!');
            response.success("Updated Records!!");
              },
            error: function(error) {
            // error is an instance of Parse.Error.
            console.log('Error: +' error.message);
            response.error("Failed to save vote. Error=" + error.message);
            }
        });
});

我认为这行不通。Parse.com声明,在15秒的挂钟时间后,云函数将被终止。据我所知,完成这项工作的唯一方法是运行一个计划作业,查找OP想要更改的条件,并在小卡盘中进行更改(例如,一次1k行)。要么这样,要么使用这个或类似的技术从客户端进行节流。@danh好的一点,它确实应该作为作业运行,然后它将有15分钟的运行时间(作业可以手动运行,也可以按计划运行)。这有点痛parse.com没有在管理控制台中提供修复此问题的工具,许多人必须有长的和长的,需要转换为他们的“地理位置”类型。