Пример #1
0
def export_trello(config, boards, out_path):
    print("Exporting boards from Trello...")
    exported = []
    params = {'key': config['key'], 'token': config['token']}
    for board in boards:
        print("  Exporting board '{}'...".format(board['name']))
        board_url = "{}/boards/{}".format(config['url'], board['id']['trello'])
        resp_board = requests.get(board_url, params=params).json()

        labels = []
        resp_labels = requests.get(board_url + "/labels", params=params).json()
        for l in [x for x in resp_labels if x['id'] != '']:
            labels.append({k: l[k] for k in ['name','id','color'] if k in l})

        resp_cols = requests.get(board_url + "/lists", params=params).json()
        columns = [{'name': c['name'], 'id': c['id']} for c in resp_cols if not c['closed']]

        milestones = [] # trello has no milestones. See misc/approx_milestones.py
        
        opened = requests.get(board_url, params={**params, **{"cards":"visible"}}).json()["cards"]
        closed = requests.get(board_url, params={**params, **{"cards":"closed"}}).json()["cards"]
        show_findings(labels, [], columns, opened, closed)

        issues = []
        [issues.append(Issue(o, 'trello').__dict__) for o in opened]
        [issues.append(Issue(c, 'trello').__dict__) for c in closed]
        exported.append({
            'name': board['name'], 
            'id': resp_board['id'], 
            'labels': labels, 
            'milestones': milestones,
            'columns': columns, 
            'issues': issues
        })
    return exported
Пример #2
0
    def post(self, issue_id):
        r = client.repository('rainforestapp', 'GitSatisfaction')
        issue = Issue(r.issue(issue_id))

        j = tornado.escape.json_decode(self.request.body)

        issue.add_subscriber(j["email"])

        self.write(issue.to_json())
Пример #3
0
    def post(self, issue_id):
        r = client.repository('rainforestapp', 'GitSatisfaction')
        issue = Issue(r.issue(issue_id))

        j = tornado.escape.json_decode(self.request.body)

        issue.add_subscriber(j["email"])

        self.write(issue.to_json())
Пример #4
0
def get_issues_in_active_and_future_sprints_in_board(board_name):
    sprint_names = jira_client.get_active_and_future_sprint_names_in_board(
        board_name)

    issues_in_active_and_future_sprints = [
    ]  # [{'sprint_A': ['issue_A', ...]}, {'sprintB': ['issue_C'...]}...]
    for sprint_name in sprint_names:
        _issues = jira_client.search_issues(
            'sprint="{}" AND issuetype not in (Sub-task, 估點, Memo)'.format(
                sprint_name),
            startAt=0,
            maxResults=False)
        issues = []
        for _issue in _issues:
            issue_story_point = 0.0
            if customfield['story_point'] in _issue.raw['fields'].keys():
                issue_story_point = _issue.raw['fields'][
                    customfield['story_point']]

            issue = Issue()
            issue.issueKey = _issue.key
            issue.url = JIRA_URL + '/browse/{}'.format(_issue.key)
            issue.summary = _issue.fields.summary
            issue.description = _issue.fields.description
            issue.storyPoint = issue_story_point
            issue.sprintName = sprint_name
            issues.append(issue.__dict__)

        sprint = Sprint()
        sprint.sprintName = sprint_name
        sprint.issues = issues

        issues_in_active_and_future_sprints.append(sprint.__dict__)
    return jsonify(issues_in_active_and_future_sprints)
Пример #5
0
    def test_add_subscripber(self):
        g3_issue = Empty()
        g3_issue.body_text = ""
        g3_issue.id = 1
        g3_issue.title = 5
        def empty(*args, **kwargs):
            pass
        g3_issue.edit = empty

        issue = Issue(g3_issue)
        issue.add_subscriber("*****@*****.**")
        issue.add_subscriber("*****@*****.**")
        b = issue.to_json()['body']
        self.assertIn("listeners: [email protected],[email protected]", b)
Пример #6
0
    def test_add_subscripber(self):
        g3_issue = Empty()
        g3_issue.body_text = ""
        g3_issue.id = 1
        g3_issue.title = 5

        def empty(*args, **kwargs):
            pass

        g3_issue.edit = empty

        issue = Issue(g3_issue)
        issue.add_subscriber("*****@*****.**")
        issue.add_subscriber("*****@*****.**")
        b = issue.to_json()['body']
        self.assertIn("listeners: [email protected],[email protected]", b)
Пример #7
0
 def get_participated_issues(cls, user_id, state=None):
     from models.issue import Issue
     issues_created = cls.gets_by_creator_id(user_id, state)
     issues = [issue for issue in Issue.gets_by_participated_user(user_id,
                                                                  state)
               if issue not in issues_created]
     return issues
Пример #8
0
def get_issues_list_from_db(token):
    curs = Cursor(urlsafe=token)
    issues, curs, _ = Issue.query().order(-Issue.id).fetch_page(10, start_cursor=curs)
    if issues:
        issues_list = {}
        if curs:
            issues_list['pagetoken'] = curs.urlsafe()
        issues_list['issues'] = []
        for issue in issues:
            issues_list['issues'].append(issue.minimize())
        return issues_list
    return None
Пример #9
0
    def on_post(self, req, resp):
        ''' Issues Controller Post Request Method '''

        try:
            issue = Issue(title=req.get_json('title'),
                          description=req.get_json('description'),
                          author=ObjectId(req.get_json('author')),
                          resolved_by=ObjectId(req.get_json('resolved_by')))
            issue.save()
            resp.json = issue.to_json()
        except Exception as e:
            resp.status = falcon.HTTP_400
            if hasattr(e, 'title') and hasattr(e, 'description'):
                resp.json = {"message": "%s - %s" % (e.title, e.description)}
Пример #10
0
def sync_issues():
    req = requests.get('http://www.themagpi.com/mps_api/mps-api-v1.php?mode=list_issues')
    old_issues = json.loads(req.text)
    if not 'data' in old_issues:
        return flask.jsonify( { 'error' : 'empty issue data from MagPi' } ) , 500
    for old_issue in old_issues['data']:
        issue = Issue(key=Issue.generate_key(old_issue['title']))
        issue.fill_from_old(old_issue)
        issue.put()
    return flask.jsonify( { 'status' : 'issues sync done' } ), 200
Пример #11
0
def issue_update(_id):
    issue = Issue.get_by_id(_id)
    if request.method == "POST":
        status = request.form["status"]
        customer_id = request.form["customer_id"]
        description = request.form['description']
        date_start = request.form['date_start']
        date_start = datetime.strptime(date_start, '%Y-%m-%d')

        issue.status = status
        issue.customer_id = customer_id
        issue.description = description
        issue.date_start = date_start
        issue.save_to_mongo()
        return redirect(url_for("customer.find_customers"))
    return render_template('issues/issue_update.html', issue=issue)
def get_issues_by_jql():
    pagination_start_at = 0
    pagination_max_results = 100
    # pagination_max_results = 2
    pagination_total = 9999999

    options = {"server": config.jira_base_url}
    jira = JIRA(basic_auth=(config.jira_user, config.jira_api_key),
                options=options)
    issues = {}
    data = []

    while pagination_total > pagination_start_at:
        issues = jira.search_issues(config.jira_jql,
                                    maxResults=pagination_max_results,
                                    startAt=pagination_start_at)
        print("Total: ")
        print(issues.total)
        for item in issues:
            changelog = get_issue_changelog(item.key)
            issue = Issue(
                item.key, item.id, maya.parse(item.fields.created),
                maya.parse(item.fields.resolutiondate)
                if item.fields.resolutiondate != None else "",
                item.fields.issuetype.name if item.fields.issuetype != None
                else "", item.fields.status.name, item.fields.summary,
                item.fields.assignee.displayName
                if item.fields.assignee != None else "",
                item.fields.assignee.raw['avatarUrls']['48x48']
                if item.fields.assignee != None else "",
                item.fields.aggregatetimeoriginalestimate)

            issue.time_in_status = get_issue_time_in_status(issue, changelog)
            issue.cycle_time = sum_time_in_statuses(
                issue.time_in_status, config.cycle_time_status_to_consider)
            issue.lead_time = sum_time_in_statuses(
                issue.time_in_status, config.lead_time_status_to_consider)
            issue.waiting_time = sum_time_in_statuses(issue.time_in_status,
                                                      config.waiting_status)
            issue.child_count = get_issue_child_count(issue.key)
            data.append(issue)
            print(len(data))

        # pagination_start_at = pagination_total
        pagination_start_at += pagination_max_results
        pagination_total = issues.total

    print(len(data))
    return data
Пример #13
0
def issue_create(_id):
    if request.method == 'POST':
        status = request.form["status"]
        customer_id = _id
        description = request.form['description']
        date_start = request.form['date_start']
        if date_start is not '':
            date_start = datetime.strptime(date_start, '%Y-%m-%d')
        else:
            flash("a date is always required", "danger")
            return render_template("issues/issue_create.html")
        if customer_id and status and description and date_start is not '':
            Issue(status, customer_id, description, date_start).save_to_mongo()
            return redirect(url_for("customer.find_customers"))
        else:
            flash("enter correct data in all fields", "danger")
    return render_template("/issues/issue_create.html")
Пример #14
0
from models.label import Label
from models.milestone import Milestone
from models.issue import Issue
from templates import simple
import sys

project_id = sys.argv[1]

lbl_result = {}
mls_result = {}

for label in simple.labels:
    lbl_result[label['name']] = Label(project_id).create(label)

for milestone in simple.milestones:
    mls_result[milestone['title']] = Milestone(project_id).create(milestone)
    for task in simple.issues[milestone['title']]:
        print(mls_result[milestone['title']])
        task['milestone_id'] = mls_result[milestone['title']]['id']
        print(Issue(project_id).create(task))
Пример #15
0
 def issue(self):
     from models.issue import Issue
     return Issue.get_cached_issue(self.issue_id)
Пример #16
0
def get_issue_by_issue_id(issue_id):
    from models.issue import Issue
    issue = Issue.get_cached_issue(issue_id)
    return issue
Пример #17
0
 def gets_by_assignee_id(cls, user_id, state=None):
     from models.issue import Issue
     return Issue.gets_by_assignee_id(user_id, state)
Пример #18
0
def issues_index(customer_id):
    if request.method == 'GET':
        issues = Issue.find_issues(customer_id)
        issues = sorted(issues, key=lambda issues: str(issues.date_start))
        return render_template('/issues/issues_index.html', issues=issues)
Пример #19
0
 def get(self):
     r = client.repository('rainforestapp', 'GitSatisfaction')
     out = []
     for issue in r.iter_issues(state='open'):
         out.append(Issue(issue).to_json())
     self.write(json.dumps(out))
Пример #20
0
def issues_request() -> "list":
    if request.method == "POST":
        status = request.form["status"]
        issues = Issue.find_by_status(status)
        return render_template('/issues/issues_status.html', issues=issues)
    return render_template("/issues/issues_request.html")
Пример #21
0
def get_issue_from_db(issue):
    issues = Issue.query(Issue.id==issue).fetch()
    if issues:
        return issues[0].maximize()
    return None
Пример #22
0
def _q_lookup(request, uid):
    if uid.isdigit():
        issue = Issue.get_cached_issue(uid)
        if issue:
            return IssueUI(issue)
    raise TraversalError