Skip to content

Commit dacea19

Browse files
author
Cookiezaurs
committed
more fixes
1 parent 6cfff05 commit dacea19

File tree

4 files changed

+7
-41
lines changed

4 files changed

+7
-41
lines changed

api/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const pack = require('../package.json');
1414
const versionInfo = require('../frontend/express/version.info.js');
1515
const moment = require("moment");
1616

17-
var {MongoDbQueryRunner} = require('../plugins/drill/api/parts/data/MongoDbQueryRunner.js');
17+
var {MongoDbQueryRunner} = require('./utils/mongoDbQueryRunner.js');
1818

1919
var t = ["countly:", "api"];
2020
common.processRequest = processRequest;

api/ingestor/requestProcessor.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,9 @@ const processRequestData = (ob, done) => {
709709
update = common.mergeQuery(update, ob.updates[i]);
710710
}
711711
}
712-
var SaveAppUser = Date.now().valueOf();
712+
//var SaveAppUser = Date.now().valueOf();
713713

714-
common.updateAppUser(ob.params, update, false, function(err, userdoc) {
714+
common.updateAppUser(ob.params, update, false, function() {
715715

716716
/*var AfterSaveAppUser = Date.now().valueOf();
717717
if (AfterSaveAppUser - SaveAppUser > treshold) {
@@ -727,10 +727,6 @@ const processRequestData = (ob, done) => {
727727
}
728728
});
729729

730-
}).catch(function(err) {
731-
log.e(err);
732-
common.returnMessage(ob.params, 400, 'Cannot process request');
733-
done();
734730
});
735731
};
736732

plugins/views/api/api.js

-30
Original file line numberDiff line numberDiff line change
@@ -1965,36 +1965,6 @@ const escapedViewSegments = { "name": true, "segment": true, "height": true, "wi
19651965
});
19661966
});
19671967

1968-
/**
1969-
* Check if view count is alread updated somewhere else and fix it
1970-
* @param {Array} updates - array with updates
1971-
* @param {number} inc - amount to increment
1972-
* @param {number} set - amount to set
1973-
*/
1974-
function checkViewQuery(updates, inc, set) {
1975-
var needUpdate = true;
1976-
for (let i = 0; i < updates.length; i++) {
1977-
if (inc && updates[i] && updates[i].$set && typeof updates[i].$set.vc === "number") {
1978-
updates[i].$set.vc = updates[i].$set.vc + inc;
1979-
needUpdate = false;
1980-
break;
1981-
}
1982-
else if (typeof set !== "undefined" && updates[i] && updates[i].$inc && updates[i].$inc.vc) {
1983-
set += updates[i].$inc.vc;
1984-
delete updates[i].$inc.vc;
1985-
}
1986-
}
1987-
1988-
if (needUpdate) {
1989-
if (typeof set !== "undefined") {
1990-
updates.push({$set: {vc: set}});
1991-
}
1992-
else if (inc) {
1993-
updates.push({$inc: {vc: inc}});
1994-
}
1995-
}
1996-
}
1997-
19981968
/**
19991969
* Function to process view
20001970
* @param {Object} params - Default parameters object

test/unit-tests/db.tests.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -257,25 +257,25 @@ describe('Testing Simple database operations', function() {
257257

258258
describe("test insert Many(+behaviour on duplicate)", function() {
259259
it("Insert once and check result(promise)", async function(done) {
260-
var rr = await db.collection("testCommands3").insertMany([{"_id": 1},{ "_id": 2},{"_id": 3}]);
260+
var rr = await db.collection("testCommands3").insertMany([{"_id": 1}, { "_id": 2}, {"_id": 3}]);
261261

262262
var cursor = db.collection("testCommands3").find();
263263
var res = await cursor.toArray();
264264
res.should.have.property.length(3);
265265
});
266266

267267
it("Insert again and check result(callback)", async function(done) {
268-
var rr = await db.collection("testCommands3").insertMany([{"_id": 4},{ "_id": 5},{ "_id": 6}]);
268+
var rr = await db.collection("testCommands3").insertMany([{"_id": 4}, { "_id": 5}, { "_id": 6}]);
269269

270-
db.collection("testCommands3").insertMany([{"_id": 4},{ "_id": 5},{ "_id": 6}], function(err, res) {
270+
db.collection("testCommands3").insertMany([{"_id": 4}, { "_id": 5}, { "_id": 6}], function(err, res) {
271271
db.collection("testCommands3").find().toArray(function(err, res) {
272272
res.should.have.property.length(6);
273273
});
274274
});
275275
});
276276

277277
it("Insert and should get duplicate error", async function(done) {
278-
var rr = await db.collection("testCommands3").insertMany([{"_id": 7, "_id": 1, "_id": 8}]);
278+
var rr = await db.collection("testCommands3").insertMany([{"_id": 7}, { "_id": 1}, { "_id": 8}]);
279279

280280
var cursor = db.collection("testCommands3").find();
281281
var res = await cursor.toArray();

0 commit comments

Comments
 (0)