mirror of https://gitee.com/bigwinds/arangodb
Bug fix 3.4/ui optimize graph load (#9831)
* release version 3.4.8 * iterate through all vertexCollections of a graph to find a vertex to display * changelog * Remote first dot in v.3.4.9
This commit is contained in:
parent
34481860a9
commit
e2844ec995
|
@ -1,6 +1,9 @@
|
|||
v3.4.9 (2019-XX-XX)
|
||||
v3.4.9 (XXXX-XX-XX)
|
||||
-------------------
|
||||
|
||||
* The graph viewer of the web interface now tries to find a vertex document of
|
||||
all available vertex collections before it aborts.
|
||||
|
||||
* Bugfix: Save distinct WAL ticks for multiple replication clients from the same
|
||||
server. Also, when a follower is added for synchronous replication, the WAL
|
||||
tick held by the client is freed immediately, rather than waiting for a
|
||||
|
|
|
@ -562,14 +562,9 @@ authRouter.get('/graph/:name', function (req, res) {
|
|||
if (!verticesCollections || verticesCollections.length === 0) {
|
||||
res.throw('bad request', 'no vertex collections found for graph');
|
||||
}
|
||||
var vertexName;
|
||||
try {
|
||||
vertexName = verticesCollections[Math.floor(Math.random() * verticesCollections.length)].name();
|
||||
} catch (err) {
|
||||
res.throw('bad request', 'vertex collection of graph not found');
|
||||
}
|
||||
|
||||
var vertexCollections = [];
|
||||
|
||||
_.each(graph._vertexCollections(), function (vertex) {
|
||||
vertexCollections.push({
|
||||
name: vertex.name(),
|
||||
|
@ -577,7 +572,6 @@ authRouter.get('/graph/:name', function (req, res) {
|
|||
});
|
||||
});
|
||||
|
||||
var startVertex;
|
||||
var config;
|
||||
|
||||
try {
|
||||
|
@ -586,25 +580,40 @@ authRouter.get('/graph/:name', function (req, res) {
|
|||
res.throw('bad request', e.message, {cause: e});
|
||||
}
|
||||
|
||||
var getPseudoRandomStartVertex = function (collName) {
|
||||
let maxDoc = db[collName].count();
|
||||
if (maxDoc === 0) {
|
||||
return null;
|
||||
}
|
||||
if (maxDoc > 1000) {
|
||||
maxDoc = 1000;
|
||||
}
|
||||
let randDoc = Math.floor(Math.random() * maxDoc);
|
||||
var getPseudoRandomStartVertex = function () {
|
||||
for (var i = 0; i < graph._vertexCollections().length; i++) {
|
||||
var vertexCollection = graph._vertexCollections()[i];
|
||||
let maxDoc = db[vertexCollection.name()].count();
|
||||
|
||||
return db._query(
|
||||
'FOR vertex IN @@vertexCollection LIMIT @skipN, 1 RETURN vertex',
|
||||
{
|
||||
'@vertexCollection': collName,
|
||||
'skipN': randDoc
|
||||
if (maxDoc === 0) {
|
||||
continue;
|
||||
}
|
||||
).toArray()[0];
|
||||
|
||||
if (maxDoc > 1000) {
|
||||
maxDoc = 1000;
|
||||
}
|
||||
|
||||
let randDoc = Math.floor(Math.random() * maxDoc);
|
||||
|
||||
let potentialVertex = db._query(
|
||||
'FOR vertex IN @@vertexCollection LIMIT @skipN, 1 RETURN vertex',
|
||||
{
|
||||
'@vertexCollection': vertexCollection.name(),
|
||||
'skipN': randDoc
|
||||
}
|
||||
).toArray()[0];
|
||||
|
||||
if (potentialVertex) {
|
||||
return potentialVertex;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
var multipleIds;
|
||||
var startVertex; // will be "randomly" choosen if no start vertex is specified
|
||||
|
||||
if (config.nodeStart) {
|
||||
if (config.nodeStart.indexOf(' ') > -1) {
|
||||
multipleIds = config.nodeStart.split(' ');
|
||||
|
@ -615,11 +624,11 @@ authRouter.get('/graph/:name', function (req, res) {
|
|||
res.throw('bad request', e.message, {cause: e});
|
||||
}
|
||||
if (!startVertex) {
|
||||
startVertex = getPseudoRandomStartVertex(vertexName);
|
||||
startVertex = getPseudoRandomStartVertex();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
startVertex = getPseudoRandomStartVertex(vertexName);
|
||||
startVertex = getPseudoRandomStartVertex();
|
||||
}
|
||||
|
||||
var limit = 0;
|
||||
|
@ -633,7 +642,7 @@ authRouter.get('/graph/:name', function (req, res) {
|
|||
if (startVertex === null) {
|
||||
toReturn = {
|
||||
empty: true,
|
||||
msg: 'Your graph is empty',
|
||||
msg: 'Your graph is empty. We did not find a document in any available vertex collection.',
|
||||
settings: {
|
||||
vertexCollections: vertexCollections
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue