Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
Python-Jira 票证管理_创想鸟

Python-Jira 票证管理

python-jira 票证管理

您好,我刚刚发现了 jira lib,我决定对其进行测试,以找到获得最多门票的人。

我的github中的代码:https://github.com/victordalet/jira_python_test

一、安装

你只需要python并安装jira lib。

pip install jira

二 – 登录

用您的信息声明 3 个变量,并在安全中前往 https://id.atlassian.com/manage-profile/profile-and-visibility 生成您的令牌(密码)。

jira_url = "" # https://name.alassian.netjira_user = "" # me@name.frjira_password = "" # token

iii – lib 功能

我正在创建一个类来获取jira信息,它可以创建一种类似于get_tickets方法的mysql查询来查找资源或票证、项目…

class ticketmanager:    def __init__(self):        self.jira = jira(jira_url, basic_auth=(jira_user, jira_password))    def get_projects(self):        return self.jira.projects()    def get_tickets(self, project_key: str):        return self.jira.search_issues(f'project="{project_key}"')    @staticmethod    def ticket_status(ticket_):        return ticket_.fields.status    @staticmethod    def ticket_reporter(ticket_):        try:            return ticket_.fields.reporter        except attributeerror:            return "unknown"    @staticmethod    def ticket_assignee(ticket_):        try:            return ticket_.fields.assignee        except attributeerror:            return "unknown"

iv – 显示用户活动

我浏览该项目以找到所有门票并将正确的雕像添加到用户字典中。

if __name__ == '__main__':    ticket_manager = ticketmanager()    projects = ticket_manager.get_projects()    user = {}    nb_total_tickets = 0    for project in projects:        tickets = ticket_manager.get_tickets(project.key)        nb_total_tickets += len(tickets)        for ticket in tickets:            reporter = ticket_manager.ticket_reporter(ticket)            assignee = ticket_manager.ticket_assignee(ticket)            if assignee not in user:                user[assignee] = {'ticket_to_do': 0, 'ticket_reported': 0}            if reporter not in user:                user[reporter] = {'ticket_to_do': 0, 'ticket_reported': 0}            user[assignee]['ticket_to_do'] += 1            user[reporter]['ticket_reported'] += 1    print(f'there are {nb_total_tickets} tickets in total')

v – 排序并显示结果

现在我按照创建和使用的票证数量对用户进行排序。

    user = dict(sorted(user.items(), key=lambda x: (x[1]['ticket_to_do'], x[1]['ticket_reported']), reverse=true))    for name, value in user.items():        print(f'{name} : {value["ticket_to_do"]} tickets to do, {value["ticket_reported"]} tickets reported')

结果:

J.M. : 90 tickets to do, 60 tickets reportedL.M : 75 tickets to do, 21 tickets reportedJ.M : 57 tickets to do, 76 tickets reportedV.M : 50 tickets to do, 0 tickets reported

以上就是Python-Jira 票证管理的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1349512.html

赞 (0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
如何使用一个 API 创建 AI 聊天机器人来访问多个 LLM
上一篇 2025年12月13日 12:53:59
使用 FastAPI 构建 Todo API 的部分:分步指南
下一篇 2025年12月13日 12:54:08

相关推荐

发表回复

登录后才能评论
关注微信