Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should be able to observe 10000 rows in no less time than the previous run", function (done) {
var model = blast.observe(sampleData);
perf = window._p;
Parse.initialize("8xnXEIVSc0KBeeDoEHNXKFPwnqQIVHfewNTNKOIO", "vbk4WiXQDzzBF28UQFeTn6tmxsaM73U9i6qDzqAz");
var TestRun = Parse.Object.extend("TestRun");
var query = new Parse.Query(TestRun);
var time = perf["blast.observe"].sum;
var newTestRun = new TestRun();
newTestRun.set("key", "observe_100000_rows");
newTestRun.set("time", time);
query.find({
success: function (testRuns) {
if (!testRuns || testRuns.length === 0) {
newTestRun.save(null, {
success: function (run) {
// pass the test
done();
}
});
} else {
getByPageName: function(pageName, defaultContent, cb) {
var collection = new Content.Collection();
collection.query = new Parse.Query(Content);
collection.query.equalTo('pageName', pageName);
collection.fetch({
success: function(obj) {
cb(obj.models[0] || Content.create(pageName, defaultContent));
},
error: function(obj, err) {
console.error('getByPageName() error', obj, err);
}
});
},
observe: function() {
var now = new Date();
var monthStart = new Date(now.getFullYear(), now.getMonth(), 0, 0, 0);
var monthEnd = new Date(now.getFullYear(), now.getMonth() + 1, 0, 0, 0);
return {
expenses: (new Parse.Query('Expense'))
.greaterThan('createdAt', monthStart)
.lessThan('createdAt', monthEnd)
.ascending('createdAt')
};
},
function requestContentItems(model, items, itemsDraft) {
return send(getAllObjects(
new Parse.Query(Parse.Object.extend(model.tableName))
))
.then(items_o => {
for (let item_o of items_o) {
let item = new ContentItemData();
item.model = model;
item.setOrigin(item_o);
if (item_o.get('t__owner'))
itemsDraft.push(item);
else
items.push(item);
}
})
.catch(() => {});
}
export function getUser(email) {
if (!email)
return Promise.reject();
return send(
new Parse.Query(Parse.User)
.equalTo("email", email)
.first()
)
.then(user_o => {
if (user_o)
return new UserData().setOrigin(user_o);
else
throw 'User not found!';
});
}
function requestTemplates(templates_o, templates) {
return send(getAllObjects(
new Parse.Query(TemplateData.OriginClass)
))
.then(_templates_o => {
Array.prototype.push.apply(templates_o, _templates_o);
for (let template_o of templates_o)
templates.push(new TemplateData().setOrigin(template_o));
});
}
var ReactTree = require('./ReactTree');
var Tree = require('./lib/Tree');
var ImportUtils = require('./lib/ImportUtils');
var config = require('./config');
var FakeParseTree = require('./lib/FakeParseTree');
if (config.use_parse) {
var Parse = require('parse').Parse;
Parse.initialize(config.parse_app_id, config.parse_js_key);
var First = Parse.Object.extend('first');
var query = new Parse.Query(First);
query.get(config.parse_id, {
success: function(parseTree) {
ReactTree.startRender(parseTree);
},
error: function(obj, error) {
throw 'Error loading tree' + obj + error;
}
});
} else {
ImportUtils.opmlToTree(ImportUtils.sampleOpml, function(tree) {
ReactTree.startRender(new FakeParseTree(Tree.toString(tree)));
});
}
function requestCollaborationsPre(sites) {
return send(getAllObjects(
new Parse.Query(CollaborationData.OriginClass)
.equalTo("user", Parse.User.current())
))
.then(collabs => {
for (let collab of collabs)
sites.push(collab.get('site'));
return send(Parse.Object.fetchAllIfNeeded(sites));
});
}
observe: function() {
var now = new Date();
var monthStart = new Date(now.getFullYear(), now.getMonth(), 0, 0, 0);
var monthEnd = new Date(now.getFullYear(), now.getMonth() + 1, 0, 0, 0);
return {
expenses: (new Parse.Query('Expense'))
.greaterThan('createdAt', monthStart)
.lessThan('createdAt', monthEnd)
.ascending('createdAt'),
user: ParseReact.currentUser
};
},
function requestFields(models_o, models) {
return send(getAllObjects(
new Parse.Query(ModelFieldData.OriginClass)
.containedIn("model", models_o)
))
.then(fields_o => {
for (let field_o of fields_o) {
let field = new ModelFieldData().setOrigin(field_o);
let model_o = field_o.get("model");
for (let model of models) {
if (model.origin.id == model_o.id) {
field.model = model;
model.fields.push(field);
break;
}
}
}
});
}