Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
ar2rsawseen committed Jul 18, 2019
2 parents ec9475f + da9f795 commit 5b24ca0
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 20 deletions.
2 changes: 1 addition & 1 deletion api/parts/data/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ countlyEvents.processEvents = function(params) {
var currEvent = params.qstring.events[i],
shortEventName = "",
eventCollectionName = "";
if (!currEvent.key || !currEvent.count || !common.isNumber(currEvent.count) || (currEvent.key.indexOf('[CLY]_') === 0 && plugins.internalEvents.indexOf(currEvent.key) === -1)) {
if (!currEvent.key || !currEvent.count || !common.isNumber(currEvent.count) || (currEvent.key && currEvent.key.indexOf('[CLY]_') === 0 && plugins.internalEvents.indexOf(currEvent.key) === -1)) {
continue;
}

Expand Down
7 changes: 5 additions & 2 deletions api/parts/mgmt/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,9 @@ function deleteAppData(appId, fromAppDelete, params, app) {
* @param {object} app - app document
**/
function deleteAllAppData(appId, fromAppDelete, params, app) {
common.db.collection('apps').update({'_id': common.db.ObjectID(appId)}, {$set: {seq: 0}}, function() {});
if (!fromAppDelete) {
common.db.collection('apps').update({'_id': common.db.ObjectID(appId)}, {$set: {seq: 0}}, function() {});
}
common.db.collection('users').remove({'_id': {$regex: appId + ".*"}}, function() {});
common.db.collection('carriers').remove({'_id': {$regex: appId + ".*"}}, function() {});
common.db.collection('devices').remove({'_id': {$regex: appId + ".*"}}, function() {});
Expand All @@ -688,7 +690,7 @@ function deleteAllAppData(appId, fromAppDelete, params, app) {
var collectionNameWoPrefix = crypto.createHash('sha1').update(events.list[i] + appId).digest('hex');
common.db.collection("events" + collectionNameWoPrefix).drop(function() {});
}
if (params.qstring.args.period === "reset") {
if (fromAppDelete || params.qstring.args.period === "reset") {
common.db.collection('events').remove({'_id': common.db.ObjectID(appId)}, function() {});
}
}
Expand All @@ -698,6 +700,7 @@ function deleteAllAppData(appId, fromAppDelete, params, app) {
if (!fromAppDelete) {
common.db.collection('metric_changes' + appId).drop(function() {
common.db.collection('metric_changes' + appId).ensureIndex({ts: -1}, { background: true }, function() {});
common.db.collection('metric_changes' + appId).ensureIndex({ts: 1, "cc.o": 1}, { background: true }, function() {});
common.db.collection('metric_changes' + appId).ensureIndex({uid: 1}, { background: true }, function() {});
});
common.db.collection('app_user_merges' + appId).drop(function() {
Expand Down
2 changes: 1 addition & 1 deletion bin/config/countly_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if [ `getent passwd countly`x == 'x' ]; then
useradd -r -M -U -d $COUNTLY_DIR -s /bin/false countly

#countly process should be able to restart itself
echo "countly ALL=(ALL) NOPASSWD: /usr/bin/countly start, /usr/bin/countly stop, /usr/bin/countly restart, /usr/bin/countly upgrade" >> /etc/sudoers.d/countly
echo "countly ALL=(ALL) NOPASSWD: /usr/bin/countly start, /usr/bin/countly stop, /usr/bin/countly restart, /usr/bin/countly upgrade, /usr/bin/npm *" >> /etc/sudoers.d/countly
fi

#change permission of countly directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@
success: function(json) {
_resultData = json;
for (var i = 0; i < json.length; i++) {
if (json[i].meta) {
json[i].meta = countlyCommon.decodeHtml(json[i].meta);
}
if (json[i].request) {
json[i].request = JSON.parse(countlyCommon.decodeHtml(json[i].request));
json[i].request = JSON.parse(json[i].request);
}
_resultObj[json[i]._id] = json[i];
}
Expand All @@ -45,13 +42,10 @@
dataType: "json",
success: function(json) {
if (json.data) {
json.data = JSON.parse(countlyCommon.decodeHtml(json.data));
}
if (json.meta) {
json.meta = countlyCommon.decodeHtml(json.meta);
json.data = JSON.parse(json.data);
}
if (json.request) {
json.request = JSON.parse(countlyCommon.decodeHtml(json.request));
json.request = JSON.parse(json.request);
}
_data[id] = json;
if (callback) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/express/public/stylesheets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
url('../fonts/Oswald-700/Oswald-700.ttf') format('truetype'),
url('../fonts/Oswald-700/Oswald-700.svg#Oswald') format('svg');
}

* { outline:none; }
html { height: 100%; }
body { margin:0; padding:0; overflow:auto; background-color:#F9F9F9; user-select:text; font-family: Ubuntu,Helvetica,sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
#content-container { margin-left:224px; min-width:768px; min-height: 400px; padding:78px 16px 35px 16px; transition: margin-left 0.55s; will-change: margin-left; }
Expand Down
2 changes: 1 addition & 1 deletion plugins/assistant/api/assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const _ = require('underscore');

db.collection('apps').findOne({_id: db.ObjectID(app_id)}, {type: 1}, function(err, document) {
//todo handle null case
const isMobile = document.type === "mobile";//check if app type is mobile or web
const isMobile = document && document.type === "mobile";//check if app type is mobile or web

//get global unsaved notifications for this app
db.collection(db_name_notifs).find({app_id: app_id}, {}).toArray(function(err1, notifs) {
Expand Down
6 changes: 3 additions & 3 deletions plugins/pluginManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ var pluginManager = function pluginManager() {
return callback(errors);
}
var cwd = eplugin ? eplugin.rfs : path.join(__dirname, plugin);
exec('npm install --unsafe-perm', {cwd: cwd}, function(error) {
exec('sudo npm install --unsafe-perm', {cwd: cwd}, function(error) {
if (error) {
errors = true;
console.log('error: %j', error);
Expand Down Expand Up @@ -785,7 +785,7 @@ var pluginManager = function pluginManager() {
return callback(errors);
}
var cwd = eplugin ? eplugin.rfs : path.join(__dirname, plugin);
exec('npm update --unsafe-perm', {cwd: cwd}, function(error) {
exec('sudo npm update --unsafe-perm', {cwd: cwd}, function(error) {
if (error) {
errors = true;
console.log('error: %j', error);
Expand Down Expand Up @@ -1109,7 +1109,7 @@ var pluginManager = function pluginManager() {
return mongo.ObjectID(id);
}
catch (ex) {
console.log("Incorrect Object ID", ex);
logDbRead.i("Incorrect Object ID %j", ex);
return id;
}
};
Expand Down
15 changes: 15 additions & 0 deletions plugins/views/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,21 @@ const escapedViewSegments = { "name": true, "segment": true, "height": true, "wi
});
}
}
else if (params.qstring.action === "get_view_count") {
if (params.app_id && params.app_id !== "") {
common.db.collection("app_viewsmeta" + params.app_id).estimatedDocumentCount(function(err, count) {
if (err) {
common.returnMessage(params, 200, 0);
}
else {
common.returnMessage(params, 200, count || 0);
}
});
}
else {
common.returnMessage(params, 400, "Missing request parameter: app_id");
}
}
else {
var retData = {};
colName = "app_viewdata" + crypto.createHash('sha1').update(segment + params.app_id).digest('hex');
Expand Down
41 changes: 39 additions & 2 deletions plugins/views/frontend/public/javascripts/countly.models.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
_period = null,
_tableData = [],
_selectedViews = [],
_graphDataObj = {};
_graphDataObj = {},
_viewsCount = 0;

//graphData['appID'][]
//Public Methods
Expand Down Expand Up @@ -56,6 +57,21 @@
_domains = json.domains;
}
}
}),
$.ajax({
type: "GET",
url: countlyCommon.API_PARTS.data.r,
data: {
"app_id": countlyCommon.ACTIVE_APP_ID,
"method": "views",
"action": "get_view_count"
},
dataType: "json",
success: function(json) {
if (json && json.result) {
_viewsCount = json.result;
}
}
})
).then(//on initialize load only after getting list of selected
function() {
Expand Down Expand Up @@ -86,7 +102,24 @@
return true;
}
};

countlyViews.loadViewCount = function() {
return $.when($.ajax({
type: "GET",
url: countlyCommon.API_PARTS.data.r,
data: {
"app_id": countlyCommon.ACTIVE_APP_ID,
"method": "views",
"action": "get_view_count"
},
dataType: "json",
success: function(json) {
if (json && json.result) {
_viewsCount = json.result;
}
}
})
);
};
countlyViews.refresh = function() {
if (!countlyCommon.DEBUG) {

Expand Down Expand Up @@ -208,6 +241,10 @@
return _segments;
};

countlyViews.getViewsCount = function() {
return _viewsCount;
};

countlyViews.getSegmentKeys = function() {
var segments = [];
for (var key in _segments) {
Expand Down

0 comments on commit 5b24ca0

Please sign in to comment.