From 7d7e014bfeb785e1e142f2796b9609a6148539ab Mon Sep 17 00:00:00 2001 From: Lucas Dohmen Date: Thu, 31 Oct 2013 16:41:49 +0100 Subject: [PATCH 1/3] Only drop vertices when dropping a graph if vertices aren't used elsewhere --- js/common/tests/shell-graph.js | 15 +++++++++++++++ js/server/modules/org/arangodb/graph.js | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/js/common/tests/shell-graph.js b/js/common/tests/shell-graph.js index 7d0973cc6a..43ababc2c2 100644 --- a/js/common/tests/shell-graph.js +++ b/js/common/tests/shell-graph.js @@ -68,6 +68,21 @@ function GraphCreationSuite() { graph.drop(); }, + testDroppingIfVertexCollectionIsUsedTwice : function () { + var Graph = require("org/arangodb/graph").Graph, + graph_name = "UnitTestsCollectionGraph", + other_graph_name = "UnitTestsCollectionOtherGraph", + vertex = "UnitTestsCollectionVertex", + edges = "UnitTestsCollectionEdge", + other_edges = "UnitTestsCollectionOtherEdges", + graph = new Graph(graph_name, vertex, edges), + other_graph = new Graph(other_graph_name, vertex, other_edges); + + graph.drop(); + assertTrue(arangodb.db._collection("UnitTestsCollectionVertex") !== null); + other_graph.drop(); + }, + //////////////////////////////////////////////////////////////////////////////// /// @brief test: Find Graph //////////////////////////////////////////////////////////////////////////////// diff --git a/js/server/modules/org/arangodb/graph.js b/js/server/modules/org/arangodb/graph.js index 49884cf767..06d5ae17c8 100644 --- a/js/server/modules/org/arangodb/graph.js +++ b/js/server/modules/org/arangodb/graph.js @@ -555,7 +555,10 @@ Graph.prototype.drop = function (waitForSync) { gdb.remove(this._properties, true, waitForSync); - this._vertices.drop(); + if (gdb.byExample({vertices: this._vertices.name()}).count() === 0) { + this._vertices.drop(); + } + this._edges.drop(); }; From de04c3257cb1639ed764c6de4d16dc25b25c2c6f Mon Sep 17 00:00:00 2001 From: Heiko Kernbach Date: Thu, 31 Oct 2013 17:58:44 +0100 Subject: [PATCH 2/3] optimized sorting for documents - frontend --- .../js/collections/arangoDocuments.js | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/js/apps/system/aardvark/frontend/js/collections/arangoDocuments.js b/js/apps/system/aardvark/frontend/js/collections/arangoDocuments.js index 508cf0f638..100271f821 100644 --- a/js/apps/system/aardvark/frontend/js/collections/arangoDocuments.js +++ b/js/apps/system/aardvark/frontend/js/collections/arangoDocuments.js @@ -73,7 +73,7 @@ window.arangoDocuments = Backbone.Collection.extend({ if (this.documentsCount <= sortCount) { //sorted - myQueryVal = "FOR x in @@collection SORT x._key LIMIT @offset, @count RETURN x"; + myQueryVal = "FOR x in @@collection SORT TO_NUMBER(x._key) == 0 ? x._key : TO_NUMBER(x._key) LIMIT @offset, @count RETURN x"; } else { //not sorted @@ -132,23 +132,38 @@ window.arangoDocuments = Backbone.Collection.extend({ } else { filterString = ' FILTER' + filter.join(' && '); } - var body = { - //temp solution, waiting for api with paging possibility - query: "FOR u IN " + this.collectionID + - filterString + - " LIMIT 0," + self.documentsPerPage + - " RETURN u", - bindVars: bindValues, - options: { + + var sortCount = 10000; + + var sortString = ''; + if (this.documentsCount <= sortCount) { + //sorted + sortString = " SORT TO_NUMBER(u._key) == 0 ? u._key : TO_NUMBER(u._key)"; + } + var myQueryVal = "FOR u in @@collection" + filterString + sortString + + " LIMIT 0, @count RETURN u"; + + var myQuery = { + query: myQueryVal, + bindVars: { + "@collection": this.collectionID, + "count": this.documentsPerPage + }, + options: { fullCount: true - } + } }; + + $.each(bindValues, function(k,v) { + myQuery.bindVars[k] = v; + }); + $.ajax({ cache: false, type: 'POST', async: false, url: '/_api/cursor', - data: JSON.stringify(body), + data: JSON.stringify(myQuery), contentType: "application/json", success: function(data) { self.clearDocuments(); From d363f091d103c1e9e41894fc5aab6671016ef037 Mon Sep 17 00:00:00 2001 From: Heiko Kernbach Date: Thu, 31 Oct 2013 18:00:42 +0100 Subject: [PATCH 3/3] prep for selecting databases in frontend --- .../system/aardvark/frontend/js/routers/router.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/apps/system/aardvark/frontend/js/routers/router.js b/js/apps/system/aardvark/frontend/js/routers/router.js index 56732bc070..b1f696935e 100644 --- a/js/apps/system/aardvark/frontend/js/routers/router.js +++ b/js/apps/system/aardvark/frontend/js/routers/router.js @@ -19,6 +19,7 @@ $(document).ready(function() { "logs" : "logs", "about" : "about", "api" : "api", + "databases" : "databases", "application/installed/:key" : "applicationEdit", "application/available/:key" : "applicationInstall", "applications/installed" : "applicationsInstalled", @@ -31,6 +32,8 @@ $(document).ready(function() { initialize: function () { window.activeSession = new window.ArangoSession(); + window.arangoDatabase = new window.ArangoDatabase(); + window.arangoCollectionsStore = new window.arangoCollections(); window.arangoDocumentsStore = new window.arangoDocuments(); window.arangoDocumentStore = new window.arangoDocument(); @@ -189,6 +192,16 @@ $(document).ready(function() { this.naviView.selectMenuItem('api-menu'); }, + databases: function() { + if (!this.databaseView) { + this.databaseView = new window.databaseView({ + collection: arangoDatabase + }); + } + this.databaseView.render(); + this.naviView.selectMenuItem('database-menu'); + }, + about: function() { if (!this.aboutView) { this.aboutView = new window.aboutView();