couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [couchdb-fauxton] branch master updated: Show a warning in Fauxton when no Mango index is available (#952)
Date Mon, 14 Aug 2017 08:46:19 GMT
This is an automated email from the ASF dual-hosted git repository.

garren 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 0e16e06  Show a warning in Fauxton when no Mango index is available (#952)
0e16e06 is described below

commit 0e16e06df79dc2006a83ecd631c7d1750d615578
Author: Will Holley <willholley@gmail.com>
AuthorDate: Mon Aug 14 09:46:17 2017 +0100

    Show a warning in Fauxton when no Mango index is available (#952)
    
    Mango allows queries to run without an index by performing a full
    database scan. Whilst this is useful in some scenarios, Couch
    returns a warning in the response that an index should be created
    if performance is important. This warning is now propagated
    to Fauxton using the existing alert infrastructure.
---
 app/addons/documents/index-results/actions.js | 13 +++++++++++++
 app/addons/documents/resources.js             |  7 +++++++
 2 files changed, 20 insertions(+)

diff --git a/app/addons/documents/index-results/actions.js b/app/addons/documents/index-results/actions.js
index 619cfe3..f51d88d 100644
--- a/app/addons/documents/index-results/actions.js
+++ b/app/addons/documents/index-results/actions.js
@@ -45,6 +45,17 @@ export default {
     });
   },
 
+  notifyOfWarnings: function (options) {
+    var msg = options.collection.warning && options.collection.warning();
+    if (msg) {
+      FauxtonAPI.addNotification({
+        msg: msg,
+        clear:  false,
+        type: 'error'
+      });
+    }
+  },
+
   newResultsList: function (options) {
     this.clearResults();
 
@@ -87,6 +98,8 @@ export default {
   },
 
   newMangoResultsList: function (options) {
+    this.notifyOfWarnings(options);
+
     FauxtonAPI.dispatch({
       type: ActionTypes.INDEX_RESULTS_NEW_RESULTS,
       options: options
diff --git a/app/addons/documents/resources.js b/app/addons/documents/resources.js
index 6542193..ca7d43e 100644
--- a/app/addons/documents/resources.js
+++ b/app/addons/documents/resources.js
@@ -179,6 +179,7 @@ Documents.MangoDocumentCollection = PagingCollection.extend({
   initialize: function (_attr, options) {
     var defaultLimit = FauxtonAPI.constants.MISC.DEFAULT_PAGE_SIZE;
 
+    this._warning = null;
     this.database = options.database;
     this.params = _.extend({limit: defaultLimit}, options.params);
 
@@ -198,6 +199,10 @@ Documents.MangoDocumentCollection = PagingCollection.extend({
     return this.urlRef.apply(this, arguments);
   },
 
+  warning: function () {
+    return this._warning;
+  },
+
   updateSeq: function () {
     return false;
   },
@@ -287,6 +292,8 @@ Documents.MangoDocumentCollection = PagingCollection.extend({
 
     this.paging.hasNext = this.paging.hasPrevious = false;
 
+    this._warning = resp.warning;
+
     this.viewMeta = {
       total_rows: resp.total_rows,
       offset: resp.offset,

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <commits@couchdb.apache.org>'].

Mime
View raw message