forked from Countly/countly-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Onur Alp Soner
authored and
Onur Alp Soner
committed
Jul 29, 2012
1 parent
c0d08da
commit c266847
Showing
9 changed files
with
362 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
getDescendantProp = function(obj, desc) { | ||
desc = String(desc); | ||
|
||
if (desc.indexOf(".") === -1) { | ||
return obj[desc]; | ||
} | ||
|
||
var arr = desc.split("."); | ||
while(arr.length && (obj = obj[arr.shift()])); | ||
|
||
return obj; | ||
}; | ||
|
||
removeEscaped = function (x) { | ||
|
||
if (!x["devices"] && !x["carriers"]) { | ||
return true; | ||
} | ||
|
||
var tmpValueSet = (x["devices"])? x["devices"] : x["carriers"], | ||
valueSet = []; | ||
|
||
for (var i=0; i < tmpValueSet.length; i++) { | ||
if (tmpValueSet[i].indexOf("'") != -1) { | ||
valueSet[valueSet.length] = tmpValueSet[i]; | ||
} | ||
} | ||
|
||
if (!valueSet.length) { | ||
return true; | ||
} | ||
|
||
var setThese = {}, | ||
unsetThese = {}, | ||
oldValueSet = valueSet.join(",").replace(/\'/mg,"\\'").split(","); | ||
|
||
for (var j=0; j < 55; j++) { | ||
for (var l=0; l < valueSet.length; l++) { | ||
var versionValue = getDescendantProp(x, ("w" + j + "." + oldValueSet[l])); | ||
|
||
if (versionValue) { | ||
delete x["w" + j][valueSet[l]]; | ||
setThese["w" + j + "." + valueSet[l]] = versionValue; | ||
unsetThese["w" + j + "." + oldValueSet[l]] = 1; | ||
} | ||
} | ||
} | ||
|
||
for (var i=2012; i < 2013; i++) { | ||
for (var k=1; k < 13; k++) { | ||
for (var j=1; j < 32; j++) { | ||
for (var l=0; l < valueSet.length; l++) { | ||
var versionValue = getDescendantProp(x, (i + "." + k + "." + j + "." + oldValueSet[l])); | ||
|
||
if (versionValue) { | ||
delete x[i][k][j][valueSet[l]]; | ||
setThese[i + "." + k + "." + j + "." + valueSet[l]] = versionValue; | ||
unsetThese[i + "." + k + "." + j + "." + oldValueSet[l]] = 1; | ||
} | ||
} | ||
} | ||
|
||
for (var l=0; l < valueSet.length; l++) { | ||
var versionValue = getDescendantProp(x, (i + "." + k + "." + oldValueSet[l])); | ||
|
||
if (versionValue) { | ||
delete x[i][k][valueSet[l]]; | ||
setThese[i + "." + k + "." + valueSet[l]] = versionValue; | ||
unsetThese[i + "." + k + "." + oldValueSet[l]] = 1; | ||
} | ||
} | ||
} | ||
|
||
for (var l=0; l < valueSet.length; l++) { | ||
var versionValue = getDescendantProp(x, (i + "." + oldValueSet[l])); | ||
|
||
if (versionValue) { | ||
delete x[i][valueSet[l]]; | ||
setThese[i + "." + valueSet[l]] = versionValue; | ||
unsetThese[i + "." + oldValueSet[l]] = 1; | ||
} | ||
} | ||
} | ||
|
||
for (var l=0; l < valueSet.length; l++) { | ||
var versionValue = x[oldValueSet[l]]; | ||
|
||
if (versionValue) { | ||
delete x[valueSet[l]]; | ||
setThese[valueSet[l]] = versionValue; | ||
unsetThese[oldValueSet[l]] = 1; | ||
} | ||
} | ||
|
||
if (x["devices"]) { | ||
db.devices.update({_id: x._id}, {$set: setThese, $unset: unsetThese}); | ||
} else { | ||
db.carriers.update({_id: x._id}, {$set: setThese, $unset: unsetThese}); | ||
} | ||
} | ||
|
||
db.carriers.find().forEach(removeEscaped); | ||
db.devices.find().forEach(removeEscaped); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
/* | ||
Versions listed below are common for Android and iOS; | ||
2.0, 2.1, 2.2.1, 2.2.2, 2.2, 2.2.1, 3.0, 3.0, 3.1, 3.2.1, 3.2.2, 3.2.4, 3.2, 3.2, 4.0.1, 4.0.2, 4.0.3, 4.0.4, 4.1.1 | ||
*/ | ||
|
||
var iosVersions = ["1:2b1", "2:0b2", "2:0b3", "2:0b4", "2:0b5", "2:0b6", "2:0b7", "2:0b8", "2:0", "2:1:1", "2:1:2", "2:1:3", "2:1:4", "2:1", "2:2:1", "2:2:2", "2:2", "2:2:1", "3:0:1", "3:0:2", "3:0:3", "3:0:4", "3:0:5", "3:0", "3:0", "3:1:1", "3:1:2", "3:1:3", "3:1", "3:2:1", "3:2:2", "3:2:3", "3:2:4", "3:2:5", "3:2", "3:2", "4:0:1", "4:0:2", "4:0:3", "4:0:4", "4:0", "4:0", "4:1:1", "4:1:2", "4:1:3", "4:1", "4:2:1", "4:2:2", "4:2:3", "4:2", "4:2", "4:2", "4:3:1", "4:3:2", "4:3:3", "4:3", "4:3", "5:0:1", "5:0:2", "5:0:3", "5:0:4", "5:0:5", "5:0:6", "5:0:7", "5:0", "5:0", "5:0:1:1", "5:0:1", "5:1:1", "5:1:2", "5:1:3", "5:1", "6:0:1", "6:0:2", "6:0:3"], | ||
androidVersions = ["1:0", "1:1", "1:5", "1:6", "2:0", "2:0:1", "2:1", "2:2", "2:2:1", "2:2:2", "2:2:3", "2:3", "2:3:3", "2:3:4", "2:3:5", "2:3:6", "2:3:7", "3:0", "3:1", "3:2", "3:2:1", "3:2:2", "3:2:4", "3:2:6", "4:0:1", "4:0:2", "4:0:3", "4:0:4", "4:1:1"]; | ||
|
||
var fixVersions = { | ||
"iOS": { | ||
"array": iosVersions, | ||
"prefix": "i" | ||
}, | ||
"Android": { | ||
"array": androidVersions, | ||
"prefix": "a" | ||
} | ||
} | ||
|
||
getDescendantProp = function(obj, desc) { | ||
desc = String(desc); | ||
|
||
if (desc.indexOf(".") === -1) { | ||
return obj[desc]; | ||
} | ||
|
||
var arr = desc.split("."); | ||
while(arr.length && (obj = obj[arr.shift()])); | ||
|
||
return obj; | ||
}; | ||
|
||
arrayUnique = function(arr) { | ||
var o = {}, | ||
i, | ||
l = arr.length, | ||
r = []; | ||
|
||
for(i=0; i<l;i+=1) { | ||
o[arr[i]] = arr[i]; | ||
} | ||
|
||
for(i in o) { | ||
r.push(o[i]); | ||
} | ||
|
||
return r; | ||
}; | ||
|
||
addPlatformPrefix = function (x) { | ||
|
||
if (!x["os"] || !x["os_versions"]) { | ||
return true; | ||
} else { | ||
x["os"] = x["os"].sort(); | ||
} | ||
|
||
for (var m=0; m < x["os"].length; m++) { | ||
var setThese = {}, | ||
unsetThese = {}, | ||
pullThese = [], | ||
pushThese = [], | ||
activeVersionArray = fixVersions[x["os"][m]].array, | ||
activePlatformPrefix = fixVersions[x["os"][m]].prefix; | ||
|
||
if (x["os"].length == 1) { | ||
activeVersionArray = []; | ||
|
||
for (var l=0; l < x["os_versions"].length; l++) { | ||
if (x["os_versions"][l].indexOf("i") == -1 && x["os_versions"][l].indexOf("a") == -1) { | ||
activeVersionArray[activeVersionArray.length] = x["os_versions"][l]; | ||
} | ||
} | ||
|
||
activeVersionArray = activeVersionArray.join(',').replace(/\./g, ":").split(','); | ||
} | ||
|
||
for (var j=0; j < 55; j++) { | ||
for (var l=0; l < activeVersionArray.length; l++) { | ||
var versionValue = getDescendantProp(x, ("w" + j + "." + activeVersionArray[l])); | ||
|
||
if (versionValue) { | ||
delete x["w" + j][activeVersionArray[l]]; | ||
setThese["w" + j + "." + activePlatformPrefix + activeVersionArray[l]] = versionValue; | ||
unsetThese["w" + j + "." + activeVersionArray[l]] = 1; | ||
pullThese[pullThese.length] = activeVersionArray[l]; | ||
} | ||
} | ||
} | ||
|
||
for (var i=2012; i < 2013; i++) { | ||
for (var k=1; k < 13; k++) { | ||
for (var j=1; j < 32; j++) { | ||
for (var l=0; l < activeVersionArray.length; l++) { | ||
var versionValue = getDescendantProp(x, (i + "." + k + "." + j + "." + activeVersionArray[l])); | ||
|
||
if (versionValue) { | ||
delete x[i][k][j][activeVersionArray[l]]; | ||
setThese[i + "." + k + "." + j + "." + activePlatformPrefix + activeVersionArray[l]] = versionValue; | ||
unsetThese[i + "." + k + "." + j + "." + activeVersionArray[l]] = 1; | ||
pullThese[pullThese.length] = activeVersionArray[l]; | ||
} | ||
} | ||
} | ||
|
||
for (var l=0; l < activeVersionArray.length; l++) { | ||
var versionValue = getDescendantProp(x, (i + "." + k + "." + activeVersionArray[l])); | ||
|
||
if (versionValue) { | ||
delete x[i][k][activeVersionArray[l]]; | ||
setThese[i + "." + k + "." + activePlatformPrefix + activeVersionArray[l]] = versionValue; | ||
unsetThese[i + "." + k + "." + activeVersionArray[l]] = 1; | ||
pullThese[pullThese.length] = activeVersionArray[l]; | ||
} | ||
} | ||
} | ||
|
||
for (var l=0; l < activeVersionArray.length; l++) { | ||
var versionValue = getDescendantProp(x, (i + "." + activeVersionArray[l])); | ||
|
||
if (versionValue) { | ||
delete x[i][activeVersionArray[l]]; | ||
setThese[i + "." + activePlatformPrefix + activeVersionArray[l]] = versionValue; | ||
unsetThese[i + "." + activeVersionArray[l]] = 1; | ||
pullThese[pullThese.length] = activeVersionArray[l]; | ||
} | ||
} | ||
} | ||
|
||
for (var l=0; l < activeVersionArray.length; l++) { | ||
var versionValue = x[activeVersionArray[l]]; | ||
|
||
if (versionValue) { | ||
delete x[activeVersionArray[l]]; | ||
setThese[activePlatformPrefix + activeVersionArray[l]] = versionValue; | ||
unsetThese[activeVersionArray[l]] = 1; | ||
pullThese[pullThese.length] = activeVersionArray[l]; | ||
} | ||
} | ||
|
||
pullThese = arrayUnique(pullThese); | ||
|
||
for (var i=0; i < pullThese.length; i++) { | ||
pushThese[i] = activePlatformPrefix + pullThese[i] | ||
} | ||
|
||
var pullTheseRep = pullThese.join(',').replace(/:/g, ".").split(','); | ||
pullThese = pullThese.concat(pullTheseRep); | ||
|
||
db.device_details.update({_id: x._id}, {$set: setThese, $unset: unsetThese, $pushAll: {'os_versions': pushThese}}); | ||
db.device_details.update({_id: x._id}, {$pullAll: {'os_versions': pullThese}}); | ||
} | ||
} | ||
|
||
db.device_details.find().forEach(addPlatformPrefix); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var countlyConfig = {}; | ||
|
||
countlyConfig.mongodb = {}; | ||
countlyConfig.web = {}; | ||
|
||
countlyConfig.mongodb.host = "localhost"; | ||
countlyConfig.mongodb.db = "countly"; | ||
countlyConfig.mongodb.port = 27017; | ||
countlyConfig.web.port = 6001; | ||
|
||
module.exports = countlyConfig; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 93 additions & 0 deletions
93
frontend/express/public/javascripts/countly/countly.app.version.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
(function(countlyAppVersion, $, undefined) { | ||
|
||
//Private Properties | ||
var _periodObj = {}, | ||
_appVersionsDb = {}; | ||
|
||
//Public Methods | ||
countlyAppVersion.initialize = function() { | ||
_periodObj = countlyCommon.periodObj; | ||
|
||
if (!countlyCommon.DEBUG) { | ||
return $.ajax({ | ||
type: "GET", | ||
url: countlyCommon.READ_API_URL, | ||
data: { | ||
"app_key" : countlyCommon.ACTIVE_APP_KEY, | ||
"method" : "app_versions" | ||
}, | ||
dataType: "jsonp", | ||
success: function(json) { | ||
_appVersionsDb = json; | ||
} | ||
}); | ||
} else { | ||
_appVersionsDb = {"2012":{}}; | ||
return true; | ||
} | ||
}; | ||
|
||
countlyAppVersion.clearAppVersionsObject = function(obj) { | ||
if (obj) { | ||
if(!obj["t"]) obj["t"] = 0; | ||
if(!obj["n"]) obj["n"] = 0; | ||
if(!obj["u"]) obj["u"] = 0; | ||
} | ||
else { | ||
obj = {"t": 0, "n": 0, "u": 0}; | ||
} | ||
|
||
return obj; | ||
} | ||
|
||
countlyAppVersion.getAppVersionBars = function() { | ||
return countlyCommon.extractBarData(_appVersionsDb, _appVersionsDb["app_versions"], countlyAppVersion.clearAppVersionsObject); | ||
} | ||
|
||
countlyAppVersion.getAppVersionData = function(os) { | ||
|
||
var appVersionData = {chartData: {}, chartDP: {dp: [], ticks: []}}; | ||
|
||
var tmpAppVersionData = countlyCommon.extractTwoLevelData(_appVersionsDb, _appVersionsDb["app_versions"], countlyAppVersion.clearAppVersionsObject, [ | ||
{ | ||
name: "app_version", | ||
func: function (rangeArr, dataObj) { | ||
return rangeArr; | ||
} | ||
}, | ||
{ "name": "t" }, | ||
{ "name": "u" }, | ||
{ "name": "n" } | ||
]); | ||
|
||
appVersionData.chartData = tmpAppVersionData.chartData; | ||
|
||
if (appVersionData.chartData) { | ||
for (var i = 0; i < appVersionData.chartData.length; i++) { | ||
appVersionData.chartData[i].app_version = appVersionData.chartData[i].app_version.replace(/:/g, "."); | ||
} | ||
} | ||
|
||
var appVersions = _.pluck(appVersionData.chartData, "app_version"), | ||
appVersionTotal = _.pluck(appVersionData.chartData, 't'), | ||
appVersionNew = _.pluck(appVersionData.chartData, 'n'), | ||
chartDP = [{data: [], label: "Total Sessions"}, {data: [], label: "New Users"}]; | ||
|
||
chartDP[0]["data"][0] = [-1,null]; | ||
chartDP[0]["data"][appVersions.length+1] = [appVersions.length, null]; | ||
|
||
appVersionData.chartDP.ticks.push([-1, ""]); | ||
appVersionData.chartDP.ticks.push([appVersions.length, ""]); | ||
|
||
for (var i = 0; i < appVersions.length; i++) { | ||
chartDP[0]["data"][i+1] = [i, appVersionTotal[i]]; | ||
chartDP[1]["data"][i+1] = [i, appVersionNew[i]]; | ||
appVersionData.chartDP.ticks.push([i, appVersions[i]]); | ||
} | ||
|
||
appVersionData.chartDP.dp = chartDP; | ||
|
||
return appVersionData; | ||
} | ||
|
||
}(window.countlyAppVersion = window.countlyAppVersion || {}, jQuery)); |
Empty file.