| 1 | = Tests = |
| 2 | |
| 3 | == Tag amount Usage Statistics == |
| 4 | |
| 5 | {{{ |
| 6 | var xy= []; |
| 7 | var taggingService = Components.classes["@mozilla.org/browser/tagging-service;1"].getService(Components.interfaces.nsITaggingService); |
| 8 | var historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"].getService(Components.interfaces.nsINavHistoryService); |
| 9 | var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); |
| 10 | var options = historyService.getNewQueryOptions(); |
| 11 | options.queryType=1; |
| 12 | var query = historyService.getNewQuery(); |
| 13 | var result = historyService.executeQuery(query, options); |
| 14 | var rootNode = result.root; |
| 15 | rootNode.containerOpen = true; |
| 16 | for (var i = 0; i < rootNode.childCount; i ++) { |
| 17 | var node = rootNode.getChild(i); |
| 18 | var aURI = ioService.newURI(node.uri, null, null); |
| 19 | var tagCount = { value : 0 }; |
| 20 | taggingService.getTagsForURI(aURI, tagCount); |
| 21 | xy[tagCount.value] = (xy[tagCount.value] != null) ? (xy[tagCount.value] + 1) : 1; |
| 22 | } |
| 23 | xy; |
| 24 | }}} |
| 25 | |
| 26 | == Tag Saturation (monthly) == |
| 27 | {{{ |
| 28 | var pC = Components.classes["@mozilla.org/browser/nav-history-service;1"].getService(Components.interfaces.nsPIPlacesDatabase).DBConnection; |
| 29 | var stmt = pC.createStatement("SELECT dateAdded FROM moz_bookmarks WHERE parent=4 and type=2 ORDER BY dateAdded ASC"); |
| 30 | var oldFirstOfMonth = 0; |
| 31 | var xy = []; |
| 32 | var i = -1; |
| 33 | while (stmt.step()) { |
| 34 | var dateAdded = stmt.getInt64(0); |
| 35 | var dateAddedDate = new Date(dateAdded / 1000); |
| 36 | var firstOfMonth = new Date(dateAddedDate.getFullYear(), dateAddedDate.getMonth() + 1, dateAddedDate.getDate()).getTime(); |
| 37 | var diff = firstOfMonth - oldFirstOfMonth; |
| 38 | if (diff > 0) { |
| 39 | xy[i + 1] = (xy[i] != null) ? xy[i] + 1 : 1; |
| 40 | i++; |
| 41 | oldFirstOfMonth = firstOfMonth; |
| 42 | } else { |
| 43 | xy[i] = (xy[i] != null) ? (xy[i] + 1) : 1; |
| 44 | } |
| 45 | } |
| 46 | xy; |
| 47 | }}} |