You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mu...@apache.org on 2015/07/15 23:56:31 UTC

[2/4] cordova-registry-web git commit: Changing batch sizes for XHR to improve perf

Changing batch sizes for XHR to improve perf


Project: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/commit/95474923
Tree: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/tree/95474923
Diff: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/diff/95474923

Branch: refs/heads/master
Commit: 954749236d07be4a341ceb263c74778eecc42904
Parents: f4cc553
Author: Nikhil Khandelwal <ni...@microsoft.com>
Authored: Wed Jul 15 11:05:26 2015 -0700
Committer: Murat Sutunc <su...@gmail.com>
Committed: Wed Jul 15 14:47:23 2015 -0700

----------------------------------------------------------------------
 npm-search/assets/js/app.js | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/95474923/npm-search/assets/js/app.js
----------------------------------------------------------------------
diff --git a/npm-search/assets/js/app.js b/npm-search/assets/js/app.js
index aad42ce..f354e55 100644
--- a/npm-search/assets/js/app.js
+++ b/npm-search/assets/js/app.js
@@ -2,6 +2,11 @@ var React    = window.React = require('react'), // assign it to window for react
     classNames = require('classnames'),
     App = {};
 
+var Constants = {
+    DownloadCountBatch: 100,
+    NpmSearchInitialSize: 500
+}
+
 var OfficialPlugin = React.createClass({
     render: function() {
         return (
@@ -332,7 +337,7 @@ var App = React.createClass({
             queryHost = "http://npmsearch.com/query",
             queryFields = "fields=name,keywords,license,description,author,modified,homepage,version",
             queryKeywords = "q=keywords:%22ecosystem:cordova%22",
-            queryInitialSize = 300;
+            queryInitialSize = Constants.NpmSearchInitialSize;
 
         xhrRequest(queryHost + "?" + queryFields + "&" + queryKeywords + "&size=" + queryInitialSize + "&start=0", function(xhrResult) {
             plugins = xhrResult.results;
@@ -347,11 +352,11 @@ var App = React.createClass({
             }
         }, function() { console.log('xhr err'); });
 
-        var getDownloadCount = function(plugins,that) {
+        var getDownloadCount = function(plugins, that) {
             var packageNames = "";
             for(var index=0; index < plugins.length; index++) {
                 packageNames += plugins[index].name + ",";
-                if(index%50 === 0 || index === plugins.length -1) {
+                if(index % Constants.DownloadCountBatch === 0 || index === plugins.length -1) {
                     xhrRequest("https://api.npmjs.org/downloads/point/last-month/" + packageNames, function(xhrResult) {
                         plugins.forEach(function(plugin) {
                             if(xhrResult[plugin.name])


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org