Repository: incubator-htrace Updated Branches: refs/heads/master eff89a850 -> 55c7f39ea
HTRACE-192. gui: when expanding parents or children, sort the spans by begin time (cmccabe) Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/55c7f39e Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/55c7f39e Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/55c7f39e Branch: refs/heads/master Commit: 55c7f39ea1d8479036ba4ddc8d2e3ab83a184834 Parents: eff89a8 Author: Colin Patrick Mccabe <[email protected]> Authored: Wed Jun 17 12:21:29 2015 -0700 Committer: Colin Patrick Mccabe <[email protected]> Committed: Thu Jun 18 13:43:17 2015 -0700 ---------------------------------------------------------------------- htrace-webapp/src/main/web/app/span.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/55c7f39e/htrace-webapp/src/main/web/app/span.js ---------------------------------------------------------------------- diff --git a/htrace-webapp/src/main/web/app/span.js b/htrace-webapp/src/main/web/app/span.js index 553239e..d29f020 100644 --- a/htrace-webapp/src/main/web/app/span.js +++ b/htrace-webapp/src/main/web/app/span.js @@ -54,6 +54,18 @@ htrace.parseMultiSpanAjaxQueryResults = function(ajaxCalls) { return parsedSpans; }; +htrace.sortSpansByBeginTime = function(spans) { + return spans.sort(function(a, b) { + if (a.get("begin") < b.get("begin")) { + return -1; + } else if (a.get("begin") > b.get("begin")) { + return 1; + } else { + return 0; + } + }); +}; + htrace.getReifiedParents = function(span) { return span.get("reifiedParents") || []; }; @@ -169,6 +181,7 @@ htrace.Span = Backbone.Model.extend({ span.get("spanId") + ": " + e); return; } + reifiedParents = htrace.sortSpansByBeginTime(reifiedParents); // The current span is a child of the reified parents. There may be other // children of those parents, but we are ignoring that here. By making // this non-null, the "expand children" button will not appear for these @@ -219,6 +232,7 @@ htrace.Span = Backbone.Model.extend({ "for " + span.get("spanId") + ": " + e); return; } + reifiedChildren = htrace.sortSpansByBeginTime(reifiedChildren); // The current span is a parent of the new child. // There may be other parents, but we are ignoring that here. // By making this non-null, the "expand parents" button will not
