Update Comment Author and Created using Jira python library - jira

I have been able to create a comment but can't firgure out how to create it with a particualr author and timestamp. Ayone figure this out? This creates the comment:
newComment = jira.add_comment(newIssue, strComment)
Now I can't find a way to update the author or created time. I have tried the following to create a string with all three like they do for the csv import:
strComment = dtobj.strftime("%x %X %p") + ';' + comment.author.accountId + ';' + comment.body
Also tried using the update method:
newIssue.update(author=userhexid)

I think with on-prem REST API you can only add a comment with the current user as the author and the current date.
https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/issue-addComment

Related

Joins queries in Ruby on Rails

Hi I am trying to run a joins query in rails. I am trying to output specific data from my User model while also getting data from my contactDetails model.. Code:
User.where(user_type: :lender).all.each do |user|
result <<
"#{user.id}, " +
"#{user.contact_details},"
end
The above prints out fine but when I add:
User.where(user_type: :lender).all.each do |user|
result <<
"#{user.id}, " +
"#{user.contact_details}," +
"#{user.contact_details.city}," +
"#{user.contact_details.region}, "
end
Cannot find region or city.
I think what's happening is user.contact_details is returning nil.
That would allow the first interpolation to work, as "#{nil}" just returns an empty string.
However, in the second example, when you call user.contact_details.city and user.contact_details.region, you're calling the methods city and region on nil, hence the error.
You can account for this using the safe operator to return empty strings, i.e.
user.contact_details&.city
# or in older Ruby versions
user.contact_details.try(:city)
Whether you want to have empty strings returned when the association exists is up to you, however, if you don't want them adding you could do something like:
result_string = user.id.to_s
if user.contact_details.present?
result_string += "#{user.contact_details}," +
"#{user.contact_details.city}," +
"#{user.contact_details.region}, "
end
result << result_string
Finally, if you're expecting contact_details to be present, the problem likely lies in their creation and attachment to the user model - if that's the case, I'd suggest having a look at how you're doing this, and opening a new question with the relevant info if you can't get it to work.
Hope that helps - let me know if you've any questions on this at all.
I have solved this using present? method and then placing Ternary operators inside the code to a none applicable message for users who have not provided contact details. There was no need to add includes or joins:
User.where(user_type: :lender).all.each do |user|
result <<
"#{user.id}, " +
"#{user.contact_details.present? ? user.contact_details.country : ' N/A '}," +
"#{user.contact_details.present? ? user.contact_details.region : ' N/A ' }," +
"#{user.contact_details.present? ? user.contact_details.city : ' N/A '}"
end

Flattening data with Firebase

After reading the documentation here:
https://www.firebase.com/docs/ios/guide/structuring-data.html
I am working on flattening my data. Here is the issue I am facing at the moment, in the code below:
let firebaseDBNameUnit = ["titleString": "name1"],
firebaseNameRef = topRef.childByAppendingPath("MyApp/Name")
firebaseNameRef.childByAutoId().setValue(firebaseDBNameUnit) // *
let firebaseDBContentUnit = ["contentString": "very long content 1 11 111 1111 etc... blah blah blah"],
firebaseContentRef = topRef.childByAppendingPath("MyApp/Content")
// The following line is where my question is:
firebaseContentRef.childByAutoId().setValue(firebaseDBContentUnit)
I would like to change the last line in the code above, to use an ID which is the same as the one produced in the line marked *. How can I do that?
In order to create a relationship between Name and Content, I could of course create a field of my own, but it would be so much better to use the ID already provided by Firebase.
When you call childByAutoId() it returns a reference to the new location. If you capture that in a variable, you can use it:
let unitRef = firebaseNameRef.childByAutoId()
unitRef.setValue(firebaseDBNameUnit)
...
firebaseContentRef.childByAppendingPath(unitRef.key).setValue(firebaseDBContentUnit)

EF5 need update ContainerName.FunctionImportName for accessing Stored Procedure when updating models, Any charming solution?

I'm new to entity framework, please forgive me if my question is too simple.
I'm using EF5 build my project at the moment, there is one Function Import "GetStockItem" in my project, which calls a stored procedure and returns data from SP. Every time when I "Update Model from database" from Model Diagram, the update wizard reflects the changes of database without problem, but GetStockItem stops working. The error message when I call GetStockItem is:
"The value of EntityCommand.CommandText is not valid for a StoredProcedure command. The EntityCommand.CommandText value must be of the form 'ContainerName.FunctionImportName'."
The solution, as instructed in the error message is clear, all I need is to add ContainerName. before the FunctionImportName (GetStockItem in my case) in the context.cs file.
My question is how can I avoid the from happening every time when I update models from database? It's quite annoying to do this manual thing now and then, and it's easy to forget to do this then cause users' complaint.
Hope someone can enlighten me with charming solution! Cheers!
I just ran into this using EF5/DbContext. The solution I found was to edit the T4 template ([Model].Context.tt) that generates the DbContext.
In this file, locate the instructions for generating the ExecuteFunction call. For me, it started on line 288:
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
{
var parameters = _typeMapper.GetParameters(edmFunction);
var returnType = _typeMapper.GetReturnType(edmFunction);
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
if (includeMergeOption)
{
callParams = ", mergeOption" + callParams;
}
return string.Format(
CultureInfo.InvariantCulture,
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
edmFunction.Name,
callParams);
}
Modify the return line so that edmFunction.Name is replaced with edmFunction.FullName and upon saving, the Function Import code will be regenerated using fully-qualified names.
I had a similar issue, I suggest not to change the context.cs file at all; only make sure the connection strings in app.config file generated by EF is the same in the calling project, especially the metadata that in the connection string is very important to be correct. If it helps, please mark this answer accepted otherwise send me the steps to reproduce this error.

Sublime text 2 Plugin Development - How do I get the language of the current file

== UPDATE ===
So I realized that Sublime already has a command for adding comments. So if I have code inserted like this:
comment = " ----------------------------------------" + '\n'
comment += " " + title + '\n'
comment += " #author " + author + '\n'
comment += " #url " + url + '\n'
comment += " ---------------------------------------" + '\n'
comment = self.view.run_command('toggle_comment')
code = items['code']
layout = comment + code
self.view.replace(edit, sel[0], layout)
How do I get the command to work so that it comments out the comment variable? Thanks.
Initial Question
I am creating a plugin for Sublime Text 2 and want to make sure that when it inserts/replaces code it inserts comments as well, but to do this I need for it to insert the correct comment types for the various languages. I know that I can run the following command:
view.settings().get('syntax')
And that will return something like this:
Packages/Python/Python.tmLanguage
Is there a way to have it return just PHP, Python, C++, etc.
I'm sure I could do a substring command in Python, but since I can see an easy way of seeing all file settings I wanted to make sure there wasn't a quick easy way of doing this. Thanks for the help.
Are you looking for scope_name ?
scope_name(point) | String | Returns the syntax name assigned to the character at the given point.

Grails: Replacing symbols with HTML equivalent

I'm reading a CSV file and one of the columns has text that contains symbols that is not recognized. After I read the file, symbols such as ' becomes � . I'm also saving this into a DB.
Obviously when I display this on a webpage, it shows garbage. How can I substitute HTML code (ex. &#180 ;) for this with Grails?
I am reading the CSV using the csv plugin. Code below:
def f = "clientDocs/testfile.csv"
def fReader = new File(f).toCsvMapReader([batchSize:50, charset:'UTF-8'])
fReader.each { batchList ->
batchList.each {
def description = substituteSymbols(it.Description)
def substituteSymbols(inText) {
// HOW TO SUBSTITUTE HERE
}
Thanks for any help or suggestions. I've already tried string.replaceAll(regExp).
Grails comes with a basic set of encoders/decoders for common tasks.
What you want here is it.Description.encodeAsHTML().
And then if you want the original when displaying in the view, just reverse it with .decodeHTML()
You can read more about these here: http://grails.org/doc/latest/guide/single.html#codecs
(Edited decode method name typo as per the comment)

Resources