Rally Analytics set the startindex for a query - rally

I have a query for the Rally Analytics which returns a data set larger than the pagesize. So I want to do another query to return the remainder data set. I tried setting a startindex value but that does not work, StartIndex stays at 0.
this.query = {
find:Ext.encode(requestedQuery.find),
StartIndex:20000,
pagesize:20000 //MAX_PAGESIZE
};
_queryAnalyticsApi:function () {
Ext.Ajax.request({
url:"https://rally1.rallydev.com/analytics/1.27/" + this.workspace + "/artifact/snapshot/query.js?" + Ext.Object.toQueryString(this.query) +
"&fields=" + JSON.stringify(this.requestedFields) + "&sort={_ValidFrom:1}",
method:"GET",
//need to change this to a POST
success:function (response) {
this._afterQueryReturned(JSON.parse(response.responseText));
},
scope:this
});
},

that works, it was confusing because the attribute of the result set is called StartIndex. It would be nice if the granularity (i.e. day, week) could be defined and handled on the server first, so it wouldn't have to return such a large dataset.

The parameter you'll want to use is called start. Also, on subsequent pages it is important to include a filter using the ETLDate returned from the first page of data so your results are consistent in time. We have created a SnapshotStore in the AppSDK 2.0 that handles all this complexity for you. Look for it soon!

Related

columnSummary is not added

I am trying to add columnSummary to my table using Handsontable. But it seems that the function does not fire. The stretchH value gets set and is set properly. But it does not react to the columnSummary option:
this.$refs.hot.hotInstance.updateSettings({stretchH: 'all',columnSummary: [
{
destinationRow: 0,
destinationColumn: 2,
reversedRowCoords: true,
type: 'custom',
customFunction: function(endpoint) {
console.log("TEST");
}
}]
}, false);
I have also tried with type:'sum' without any luck.
Thanks for all help and guidance!
columnSummary cannot be changed with updateSettings: GH #3597
You can set columnSummary settings at the initialization of Handsontable.
One workaround would be to somehow manage your own column summary, since Handsontable one could give you some headeache. So you may try to add one additional row to put your arithmetic in, but it is messy (it needs fixed rows number and does not work with filtering and sorting operations. Still, it could work well under some circumstances.
In my humble opinion though, a summary column has to be fully functionnal. We then need to set our summary row out of the table data. What comes to mind is to take the above mentioned additional row and take it away from the table data "area" but it would force us to make that out of the table row always looks like it still was in the table.
So I thought that instead of having a new line we could just have to add our column summary within column header:
Here is a working JSFiddle example.
Once the Handsontable table is rendered, we need to iterate through the columns and set our column summary right in the table cell HTML content:
for(var i=0;i<tableConfig.columns.length;i++) {
var columnHeader = document.querySelectorAll('.ht_clone_top th')[i];
if(columnHeader) { // Just to be sure column header exists
var summaryColumnHeader = document.createElement('div');
summaryColumnHeader.className = 'custom-column-summary';
columnHeader.appendChild( summaryColumnHeader );
}
}
Now that our placeholders are set, we have to update them with some arithmetic results:
var printedData = hotInstance.getData();
for(var i=0;i<tableConfig.columns.length;i++) {
var summaryColumnHeader = document.querySelectorAll('.ht_clone_top th')[i].querySelector('.custom-column-summary'); // Get back our column summary for each column
if(summaryColumnHeader) {
var res = 0;
printedData.forEach(function(row) { res += row[i] }); // Count all data that are stored under that column
summaryColumnHeader.innerText = '= '+ res;
}
}
This piece of code function may be called anytime it should be:
var hotInstance = new Handsontable(/* ... */);
setMySummaryHeaderCalc(); // When Handsontable table is printed
Handsontable.hooks.add('afterFilter', function(conditionsStack) { // When Handsontable table is filtered
setMySummaryHeaderCalc();
}, hotInstance);
Feel free to comment, I could improve my answer.

Need a counter column for a datatable with server side processing

I need to add one extra column to the datatable. This column will have incrementing serial no like 1, 2, 3, 4 etc...
I found this example, but this is not working for server side processing and I want searching-sorting working(if possible) which is also not here.
https://datatables.net/examples/api/counter_columns.html
Notes:
1) Datatable uses server side processing.
2) Sorting and searching should work on that counter column. (if possible)
3) Would be good, if I can achieve it completely on the client side using js. I don't want to make any code at server side for this(if possible).
4) Pagination should update counter no serially means if the previous page has last counter no 15, then next page should start with counter 16.
By the way I also checked this:
"Column Index" on a server-side processed DataTable
But accepted answer of this question violates my 4th requirement.
Any help would be appreciated.
Thanks,
Parth Vora
If anyone still has this problem, I solved it with draw event listener and DataTable's page.info() method. My code:
table.on('draw.dt', function () {
var info = table.page.info();
table.column(0, { search: 'applied', order: 'applied', page: 'applied' }).nodes().each(function (cell, i) {
cell.innerHTML = i + 1 + info.start;
});
});
table.on('draw.dt', function () {
var info = table.page.info();
table.column(0, { search: 'applied', order: 'applied', page: 'applied' }).nodes().each(function (cell, i) {
cell.innerHTML = i + 1 + info.start;
});
});
IT WILL WORK FINE "Thank You Brother Your Code usefull..Mansur Anorboev "

DataTables convert incoming epoch date to dd/mm/yyyy

I am using an AJAX call with datatables to populate a table. The format of the incoming data is:
{
"name": "John Doe",
"date":1244231200500
}
I can see that date formatting is discussed here: https://datatables.net/blog/2014-12-18 but there's no clear instructions for epoch data conversion.
What I want to do is put something (like within the example at the datatables site) like:
$.fn.dataTable.moment('epoch');
...but I don't see an option. What's the best approach here?
If you include moment.js you can sort this out quite easily using moment within a render function of your columns option array. Something like this should work:
{
"data":"date",
"render": function(data){
return moment.unix(data).format("DD/MM/YYYY")
}
}
Hope that helps.
You could create your own formatting function:
function ISODateString(d) {
function pad(n) { return n < 10 ? '0' + n : n }
return pad(d.getDate()) + '/' + pad(d.getMonth() + 1) + '/' + d.getFullYear();
}
And call it in datatables render:
"render": function(data){
var d = new Date(parseInt(data.substr(6), 0));
return ISODateString(d);
}

Run function every time animation repeats

Here's a script that animates a bouncing square:
http://jsfiddle.net/YH9nM/18/
var count = 1,
tM = new TimelineLite(),
element = $('#boxy');
function log(){
console.log('just bounced');
element.html('I\'ve bounced: ' + count + ' times!');
count++;
}
tM.from( element, 2, { top:'-=60px', ease: Linear.easeNone, repeat: -1, onRepeat: log() }, 0 );
However, that onRepeat option is not behaving as I'd expect. Rather than triggering the log function every time the animation repeats, it runs it once when the animation starts the first time.
It's behaving exactly as the onStart option would. Why is this happening? How can I make the div count how many times it's bounced ad infinitum?
You're running the log function when you define your tween, by using log(), and are assigning the return value of log to onRepeat (which is undefined since you don't return anything). You want the onRepeat var to be assigned to the log function
change
onRepeat: log()
to
onRepeat: log
You can see this in action here.
Patrick did actually answer the question, but here's what you want to do if you wish to pass parameters to a function you wish to run onRepeat:
onRepeatParams: ['as','many','parameters','as',1,true,'ly','wants'];
I also believe the most efficient way to access the element the timeline is applied to is through using the self keyword like this:
onRepeatParams: ["{self}"];
and then in the function doing this:
$(element.target).html('I\'ve bounced: ' + count + ' times!');
Here's what I mean in context:
var count = 1,
tM = new TimelineLite(),
element = $('#boxy');
function log(element){
console.log('just bounced');
$(element.target).html('I\'ve bounced: ' + count + ' times!');
count++;
}
tM.from( element, 2, { top:'-=60px', ease: Linear.easeNone, repeat: -1, onRepeat: log, onRepeatParams: ["{self}"] }, 0 );
http://jsfiddle.net/YH9nM/23/

"update" query - error invalid input synatx for integer: "{39}" - postgresql

I'm using node js 0.10.12 to perform querys to postgreSQL 9.1.
I get the error error invalid input synatx for integer: "{39}" (39 is an example number) when I try to perform an update query
I cannot see what is going wrong. Any advise?
Here is my code (snippets) in the front-end
//this is global
var gid=0;
//set websockets to search - works fine
var sd = new WebSocket("ws://localhost:0000");
sd.onmessage = function (evt)
{
//get data, parse it, because there is more than one vars, pass id to gid
var received_msg = evt.data;
var packet = JSON.parse(received_msg);
var tid = packet['tid'];
gid=tid;
}
//when user clicks button, set websockets to send id and other data, to perform update query
var sa = new WebSocket("ws://localhost:0000");
sa.onopen = function(){
sa.send(JSON.stringify({
command:'typesave',
indi:gid,
name:document.getElementById("typename").value,
}));
sa.onmessage = function (evt) {
alert("Saved");
sa.close;
gid=0;//make gid 0 again, for re-use
}
And the back -end (query)
var query=client.query("UPDATE type SET t_name=$1,t_color=$2 WHERE t_id = $3 ",[name, color, indi])
query.on("row", function (row, result) {
result.addRow(row);
});
query.on("end", function (result) {
connection.send("o");
client.end();
});
Why this not work and the number does not get recognized?
Thanks in advance
As one would expect from the initial problem, your database driver is sending in an integer array of one member into a field for an integer. PostgreSQL rightly rejects the data and return an error. '{39}' in PostgreSQL terms is exactly equivalent to ARRAY[39] using an array constructor and [39] in JSON.
Now, obviously you can just change your query call to pull the first item out of the JSON array. and send that instead of the whole array, but I would be worried about what happens if things change and you get multiple values. You may want to look at separating that logic out for this data structure.