This is an automated email from the ASF dual-hosted git repository.

willholley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git


The following commit(s) were added to refs/heads/master by this push:
     new 113c4d6  Mango: support multiple server-side warnings (#1245)
113c4d6 is described below

commit 113c4d6e5c973de407741d8616a5bb431224518a
Author: Will Holley <[email protected]>
AuthorDate: Fri Jan 10 08:16:01 2020 +0000

    Mango: support multiple server-side warnings (#1245)
    
    Changes the handling of mango warnings to support multiple warnings
    delimited by a newline, as added in 
https://github.com/apache/couchdb/pull/2410
---
 .../documents/mango/components/ExecutionStats.js    | 21 +++++++--------------
 bin/build-couchdb-dev.sh                            |  2 ++
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/app/addons/documents/mango/components/ExecutionStats.js 
b/app/addons/documents/mango/components/ExecutionStats.js
index 789a886..5c043d1 100644
--- a/app/addons/documents/mango/components/ExecutionStats.js
+++ b/app/addons/documents/mango/components/ExecutionStats.js
@@ -13,8 +13,6 @@ import React from 'react';
 import PropTypes from 'prop-types';
 import { Popover, OverlayTrigger } from 'react-bootstrap';
 
-const TOO_MANY_DOCS_SCANNED_WARNING = "The number of documents examined is 
high in proportion to the number of results returned. Consider adding an index 
to improve this.";
-
 export default class ExecutionStats extends React.Component {
   constructor (props) {
     super(props);
@@ -37,18 +35,13 @@ export default class ExecutionStats extends React.Component 
{
     return [minutes, ' ', minuteText, ', ', seconds, ' ', 
secondsText].join('');
   }
 
-  getWarning(executionStats, warning) {
-    if (!executionStats) { return warning; }
-
-    // warn if many documents scanned in relation to results returned
-    if (!warning && executionStats.results_returned) {
-      const docsExamined = executionStats.total_docs_examined || 
executionStats.total_quorum_docs_examined;
-      if (docsExamined / executionStats.results_returned > 10) {
-        return TOO_MANY_DOCS_SCANNED_WARNING;
-      }
+  getWarning(warnings) {
+    if (warnings) {
+      const lines = warnings.split('\n').map((warnText, i) => {
+        return <React.Fragment key={i}>{warnText}<br/></React.Fragment>;
+      });
+      return <span>{lines}</span>;
     }
-
-    return warning;
   }
 
   warningPopupComponent(warningText) {
@@ -95,7 +88,7 @@ export default class ExecutionStats extends React.Component {
       warning
     } = this.props;
 
-    const warningText = this.getWarning(executionStats, warning);
+    const warningText = this.getWarning(warning);
 
     let warningComponent = null;
     if (warningText) {
diff --git a/bin/build-couchdb-dev.sh b/bin/build-couchdb-dev.sh
index 6374ea0..4c08eed 100755
--- a/bin/build-couchdb-dev.sh
+++ b/bin/build-couchdb-dev.sh
@@ -11,6 +11,8 @@
 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 # License for the specific language governing permissions and limitations under
 # the License.
+set -xe
+
 if [[ $COUCHDB_IMAGE == "couchdb:dev" ]]; then
     git clone https://github.com/apache/couchdb-docker.git
     cd couchdb-docker

Reply via email to