Skip to content

Commit c438f0c

Browse files
authored
Merge pull request #672 from Cookiezaurs/guidelines-frontend-countly
guideline fixes countly.total.users.js, countly.version.history.js, countly.vue.components.js
2 parents 792b84b + 45157f7 commit c438f0c

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

frontend/express/public/javascripts/countly/countly.total.users.js

+30-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
(function(countlyTotalUsers, $, undefined) {
1+
/* global countlyCommon, countlyGlobal, countlyDevice, _ */
2+
(function(countlyTotalUsers, $) {
23

34
//Private Properties
45
var _activeAppId = 0,
@@ -97,10 +98,10 @@
9798
return countlyCommon.periodObj.periodContainsToday;
9899
};
99100

100-
/*
101-
Sets init status for forMetric in below format
102-
{ "APP_KEY": { "countries": { "60days": true } } }
103-
We don't directly use _totalUserObjects for init check because it is init after AJAX and might take time
101+
/**Sets init status for forMetric in below format
102+
* { "APP_KEY": { "countries": { "60days": true } } }
103+
* We don't directly use _totalUserObjects for init check because it is init after AJAX and might take time
104+
* @param {string} forMetric - metric for which set init status
104105
*/
105106
function setInit(forMetric) {
106107
if (!_initialized[_activeAppId]) {
@@ -114,15 +115,20 @@
114115
_initialized[_activeAppId][forMetric][_period] = true;
115116
}
116117

118+
/** function checks if metric is initialized
119+
* @param {string} forMetric - metric name to check
120+
* @returns {boolean} if initialized
121+
*/
117122
function isInitialized(forMetric) {
118123
return _initialized[_activeAppId] &&
119124
_initialized[_activeAppId][forMetric] &&
120125
_initialized[_activeAppId][forMetric][_period];
121126
}
122127

123-
/*
124-
Adds data for forMetric to _totalUserObjects object in below format
125-
{ "APP_KEY": { "countries": { "60days": {"TR": 1, "UK": 5} } } }
128+
/** Adds data for forMetric to _totalUserObjects object in below format
129+
* { "APP_KEY": { "countries": { "60days": {"TR": 1, "UK": 5} } } }
130+
* @param {string} forMetric - metric name
131+
* @param {object} data - data to set
126132
*/
127133
function setCalculatedObj(forMetric, data) {
128134
if (!_totalUserObjects[_activeAppId]) {
@@ -136,6 +142,11 @@
136142
_totalUserObjects[_activeAppId][forMetric][_period] = formatCalculatedObj(data, forMetric);
137143
}
138144

145+
/** sets refresh obj for metric
146+
* { "APP_KEY": { "countries": { "60days": {"TR": 1, "UK": 5} } } }
147+
* @param {string} forMetric - metric name
148+
* @param {object} data - data to set
149+
*/
139150
function setRefreshObj(forMetric, data) {
140151
if (!_totalUserObjects[_activeAppId]) {
141152
_totalUserObjects[_activeAppId] = {};
@@ -148,10 +159,12 @@
148159
_totalUserObjects[_activeAppId][forMetric][_period + "_refresh"] = formatCalculatedObj(data, forMetric);
149160
}
150161

151-
/*
152-
Response from the API is in [{"_id":"TR","u":1},{"_id":"UK","u":5}] format
153-
We convert it to {"TR": 1, "UK": 5} format in this function
154-
processingFunction is used for cases where keys are converted before being processed (e.g. device names)
162+
/** Response from the API is in [{"_id":"TR","u":1},{"_id":"UK","u":5}] format
163+
* We convert it to {"TR": 1, "UK": 5} format in this function
164+
* processingFunction is used for cases where keys are converted before being processed (e.g. device names)
165+
* @param {object} obj - data object
166+
* @param {string} forMetric - metric name
167+
* @returns {object} converted object
155168
*/
156169
function formatCalculatedObj(obj, forMetric) {
157170
var tmpObj = {},
@@ -172,9 +185,10 @@
172185
return tmpObj;
173186
}
174187

175-
/*
176-
Refreshes data based the diff between current "refresh" and the new one retrieved from the API
177-
{ "APP_KEY": { "countries": { "30days_refresh": {"TR": 1, "UK": 5} } } }
188+
/** Refreshes data based the diff between current "refresh" and the new one retrieved from the API
189+
* { "APP_KEY": { "countries": { "30days_refresh": {"TR": 1, "UK": 5} } } }
190+
* @param {string} forMetric - metric name
191+
* @param {object} todaysJson - data
178192
*/
179193
function refreshData(forMetric, todaysJson) {
180194
if (_totalUserObjects[_activeAppId] &&
@@ -186,7 +200,7 @@
186200
currRefreshObj = _totalUserObjects[_activeAppId][forMetric][_period + "_refresh"],
187201
newRefreshObj = formatCalculatedObj(todaysJson, forMetric);
188202

189-
_.each(newRefreshObj, function(value, key, list) {
203+
_.each(newRefreshObj, function(value, key) {
190204
if (currRefreshObj[key]) {
191205
// If existing refresh object contains the key we refresh the value
192206
// in total user object to curr value + new refresh value - curr refresh value

frontend/express/public/javascripts/countly/countly.version.history.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* global countlyCommon, countlyGlobal */
12
(function(countlyVersionHistoryManager, $) {
23
//we will store our data here
34
var _data = [];
@@ -15,7 +16,7 @@
1516
//got our data, let's store it
1617
_data = json.result;
1718
},
18-
error: function(exception) {}
19+
error: function(/*exception*/) {}
1920
});
2021
};
2122
//return data that we have

frontend/express/public/javascripts/countly/countly.vue.components.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*global jQuery,countlyCommon,moment */
1+
/* global countlyCommon, moment */
22
(function(CountlyVueComponents, $) {
33

44
/**

0 commit comments

Comments
 (0)