I am trying to use the following code to get a pie chart for the latest testresult from a particular testset.
pieconfig = {
type: 'TestCaseResult',
attribute: 'Verdict',
query: rally.sdk.util.Query.and(['TestSet = "' + testsetDropdown.getValue() + '"','Date < "2012-11-01"'])
};
var pieChart = new rally.sdk.ui.PieChart(pieconfig,rallyDataSource);
pieChart.display("pieChartDiv");
In this code I've put today's date manually, but I want to make this query as of a generic type which should pull the latest testresult from a specific testset. Any hints...? Thank you.
Rally has a nice DateTime format that formats dates to whatever you want. Here's the reference you can use: http://developer.rallydev.com/help/datetime.
If you always want the current day in the year-month-day format, you can do this:
var dateQuery = 'Date < ' + rally.sdk.util.DateTime.format(new Date(), "yyyy-MM-dd");
Then your query will look something like this:
query: rally.sdk.util.Query.and(['TestSet = "' + testsetDropdown.getValue() + '"', dateQuery])
EDIT: Now I see what you mean by grabbing the latest TestCaseResult. You don't actually need the Date conditional in your query. What you need to add is a couple of options to your pie config.
var pieconfig = {
type: 'TestCaseResult',
attribute: 'Verdict',
query: '(Test Set = "' + testsetDropdown.getValue() + '")',
order: 'CreationDate desc',
pagesize: 1
};
This will sort by the Creation Date in descending order, which means the most recently made TestCaseResult will be on top. Setting a pagesize to 1 means you'll always get the most recent result.
This also solves the issue of not getting test case results of the current day. The previous query will get all TestCaseResults from today at 12:00AM backward. So any test case results made in the current day will not be included.
Let me know if that doesn't work out for you. I'm pretty new to the Rally SDK1 query system.
Related
Problem: Change the Date input field from "mm/dd/yyyy" to "dd/mm/yyyy".
I already know how to change after i receive the date, but the problem is that when the client is typing the input is still receiving "mm/dd/yyyy".
My mongoose schema:
const schemaRegister = new mongoose.Schema({
date: Date,
});
My input area:
<b-form-input v-mask="'##/##/####'" v-model="date"></b-form-input>
My date formating (using momentsjs):
changeDateFormat() {
let fixedDate = moment(this.registers[i].date).format("L");
this.registers[i].date = fixedDate;
}
I am displaying the 'fixedDate' on the table, but it doesn't help a lot because when the client is typing he thinks the first 2 slots are the days (dd), but in reality they are the month (mm). As a solution i thought of using the Date as a String but then it would make the verification very difficult.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
just pass the parameters in the correct order, like this:
new Date(day, monthIndex, year);
I wasn't using the 'momentsjs' correctly, first i needed to parse the input date by using
let formatedDate = moment(this.date,"DD-MM-YYYY");
and then for displaying the date i should have used
let fixedDate = moment(this.registers.date).format("DD/MM/YYYY");
I want to get the last data created on my database, more specifically the field called: "Saldo Atual" and after this get the form data field "Valor" and make a sum between this fields (the Old one "Saldo Atual" and the new "Valor") before create a new record and add this "Valor" and the sum of "Saldo Atual"+"Valor".
I don't know how to get the database last record
var saldoAtual =
record.saldoAtual = saldoAtual + record.valor;
And I want to know if the second line it's correct to save the sum of "Saldo Atual"+"Valor"
Based on my comment, I think that your records will need to have a Date_Created field. Then in your onBeforeCreate event the following script should work (this is untested, so you need to do your own testing):
var query = app.models.YourModelTheSameAsYourEventModel.newQuery();
query.sorting.Date_Created._descending();
query.limit = 1;
var lastrecord = query.run();
record.saldoAtual = lastrecord.saldoAtual + record.valor; //You may need to use lastrecord[0].saldoAtual
record.Created_Date = new Date();
Try that and do some testing to see if this yields your desired output.
According to this article:
https://blogs.msdn.microsoft.com/alexj/2009/10/12/tip-37-how-to-do-a-conditional-include/#comment-5225
I learned how to do a conditional include.
But now I need some lower level children like if a review has Marks, I need to fetch for each review the collection of Marks also. Any idea how to do this?
Query:
var movie = readOnlyRepository.GetById<Movie>(
movieId, false);
var dbquery = from mv in movie
select new
{
mv,
reviews = from review in mv.Reviews
where review.Mark = 10
select review
};
var result = dbquery.AsEnumerable().Select(x=> x.mv).First();
Given that Review has a collection of Marks I need that included in the result.
I currently use GF for reservations 'Arrive' and 'Departure'. I would like the date displayed on the 'Departure' to always be one date ahead of the 'Arrival' date, regards of what date the guest picks. Then can pick a custom 'Departure' date, but as a default I'd like to show one date forward of the 'Arrival' date no matter what 'Arrival' date they choose.
This is possible with the gform_datepicker_options_pre_init JS filter. Example #3 is what you're after:
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 12 && fieldId == 8 ) {
optionsObj.minDate = 0;
optionsObj.onClose = function (dateText, inst) {
jQuery('#input_12_9').datepicker('option', 'minDate', dateText).datepicker('setDate', dateText);
};
}
return optionsObj;
});
If you're looking for a code-less solution, I've written a plugin that let's you do this in just a few clicks called GP Limit Dates.
Also, here is an article that addresses your specific need: How to restrict dates in second date field based on date selected in first date field with Gravity Forms
var data = d3.nest()
.key(function(d) { return d.date;})
.rollup(function(d) {
return d3.sum(d, function(g) {return g.something; });
}).entries(csv_data);
using this code above I can group by date which is in the format yyyy-mm-dd , but I want to group using the month as key. How do I do this ?
You can use the builtin method d3.timeMonth() to get the first day of the month for a date like:
d3.nest()
.key(function(d){ return d3.timeMonth(d.date); });
If d.date is not already a javascript Date object you have to first parse it to be one.
var date_format = d3.timeFormat("%Y-%m-%d");
csv_data.forEach(function(d, i) {
d.date = date_format.parse(d.date);
};
You need to change the key function to return the value you want to nest by. In most cases, the key function just returns a property of the data object (like d.date), but in your case the function will require a little more calculation.
If your date is stored as a string of the format "yyyy-mm-dd" you have two options for extracting the month: either
use regular expressions to extract the portion of the string in between the "-" characters, or
convert it to a date object and use date methods to extract a component of the date.
Browsers differ in which date formats they can convert using the native Javascript new Date(string) constructor, so if you're using date objects you may want to use a d3 date format function's format.parse(string) method to be sure of consistent results.