cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mura...@apache.org
Subject cordova-registry-web git commit: CB-9165 Adding download count for plugin list
Date Fri, 12 Jun 2015 01:23:45 GMT
Repository: cordova-registry-web
Updated Branches:
  refs/heads/master 1d7f7c03a -> dfbf52c40


CB-9165 Adding download count for plugin list


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/dfbf52c4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/tree/dfbf52c4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/diff/dfbf52c4

Branch: refs/heads/master
Commit: dfbf52c409bba0a652f9436e3c83d15d618b16ee
Parents: 1d7f7c0
Author: Raghav Katyal <rakatyal@microsoft.com>
Authored: Thu Jun 11 17:38:44 2015 -0700
Committer: Raghav Katyal <rakatyal@microsoft.com>
Committed: Thu Jun 11 18:18:47 2015 -0700

----------------------------------------------------------------------
 npm-search/assets/js/app.js | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/dfbf52c4/npm-search/assets/js/app.js
----------------------------------------------------------------------
diff --git a/npm-search/assets/js/app.js b/npm-search/assets/js/app.js
index 99b6d65..ee987ab 100644
--- a/npm-search/assets/js/app.js
+++ b/npm-search/assets/js/app.js
@@ -90,6 +90,9 @@ var Plugin = React.createClass({
             license = license[0];
         }
         var officialPlugin = this.props.plugin.isOfficial;
+        var downloadField;
+        if(this.props.plugin.downloadCount)
+            downloadField = <p className="version"> {this.props.plugin.downloadCount}
downloads last month</p>;
         return (
             <li>
                 <div className="pluginCardContents">
@@ -102,6 +105,7 @@ var Plugin = React.createClass({
                         <div className="row">
                             <SupportedPlatforms keywords={this.props.plugin.keywords}/>
                             <div className="col-xs-3">
+                                {downloadField}
                                 <p className="license">License: {license}</p>
                                 <p className="version">Version: {this.props.plugin.version}</p>
                             </div>
@@ -171,6 +175,27 @@ var App = React.createClass({
             }
         }, function() { console.log('xhr err'); });
 
+        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)
+                {
+                    xhrRequest("https://api.npmjs.org/downloads/point/last-month/" + packageNames,
function(xhrResult) {
+                        plugins.forEach(function(plugin) {
+                            if(xhrResult[plugin.name])
+                                plugin.downloadCount = xhrResult[plugin.name].downloads;
+                        });
+                        that.setState({
+                            plugins: plugins
+                        });
+                    }.bind(self), function() { console.log('xhr err'); });
+                    packageNames = "";
+                }
+            }
+        }
+
         function processPlugins(officialPlugins, plugins) {
             var pluginCount = plugins.length,
                 dateNow = new Date(),
@@ -196,6 +221,7 @@ var App = React.createClass({
                   plugins: plugins,
                   placeHolderText: 'Search ' + pluginCount + ' plugins...'
                 });
+                getDownloadCount(plugins,this);
             }
         }
     },


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


Mime
View raw message