Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Parse platform 解析后台作业在21条记录后添加多个记录停止_Parse Platform - Fatal编程技术网

Parse platform 解析后台作业在21条记录后添加多个记录停止

Parse platform 解析后台作业在21条记录后添加多个记录停止,parse-platform,Parse Platform,我试图通过解析后台作业添加多个记录。我没有收到任何错误,只是在21条记录之后停止保存记录。这是我的密码: var _ = require('underscore'); Parse.Cloud.job('usagovJobsRunner', function (request, status) { var promises = []; for (var index = 0; index < 2; index++) { promises.push(Parse.Cloud.ht

我试图通过解析后台作业添加多个记录。我没有收到任何错误,只是在21条记录之后停止保存记录。这是我的密码:

var _ = require('underscore');

Parse.Cloud.job('usagovJobsRunner', function (request, status) {
  var promises = [];
  for (var index = 0; index < 2; index++) {
    promises.push(Parse.Cloud.httpRequest({
      url: 'http://jobs.github.com/positions.json',
      followRedirects: true,
      params: {
        page: index
      }
    }));
  }

  var jobs = [];
  Parse.Promise.when(promises).then(function () {

    console.log('arguments length: ' + arguments.length);

    _.each(arguments, function (page) {
      console.log('page lenght: ' + page.data.length);

      _.each(page.data, function (job) {
        var model = new (Parse.Object.extend('Jobs'));
        model.set({
          jobId: job.id,
          title: job.title,
          description: job.description,
          location: job.location,
          jobPosting: new Date(job.created_at),
          type: job.type,
          company: job.company,
          companyUrl: job.company_url,
          companyLogoUrl: job.company_logo,
          source: 'Github Jobs',
          jobUrl: job.url
        });
        jobs.push(model)
      });
    });

    console.log('jobs count: ' + jobs.length);

    Parse.Cloud.useMasterKey();
    // save all the newly created objects
    Parse.Object.saveAll(jobs, {
      success: function (objs) {
        // objects have been saved...
        console.log('jobs saved.');
        status.success('Github Jobs runner successfully loaded ' + objs.length + ' jobs');
      },
      error: function (error) { 
        // an error occurred...
        console.log(error);
        status.error('Error: ' + error);
      }
    });


    status.success();
  }, function (err) {
    console.log(err);
    status.error(err);
  });

});
这是我的日志:

I2015-08-28610:50:31.327Z]参数长度:2 I2015-08-28610:50:31.328Z]页长:50 I2015-08-28610:50:31.363Z]页长:50 I2015-08-28610:50:31.404Z]工作数量:100 I2015-08-28T10:50:31.442Z]v15:运行作业usagovJobsRunner时使用:输入: {}结果:未定义


不要把承诺和传统的回扣混为一谈,选择一种风格并坚持下去。呼叫状态。成功;只有一次,当一切都完成了


对于调用任意页面深度,您应该创建一个普通的JS函数,该函数接受一个页码,并返回一个承诺,该承诺由页面数据和页码完成。现在,您可以调用该函数,当它完成时,您可以检查是否需要加载另一个页面,并且您还知道页码是多少。当你到达终点时,你可以呼叫状态。成功

不要把承诺和传统的回访混为一谈,选择一种方式并坚持下去。呼叫状态。成功;当一切都完成时,仅此一次。@Wain删除最后一个状态。成功;工作。我还有一个问题,我不知道githhub的最大页数,你对此有什么建议吗。