[Groonga-commit] groonga/gcs [master] Output domain status for all domains correctly

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Oct 15 16:15:36 JST 2012


YUKI Hiroshi	2012-10-15 16:15:36 +0900 (Mon, 15 Oct 2012)

  New Revision: c28571991e867d01ce55f2fc94d98b7cbb2f24df
  https://github.com/groonga/gcs/commit/c28571991e867d01ce55f2fc94d98b7cbb2f24df

  Log:
    Output domain status for all domains correctly

  Modified files:
    bin/gcs-describe-domain
    lib/command-line.js

  Modified: bin/gcs-describe-domain (+13 -11)
===================================================================
--- bin/gcs-describe-domain    2012-10-15 15:58:31 +0900 (4e0bf92)
+++ bin/gcs-describe-domain    2012-10-15 16:15:36 +0900 (c8ebaf4)
@@ -58,17 +58,19 @@ if (domainName) {
     });
   });
 } else {
-  commandLine.getDomainStatuses(null, function(error, domains) {
-    var statuses = {};
-    var statusPreparedCount = 0;
-    domains.slice(0).forEach(function(domain) {
-      statuses[domain.DomainName] = { domain: domain };
-      commandLine.getIndexFieldStatuses(domain.DomainName, function(error, indexFields) {
-        statuses[domain.DomainName].indexFields = indexFields;
-        statusPreparedCount++;
-        if (statusPreparedCount == domains.length) {
-          statuses.forEach(function(status) {
-            reportStatus(status.domain, status.indexFields);
+  commandLine.getDomainStatuses(function(error, domains) {
+    var indexFieldStatuses = {};
+    var preparedStatusesCount = 0;
+    domains.forEach(function(domain) {
+      var domainName = domain.DomainName;
+      commandLine.getIndexFieldStatuses(domainName, function(error, indexFields) {
+        indexFieldStatuses[domainName] = indexFields;
+        preparedStatusesCount++;
+        if (preparedStatusesCount == domains.length) {
+          domains.forEach(function(domain, index) {
+            if (index) console.log('');
+            var statuses = indexFieldStatuses[domain.DomainName];
+            reportStatus(domain, statuses);
           });
         }
       });

  Modified: lib/command-line.js (+10 -9)
===================================================================
--- lib/command-line.js    2012-10-15 15:58:31 +0900 (8bf2e45)
+++ lib/command-line.js    2012-10-15 16:15:36 +0900 (fbf9c16)
@@ -144,9 +144,7 @@ CommandLineInterface.prototype = {
   },
 
   getDomainStatuses: function(options, callback) {
-    this.cloudSearch.DescribeDomains(
-      options || {},
-      function(error, response) {
+    var domainStatusesCallback = function(error, response) {
         if (error) {
           console.log('Unexpected error: ' + JSON.stringify(error));
           process.exit(1);
@@ -156,9 +154,12 @@ CommandLineInterface.prototype = {
              .DescribeDomainsResult
              .DomainStatusList
              .member;
-        callback(null, domainStatuses);
-      }
-    );
+        (callback || options)(null, domainStatuses);
+      };
+    if (callback)
+      this.cloudSearch.DescribeDomains(options, domainStatusesCallback);
+    else
+      this.cloudSearch.DescribeDomains(domainStatusesCallback);
   },
 
   getIndexFieldStatuses: function(domainName, callback) {
@@ -169,12 +170,12 @@ CommandLineInterface.prototype = {
           console.log('Unexpected error: ' + JSON.stringify(error));
           process.exit(1);
         }
+
         var indexFields = response.Body
              .DescribeIndexFieldsResponse
              .DescribeIndexFieldsResult
-             .IndexFields
-             .member;
-        callback(null, indexFields);
+             .IndexFields;
+        callback(null, indexFields.members || []);
       }
     );
   },
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index