diff --git a/htrace-core/src/web/app/models/span.js b/htrace-core/src/web/app/models/span.js index 06b6b3c..0076db7 100644 --- a/htrace-core/src/web/app/models/span.js +++ b/htrace-core/src/web/app/models/span.js @@ -59,7 +59,8 @@ app.Spans = Backbone.PageableCollection.extend({ url: "/query", state: { pageSize: 10, - lastSpanId: null, + nextSpanId: null, + finished: false, predicates: [] }, queryParams: { @@ -78,7 +79,7 @@ app.Spans = Backbone.PageableCollection.extend({ */ query: function() { var predicates = this.state.predicates.slice(0); - var lastSpanId = this.state.lastSpanId; + var nextSpanId = this.state.nextSpanId; /** * Use last pulled span ID to paginate. @@ -86,16 +87,16 @@ app.Spans = Backbone.PageableCollection.extend({ * Adding a predicate to the end of the predicates list won't change the order. * Providing the predicate on spanid will filter all previous spanids. */ - if (lastSpanId) { + if (nextSpanId) { predicates.push({ - "op": "gt", + "op": "ge", "field": "spanid", - "val": lastSpanId + "val": nextSpanId }); } return JSON.stringify({ - lim: this.state.pageSize, + lim: this.state.pageSize + 1, pred: predicates }); } @@ -111,17 +112,25 @@ app.Spans = Backbone.PageableCollection.extend({ }, parseLinks: function(resp, xhr) { - if (resp.length >= this.state.pageSize) { - this.state.lastSpanId = resp[resp.length - 1].s; + this.state.finished = resp.length <= 10; - return { - "next": "/query?query=" + this.queryParams.query.call(this) - }; + if (this.state.finished) { + this.state.nextSpanId = null; } else { - this.state.lastSpanId = null; - + this.state.nextSpanId = resp[10].s; + } + + if (this.state.finished) { return {}; } + + return { + "next": "/query?query=" + this.queryParams.query.call(this) + }; + }, + + parseRecords: function(resp) { + return resp.slice(0, 10); }, setPredicates: function(predicates) { diff --git a/htrace-core/src/web/app/setup.js b/htrace-core/src/web/app/setup.js index 90915e3..3c32118 100644 --- a/htrace-core/src/web/app/setup.js +++ b/htrace-core/src/web/app/setup.js @@ -67,17 +67,20 @@ var Router = Backbone.Marionette.AppRouter.extend({ } } }), - "editable": false + "editable": false, + "sortable": false }, { "name": "spanId", "label": "ID", "cell": "string", - "editable": false + "editable": false, + "sortable": false }, { "name": "processId", "label": "processId", "cell": "string", - "editable": false + "editable": false, + "sortable": false }, { "label": "Duration", "cell": Backgrid.Cell.extend({ @@ -91,12 +94,14 @@ var Router = Backbone.Marionette.AppRouter.extend({ } } }), - "editable": false + "editable": false, + "sortable": false }, { "name": "description", "label": "Description", "cell": "string", - "editable": false + "editable": false, + "sortable": false }], "row": Backgrid.Row.extend({ "events": {