You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2014/03/14 21:09:16 UTC

couchdb commit: updated refs/heads/master to b8accb4

Repository: couchdb
Updated Branches:
  refs/heads/master a17bf86af -> b8accb4eb


Fauxton: highlight databases with more deleted docs than existing

Fixes COUCHDB-2110


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b8accb4e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b8accb4e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b8accb4e

Branch: refs/heads/master
Commit: b8accb4eb7c46e3888416afc4aff407487f2f21c
Parents: a17bf86
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Fri Mar 14 20:45:31 2014 +0100
Committer: Robert Kowalski <ro...@kowalski.gd>
Committed: Fri Mar 14 20:45:43 2014 +0100

----------------------------------------------------------------------
 src/fauxton/app/addons/databases/resources.js   |  8 ++++
 .../app/addons/databases/templates/item.html    |  8 +++-
 .../app/addons/databases/tests/resourcesSpec.js | 39 ++++++++++++++++++++
 src/fauxton/app/addons/databases/views.js       |  1 +
 4 files changed, 55 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/b8accb4e/src/fauxton/app/addons/databases/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/resources.js b/src/fauxton/app/addons/databases/resources.js
index 80cd533..f8aab96 100644
--- a/src/fauxton/app/addons/databases/resources.js
+++ b/src/fauxton/app/addons/databases/resources.js
@@ -123,6 +123,14 @@ function(app, FauxtonAPI, Documents) {
       return this.get("doc_count");
     },
 
+    numDeletedDocs: function() {
+      return this.get("doc_del_count");
+    },
+
+    isGraveYard: function() {
+      return this.numDeletedDocs() > this.numDocs();
+    },
+
     updateSeq: function(full) {
       var updateSeq = this.get("update_seq");
       if (full || (typeof(updateSeq) === 'number')) {

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b8accb4e/src/fauxton/app/addons/databases/templates/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/templates/item.html b/src/fauxton/app/addons/databases/templates/item.html
index 549f421..304ab78 100644
--- a/src/fauxton/app/addons/databases/templates/item.html
+++ b/src/fauxton/app/addons/databases/templates/item.html
@@ -16,7 +16,13 @@ the License.
   <a href="#/database/<%=encoded%>/_all_docs"><%= database.get("name") %></a>
 </td>
 <td><%= database.status.humanSize() %></td>
-<td><%= database.status.numDocs() %></td>
+<td>
+  <%= database.status.numDocs() %>
+  <% if (database.status.isGraveYard()) { %>
+    <i class="js-db-graveyard icon icon-exclamation-sign" data-toggle="tooltip"
+      title="This database has just <%= database.status.numDocs() %> docs and <%= database.status.numDeletedDocs() %> deleted docs"></i>
+  <% } %>
+</td>
 <td><%= database.status.updateSeq() %></td>
 <td>
   <a class="db-actions btn fonticon-replicate set-replication-start" title="Replicate <%= database.get("name") %>" href="#/replication/new/<%=encoded%>"></a>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b8accb4e/src/fauxton/app/addons/databases/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/tests/resourcesSpec.js b/src/fauxton/app/addons/databases/tests/resourcesSpec.js
new file mode 100644
index 0000000..8e3fee4
--- /dev/null
+++ b/src/fauxton/app/addons/databases/tests/resourcesSpec.js
@@ -0,0 +1,39 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+define([
+      'api',
+      'addons/databases/resources',
+      'addons/databases/views',
+      'testUtils'
+], function (FauxtonAPI, Resources, Views, testUtils) {
+  var assert = testUtils.assert,
+      ViewSandbox = testUtils.ViewSandbox;
+
+  describe("Databases: List", function () {
+
+    describe("List items", function () {
+
+      it("detects graveyards", function () {
+        var modelWithGraveYard = new Resources.Status({
+          doc_count: 5,
+          doc_del_count: 6
+        });
+        var modelWithoutGraveYard = new Resources.Status({
+          doc_count: 6,
+          doc_del_count: 5
+        });
+        assert.ok(modelWithGraveYard.isGraveYard());
+        assert.ok(!modelWithoutGraveYard.isGraveYard());
+      });
+    });
+  });
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/b8accb4e/src/fauxton/app/addons/databases/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/views.js b/src/fauxton/app/addons/databases/views.js
index ef52b2f..d632486 100644
--- a/src/fauxton/app/addons/databases/views.js
+++ b/src/fauxton/app/addons/databases/views.js
@@ -137,6 +137,7 @@ function(app, Components, FauxtonAPI, Databases) {
         }
       });
       this.dbSearchTypeahead.render();
+      this.$el.find(".js-db-graveyard").tooltip();
     },
 
     selectAll: function(evt){