Software Development and Programming Careers (Official Discussion Thread)

Rev Leon Lonnie Love

damned mine eyes, DAMNED mine eyes!!
Joined
Nov 11, 2017
Messages
21,913
Reputation
5,478
Daps
88,997
In Python

I'm connecting I've got 2 questions:
1. I'm connecting to the Jira API to pull ticket\issue data, how do I pull the all the comments for each issue?
2. How do I output JSON here?



I got daps, reps, and coli cash.
I just read the docs now. So it seems like to get a comment of an issue, you have to access it using the instance you created of the JIRA class. It has two methods tto access a comment:
- comment : this method takes an issue instance object as its input plus the issue's ID and then returns the comment as an instance of the jira.Comment class. you can use methods provided by this Comment class to accomplish whatever it is you want. here is the Comment class documentation: 6. API Documentation — jira-python 0.1.dev50+g7fa3a45 documentation
- comments: this method returns a list of Comment class objects for a particular issue. Im assuming this is probably what you want since you want to access all comments per issue.

Example
-----------
Code:
    try:
        for issue in issues:
        print("ticket-no: ", issue)
        print("IssueType: ", issue.fields.issuetype.name)
        print("Status: ", issue.fields.status.name)
        print("Summary: ", issue.fields.summary)
        # update comment
        comment_list = jira.comments(issue)
        for comment in comment_list:
            # re-write all comments
            comment.update(body='im a coli poster')

    except:
        print("Error")
        continue

It seems like there is very limited stuff you can do with the Comment objects because they only have one public method: "update()", and looking at its source it seems like the only usable parameters of that update method are "body" and "visibility". Comment is a subclass of the Resource class so you can extend the Comment class by making you own and then dig into the Resource class to create your custom methods that accomplish whatever task you can do. See the resource class source code here: jira.resources — jira-python 0.1.dev50+g7fa3a45 documentation

I hope this helps somehow. Let me know how it goes @Sonny Bonds
 

Rev Leon Lonnie Love

damned mine eyes, DAMNED mine eyes!!
Joined
Nov 11, 2017
Messages
21,913
Reputation
5,478
Daps
88,997
Also as a further suggestion to @Sonny Bonds , it seems like you are using an unofficial API to access Jira and it appears to not have many features. Why not use the official one from
atlassian? As shown in their github page, you can use Jira via:
Code:
from atlassian import Jira

jira = Jira(
    url='http://localhost:8080',
    username='admin',
    password='admin')
JQL = 'project = DEMO AND status IN ("To Do", "In Progress") ORDER BY issuekey'
data = jira.jql(JQL)
print(data)

The documentation for the JIra module is here: Jira module — Atlassian Python API 1.15.3 documentation
and it contains a plethora of features to access issues:
Code:
# Get issue by key
jira.issue(key)

# Get issue field value
jira.issue_field_value(key, field)

# Update issue field
fields = {'summary': 'New summary'}
jira.update_issue_field(key, fields)

# Get existing custom fields or find by filter
get_custom_fields(self, search=None, start=1, limit=50):

# Rename sprint
jira.rename_sprint(sprint_id, name, start_date, end_date)

# Check issue exists
jira.issue_exists(issue_key)

# Check issue deleted
jira.issue_deleted(issue_key)

# Update issue
jira.issue_update(issue_key, fields)

# Create issue
jira.issue_create(fields)

# Issue create or update
jira.issue_create_or_update(fields)

# Get issue transitions
jira.get_issue_transitions(issue_key)

# Get status ID from name
jira.get_status_id_from_name(status_name)

# Get transition id to status name
jira.get_transition_id_to_status_name(issue_key, status_name)

# Transition issue
jira.issue_transition(issue_key, status)

# Set issue status
jira.set_issue_status(issue_key, status_name)

# Set issue status by transition_id
jira.set_issue_status_by_transition_id(issue_key, transition_id)

# Get issue status
jira.get_issue_status(issue_key)

# Create or Update Issue Links
jira.create_or_update_issue_remote_links(issue_key, link_url, title, global_id=None, relationship=None)

# Get Issue Link by link ID
jira.get_issue_remote_link_by_id(issue_key, link_id)

# Update Issue Link by link ID
jira.update_issue_remote_link_by_id(issue_key, link_id, url, title, global_id=None, relationship=None)

# Delete Issue Links
jira.delete_issue_remote_link_by_id(issue_key, link_id)
 

Obreh Winfrey

Truly Brehthtaking
Supporter
Joined
Nov 18, 2016
Messages
20,852
Reputation
25,252
Daps
131,941
Been thinking about getting a personal blog to document my development and shyt I learn on a daily/weekly. Today I went ahead and created one. :ehh:


@Sonny Bonds no feedback after we went out of our way to help? :ufdup:
I was going to do the same thing but I ain't got no drive :mjlol:
 

Rev Leon Lonnie Love

damned mine eyes, DAMNED mine eyes!!
Joined
Nov 11, 2017
Messages
21,913
Reputation
5,478
Daps
88,997
I was going to do the same thing but I ain't got no drive :mjlol:
Same here, but after I realized that I study new things almost daily then it makes sense to take those notes in a form of a blog. Not sure how long I can maintain this but because its a pandemic and im looking for a new gig then it should be doable.
 

Obreh Winfrey

Truly Brehthtaking
Supporter
Joined
Nov 18, 2016
Messages
20,852
Reputation
25,252
Daps
131,941
Same here, but after I realized that I study new things almost daily then it makes sense to take those notes in a form of a blog. Not sure how long I can maintain this but because its a pandemic and im looking for a new gig then it should be doable.
I was going to spin up a WordPress instance on Azure but I'm a tightwad. I have a separate tutorial on Docker kicking around but I didn't finish writing it. I wanted to gear it towards college students and get them some practical knowledge they could apply on day 1.
 

Rev Leon Lonnie Love

damned mine eyes, DAMNED mine eyes!!
Joined
Nov 11, 2017
Messages
21,913
Reputation
5,478
Daps
88,997
I was going to spin up a WordPress instance on Azure but I'm a tightwad. I have a separate tutorial on Docker kicking around but I didn't finish writing it. I wanted to gear it towards college students and get them some practical knowledge they could apply on day 1.
Why not try hosting it via githubpages? If you dont mind having a static site then use Hugo or Jekyll as a server. It is easier to maintain and pretty lightweight. I used this tutorial to set it up: Create a Free Blog Site Using GitHub Pages and Hugo
 

Obreh Winfrey

Truly Brehthtaking
Supporter
Joined
Nov 18, 2016
Messages
20,852
Reputation
25,252
Daps
131,941
Why not try hosting it via githubpages? If you dont mind having a static site then use Hugo or Jekyll as a server. It is easier to maintain and pretty lightweight. I used this tutorial to set it up: Create a Free Blog Site Using GitHub Pages and Hugo
That was also a route I was going to take years back but got side tracked with other stuff. I may look into it again though.
 

Sonny Bonds

Superstar
Supporter
Joined
Apr 24, 2014
Messages
4,622
Reputation
916
Daps
13,259
@Sonny Bonds no feedback after we went out of our way to help? :ufdup:
My bad, breh. On Friday, I didn't have the Jira comments done, but what I had was good enough to start a new sprint task continuing to write the script. It's due in 2 weeks. I have to pull the Jira comments.

Having the output as JSON and changing the Jira project name via command line are other goals are other requirements too, but I already got those done last time.
 

Carlton Banks

Upper Class
Bushed
Supporter
Joined
Dec 9, 2014
Messages
20,720
Reputation
3,036
Daps
79,084
So... I realized that I'm actually not a fan of front end and prefer back end development and that's why I been struggling. I'd rather do the logic/problem solving stuff than the designing and UI stuff.
 

TheAnointedOne

Superstar
Joined
Jul 30, 2012
Messages
7,784
Reputation
666
Daps
30,669
You'll get better.

it was their simple twosum bullshyt. Was trying to come up with some samurai-type ninja solution with O(n) or better complexity

Code:
std::vector<int> twoSum( std::vector<int>& nums, int target ) {

    std::vector<int> indices;
    std::map<int, int> diff_map;
    std::size_t idx = 0;

    std::for_each(nums.begin(), nums.end(), [&](int value) {
        diff_map.insert({target-value, idx++});
        });  

    for (unsigned int n = 0; n < nums.size(); n++) {
        if (diff_map.find(nums[n]) != diff_map.end()) {
            if (n != diff_map[nums[n]]) {
                indices.push_back(n);
                indices.push_back(diff_map[nums[n]]);
                return indices;
            }
        }
    }

    return { 0 };
}
 
Top