Changes between Initial Version and Version 1 of Tagiris/Tests


Ignore:
Timestamp:
04/04/11 13:50:55 (13 years ago)
Author:
awagner
Comment:

First Tests for Tagiris evaluation

Legend:

Unmodified
Added
Removed
Modified
  • Tagiris/Tests

    v1 v1  
     1= Tests = 
     2 
     3== Tag amount Usage Statistics == 
     4 
     5{{{ 
     6var xy= []; 
     7var taggingService = Components.classes["@mozilla.org/browser/tagging-service;1"].getService(Components.interfaces.nsITaggingService); 
     8var historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"].getService(Components.interfaces.nsINavHistoryService); 
     9var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); 
     10var options = historyService.getNewQueryOptions(); 
     11options.queryType=1; 
     12var query = historyService.getNewQuery(); 
     13var result = historyService.executeQuery(query, options); 
     14var rootNode = result.root; 
     15rootNode.containerOpen = true; 
     16for (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} 
     23xy; 
     24}}} 
     25 
     26== Tag Saturation (monthly) == 
     27{{{ 
     28var pC = Components.classes["@mozilla.org/browser/nav-history-service;1"].getService(Components.interfaces.nsPIPlacesDatabase).DBConnection; 
     29var stmt = pC.createStatement("SELECT dateAdded FROM moz_bookmarks WHERE parent=4 and type=2 ORDER BY dateAdded ASC"); 
     30var oldFirstOfMonth = 0; 
     31var xy = []; 
     32var i = -1; 
     33while (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} 
     46xy; 
     47}}}