From d7c190d73ac06b36a4e841dbbd5d58a159a954f0 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Fri, 31 Dec 2021 15:01:51 +0800 Subject: [PATCH] chore: add a new pr reminder based on github id (#7350) --- .github/workflows/bot.yaml | 7 + scripts/pr_reminder.py | 377 +------------ scripts/pr_reminder_basedon_assignee.py | 669 ++++++++++++++++++++++++ 3 files changed, 703 insertions(+), 350 deletions(-) create mode 100644 scripts/pr_reminder_basedon_assignee.py diff --git a/.github/workflows/bot.yaml b/.github/workflows/bot.yaml index 7460982fa572f..a2bad7c629706 100644 --- a/.github/workflows/bot.yaml +++ b/.github/workflows/bot.yaml @@ -16,3 +16,10 @@ jobs: wget https://raw.githubusercontent.com/pingcap/docs/master/scripts/pr_reminder.py; pip3 install lxml; python3 pr_reminder.py "$WEBHOOK" + - name: Run PR reminder by assignee + env: + WEBHOOK: ${{secrets.BOT_WEBHOOK_URL}} + run: | + wget https://raw.githubusercontent.com/pingcap/docs/master/scripts/pr_reminder_basedon_assignee.py; + pip3 install lxml; + python3 pr_reminder_basedon_assignee.py "$WEBHOOK" diff --git a/scripts/pr_reminder.py b/scripts/pr_reminder.py index 9cadc13b3f35d..1edb90ba8dae3 100644 --- a/scripts/pr_reminder.py +++ b/scripts/pr_reminder.py @@ -66,35 +66,6 @@ def get_pr_no(url): 待处理 PR 数目如下,按优先级排序 ************************************************* -v5.4 发版文档,中文文档截止日期 2021-01-07,英文文档截止日期 2021-01-18 - -- sig/sql-infra 和 sig/planner - - - docs-cn 仓库中有 {v54_zh_open_sqlinfra_planner} PR 未合并,有 {v54_zh_close_sqlinfra_planner} PR 待翻译 - - docs 仓库中有 {v54_en_open_sqlinfra_planner} PR 未合并,有 {v54_en_close_sqlinfra_planner} PR 待翻译 - -- sig/engine 和 sig/scheduling - - - docs-cn 仓库中有 {v54_zh_open_engine_scheduling} PR 未合并,有 {v54_zh_close_engine_scheduling} PR 待翻译 - - docs 仓库中有 {v54_en_open_engine_scheduling} PR 未合并,有 {v54_en_close_engine_scheduling} PR 待翻译 - -- sig/migrate 和 area/dm - - - docs-cn 仓库中有 {v54_zh_open_migrate_dm} PR 未合并,有 {v54_zh_close_migrate_dm} PR 待翻译 - - docs 仓库中有 {v54_en_open_migrate_dm} PR 未合并,有 {v54_en_close_migrate_dm} PR 待翻译 - -- sig/bigdata、sig/tiup 和 sig/diagnosis - - - docs-cn 仓库中有 {v54_zh_open_bigdata_tiup_diagnosis} PR 未合并,有 {v54_zh_close_bigdata_tiup_diagnosis} PR 待翻译 - - docs 仓库中有 {v54_en_open_bigdata_tiup_diagnosis} PR 未合并,有 {v54_en_close_bigdata_tiup_diagnosis} PR 待翻译 - -- sig/transaction 和 area/security - - - docs-cn 仓库中有 {v54_zh_open_transaction_security} PR 未合并,有 {v54_zh_close_transaction_security} PR 待翻译 - - docs 仓库中有 {v54_en_open_transaction_security} PR 未合并,有 {v54_en_close_transaction_security} PR 待翻译 - -************************************************* - type/compatibility-or-feature-change 标签 兼容性变更类文档,刻不容缓,请尽快处理: @@ -125,26 +96,6 @@ def get_pr_no(url): data = { 'date': datetime.utcnow().strftime('%Y-%m-%d'), - 'v54_zh_open_sqlinfra_planner': str(get_pr_no(docs_cn_url + open_url+ sig_sql_infra + v54) + get_pr_no(docs_cn_url + open_url+ sig_planner + v54)), - 'v54_zh_close_sqlinfra_planner': str(get_pr_no(docs_cn_url + close_url+ sig_sql_infra + v54) + get_pr_no(docs_cn_url + close_url+ sig_planner + v54)), - 'v54_en_open_sqlinfra_planner': str(get_pr_no(docs_url + open_url+ sig_sql_infra + v54) + get_pr_no(docs_url + open_url+ sig_planner + v54)), - 'v54_en_close_sqlinfra_planner': str(get_pr_no(docs_url + close_url+ sig_sql_infra + v54) + get_pr_no(docs_url + close_url+ sig_planner + v54)), - 'v54_zh_open_engine_scheduling': str(get_pr_no(docs_cn_url + open_url+ sig_engine + v54) + get_pr_no(docs_cn_url + open_url+ sig_scheduling + v54)), - 'v54_zh_close_engine_scheduling': str(get_pr_no(docs_cn_url + close_url+ sig_engine + v54) + get_pr_no(docs_cn_url + close_url+ sig_scheduling + v54)), - 'v54_en_open_engine_scheduling': str(get_pr_no(docs_url + open_url+ sig_engine + v54) + get_pr_no(docs_url + open_url+ sig_scheduling + v54)), - 'v54_en_close_engine_scheduling': str(get_pr_no(docs_url + close_url+ sig_engine + v54) + get_pr_no(docs_url + close_url+ sig_scheduling + v54)), - 'v54_zh_open_migrate_dm': str(get_pr_no(docs_cn_url + open_url + sig_migrate + v54) + get_pr_no(docs_cn_url + open_url + area_dm + v54)), - 'v54_zh_close_migrate_dm': str(get_pr_no(docs_cn_url + close_url + sig_migrate + v54) + get_pr_no(docs_cn_url + close_url + area_dm + v54)), - 'v54_en_open_migrate_dm': str(get_pr_no(docs_url + open_url + sig_migrate + v54) + get_pr_no(docs_url + open_url + area_dm + v54)), - 'v54_en_close_migrate_dm': str(get_pr_no(docs_url + close_url + sig_migrate + v54) + get_pr_no(docs_url + close_url + area_dm + v54)), - 'v54_zh_open_bigdata_tiup_diagnosis': str(get_pr_no(docs_cn_url + open_url + sig_bigdata + v54) + get_pr_no(docs_cn_url + open_url + sig_tiup + v54) + get_pr_no(docs_cn_url + open_url + sig_diagnosis + v54)), - 'v54_zh_close_bigdata_tiup_diagnosis': str(get_pr_no(docs_cn_url + close_url + sig_bigdata + v54) + get_pr_no(docs_cn_url + close_url + sig_tiup + v54) + get_pr_no(docs_cn_url + close_url + sig_diagnosis + v54)), - 'v54_en_open_bigdata_tiup_diagnosis': str(get_pr_no(docs_url + open_url + sig_bigdata + v54) + get_pr_no(docs_url + open_url + sig_tiup + v54) + get_pr_no(docs_url + open_url + sig_diagnosis + v54)), - 'v54_en_close_bigdata_tiup_diagnosis': str(get_pr_no(docs_url + close_url + sig_bigdata + v54) + get_pr_no(docs_url + close_url + sig_tiup + v54) + get_pr_no(docs_url + close_url + sig_diagnosis + v54)), - 'v54_zh_open_transaction_security': str(get_pr_no(docs_cn_url + open_url + sig_transaction + v54) + get_pr_no(docs_cn_url + open_url + area_security + v54)), - 'v54_zh_close_transaction_security': str(get_pr_no(docs_cn_url + close_url + sig_transaction + v54) + get_pr_no(docs_cn_url + close_url + area_security + v54)), - 'v54_en_open_transaction_security': str(get_pr_no(docs_url + open_url + sig_transaction + v54) + get_pr_no(docs_url + open_url + area_security + v54)), - 'v54_en_close_transaction_security': str(get_pr_no(docs_url + close_url + sig_transaction + v54) + get_pr_no(docs_url + close_url + area_security + v54)), 'compat_open_zh': str(get_pr_no(compat_open_url_zh)), 'compat_close_zh': str(get_pr_no(compat_close_url_zh)), 'compat_open_en': str(get_pr_no(compat_open_url_en)), @@ -157,26 +108,6 @@ def get_pr_no(url): 'bugfix_close_zh': str(get_pr_no(bugfix_close_url_zh)), 'bugfix_open_en': str(get_pr_no(bugfix_open_url_en)), 'bugfix_close_en': str(get_pr_no(bugfix_close_url_en)), - 'v54_zh_open_sqlinfra_planner_url': 'https://github.com/pingcap/docs-cn/pulls?q=is%3Apr+label%3Asig%2Fsql-infra%2Csig%2Fplanner+label%3Av5.4+is%3Aopen', - 'v54_zh_close_sqlinfra_planner_url': 'https://github.com/pingcap/docs-cn/pulls?q=is%3Apr+label%3Asig%2Fsql-infra%2Csig%2Fplanner+label%3Av5.4+is%3Aclosed+label%3Atranslation%2Fdoing', - 'v54_en_open_sqlinfra_planner_url': 'https://github.com/pingcap/docs/pulls?q=is%3Apr+label%3Asig%2Fsql-infra%2Csig%2Fplanner+label%3Av5.4+is%3Aopen', - 'v54_en_close_sqlinfra_planner_url': 'https://github.com/pingcap/docs/pulls?q=is%3Apr+label%3Asig%2Fsql-infra%2Csig%2Fplanner+label%3Av5.4+is%3Aclosed+label%3Atranslation%2Fdoing+', - 'v54_zh_open_engine_scheduling_url': 'https://github.com/pingcap/docs-cn/pulls?q=is%3Apr+label%3Asig%2Fengine%2Csig%2Fscheduling+label%3Av5.4+is%3Aopen+', - 'v54_zh_close_engine_scheduling_url': 'https://github.com/pingcap/docs-cn/pulls?q=is%3Apr+label%3Asig%2Fengine%2Csig%2Fscheduling+label%3Av5.4+is%3Aclosed+label%3Atranslation%2Fdoing', - 'v54_en_open_engine_scheduling_url': 'https://github.com/pingcap/docs/pulls?q=is%3Apr+label%3Asig%2Fengine%2Csig%2Fscheduling+label%3Av5.4+is%3Aopen+', - 'v54_en_close_engine_scheduling_url': 'https://github.com/pingcap/docs/pulls?q=is%3Apr+label%3Asig%2Fengine%2Csig%2Fscheduling+label%3Av5.4+label%3Atranslation%2Fdoing+is%3Aclosed', - 'v54_zh_open_migrate_dm_url': 'https://github.com/pingcap/docs-cn/pulls?q=is%3Apr+label%3Asig%2Fmigrate%2Carea%2Fdm+label%3Av5.4+is%3Aopen+', - 'v54_zh_close_migrate_dm_url': 'https://github.com/pingcap/docs-cn/pulls?q=is%3Apr+label%3Asig%2Fmigrate%2Carea%2Fdm+label%3Av5.4+is%3Aclosed+label%3Atranslation%2Fdoing', - 'v54_en_open_migrate_dm_url': 'https://github.com/pingcap/docs/pulls?q=is%3Apr+label%3Asig%2Fmigrate%2Carea%2Fdm+label%3Av5.4+is%3Aopen+', - 'v54_en_close_migrate_dm_url': 'https://github.com/pingcap/docs/pulls?q=is%3Apr+label%3Asig%2Fmigrate%2Carea%2Fdm+label%3Av5.4+is%3Aclosed+label%3Atranslation%2Fdoing', - 'v54_zh_open_bigdata_tiup_diagnosis_url': 'https://github.com/pingcap/docs-cn/pulls?q=is%3Apr+label%3Asig%2Fbigdata%2Csig%2Ftiup%2Csig%2Fdiagnosis+label%3Av5.4+is%3Aopen', - 'v54_zh_close_bigdata_tiup_diagnosis_url': 'https://github.com/pingcap/docs-cn/pulls?q=is%3Apr+label%3Asig%2Fbigdata%2Csig%2Ftiup%2Csig%2Fdiagnosis+label%3Av5.4+is%3Aclosed+label%3Atranslation%2Fdoing', - 'v54_en_open_bigdata_tiup_diagnosis_url': 'https://github.com/pingcap/docs/pulls?q=is%3Apr+label%3Asig%2Fbigdata%2Csig%2Ftiup%2Csig%2Fdiagnosis+label%3Av5.4+is%3Aopen', - 'v54_en_close_bigdata_tiup_diagnosis_url': 'https://github.com/pingcap/docs/pulls?q=is%3Apr+label%3Asig%2Fbigdata%2Csig%2Ftiup%2Csig%2Fdiagnosis+label%3Av5.4+is%3Aclosed+label%3Atranslation%2Fdoing+', - 'v54_zh_open_transaction_security_url': 'https://github.com/pingcap/docs-cn/pulls?q=is%3Apr+label%3Asig%2Ftransaction%2Carea%2Fsecurity+label%3Av5.4+is%3Aopen', - 'v54_zh_close_transaction_security_url': 'https://github.com/pingcap/docs/pulls?q=is%3Apr+label%3Asig%2Ftransaction%2Carea%2Fsecurity+label%3Av5.4+is%3Aclosed+label%3Atranslation%2Fdoing', - 'v54_en_open_transaction_security_url': 'https://github.com/pingcap/docs/pulls?q=is%3Apr+label%3Asig%2Ftransaction%2Carea%2Fsecurity+label%3Av5.4+is%3Aopen', - 'v54_en_close_transaction_security_url': 'https://github.com/pingcap/docs/pulls?q=is%3Apr+label%3Asig%2Ftransaction%2Carea%2Fsecurity+label%3Av5.4+is%3Aclosed+label%3Atranslation%2Fdoing', 'compat_open_url_zh': compat_open_url_zh, 'compat_close_url_zh': compat_close_url_zh, 'compat_open_url_en': compat_open_url_en, @@ -207,7 +138,7 @@ def get_pr_no(url): "content": { "post": { "zh-CN": { - "title": "待处理的 PR 数目报告", + "title": "待处理的非发版文档 PR 数目报告", "content": [ [ { @@ -218,19 +149,7 @@ def get_pr_no(url): [ { "tag": "text", - "text": "待处理 PR 数目如下,按优先级排序" - } - ], - [ - { - "tag": "text", - "text": "*************************************************" - } - ], - [ - { - "tag": "text", - "text": "v5.4 发版文档,中文文档截止日期 2021-01-07,英文文档截止日期 2021-01-18" + "text": "待处理 PR 数目如下,按优先级排序,我们为发版文档让路,我们为发版文档让路!" } ], [ @@ -242,7 +161,7 @@ def get_pr_no(url): [ { "tag": "text", - "text": "- sig/sql-infra 和 sig/planner" + "text": "*************************************************" } ], [ @@ -254,41 +173,7 @@ def get_pr_no(url): [ { "tag": "text", - "text": " - docs-cn 仓库中有 ${v54_zh_open_sqlinfra_planner} PR" - }, - { - "tag": "a", - "text": "未合并", - "href": "${v54_zh_open_sqlinfra_planner_url}" - }, - { - "tag": "text", - "text": ",有 ${v54_zh_close_sqlinfra_planner} PR" - }, - { - "tag": "a", - "text": "待翻译", - "href": "${v54_zh_close_sqlinfra_planner_url}" - } - ], - [ - { - "tag": "text", - "text": " - docs 仓库中有 ${v54_en_open_sqlinfra_planner} PR" - }, - { - "tag": "a", - "text": "未合并", - "href": "${v54_en_open_sqlinfra_planner_url}" - }, - { - "tag": "text", - "text": ",有 ${v54_en_close_sqlinfra_planner} PR" - }, - { - "tag": "a", - "text": "待翻译", - "href": "${v54_en_close_sqlinfra_planner_url}" + "text": "type/compatibility-or-feature-change 标签" } ], [ @@ -299,54 +184,48 @@ def get_pr_no(url): ], [ { - "tag": "text", - "text": "- sig/engine 和 sig/scheduling" - } - ], - [ - { - "tag": "text", - "text": "" + "tag": "text", + "text": "兼容性变更类文档,处理不及时容易背锅,请尽快处理:" } ], [ { "tag": "text", - "text": " - docs-cn 仓库中有 ${v54_zh_open_engine_scheduling} PR" + "text": "- docs-cn 仓库中有 ${compat_open_zh} PR " }, { "tag": "a", "text": "未合并", - "href": "${v54_zh_open_engine_scheduling_url}" + "href": "${compat_open_url_zh}" }, { "tag": "text", - "text": ",有 ${v54_zh_close_engine_scheduling} PR" + "text": ",有 ${compat_close_zh} PR " }, { "tag": "a", "text": "待翻译", - "href": "${v54_zh_close_engine_scheduling_url}" + "href": "${compat_close_url_zh}" } ], [ { "tag": "text", - "text": " - docs 仓库中有 ${v54_en_open_engine_scheduling} PR" + "text": "- docs 仓库中有 ${compat_open_en} PR " }, { "tag": "a", "text": "未合并", - "href": "${v54_en_open_engine_scheduling_url}" + "href": "${compat_open_url_en}" }, { "tag": "text", - "text": ",有 ${v54_en_close_engine_scheduling} PR" + "text": ",有 ${compat_close_en} PR " }, { "tag": "a", "text": "待翻译", - "href": "${v54_en_close_engine_scheduling_url}" + "href": "${compat_close_url_en}" } ], [ @@ -358,7 +237,7 @@ def get_pr_no(url): [ { "tag": "text", - "text": "- sig/migrate 和 area/dm" + "text": "*************************************************" } ], [ @@ -370,41 +249,7 @@ def get_pr_no(url): [ { "tag": "text", - "text": " - docs-cn 仓库中有 ${v54_zh_open_migrate_dm} PR" - }, - { - "tag": "a", - "text": "未合并", - "href": "${v54_zh_open_migrate_dm_url}" - }, - { - "tag": "text", - "text": ",有 ${v54_zh_close_migrate_dm} PR" - }, - { - "tag": "a", - "text": "待翻译", - "href": "${v54_zh_close_migrate_dm_url}" - } - ], - [ - { - "tag": "text", - "text": " - docs 仓库中有 ${v54_en_open_migrate_dm} PR" - }, - { - "tag": "a", - "text": "未合并", - "href": "${v54_en_open_migrate_dm_url}" - }, - { - "tag": "text", - "text": ",有 ${v54_en_close_migrate_dm} PR" - }, - { - "tag": "a", - "text": "待翻译", - "href": "${v54_en_close_migrate_dm_url}" + "text": "ONCALL 标签" } ], [ @@ -416,53 +261,47 @@ def get_pr_no(url): [ { "tag": "text", - "text": "- sig/bigdata、sig/tiup 和 sig/diagnosis" - } - ], - [ - { - "tag": "text", - "text": "" + "text": "文档被读者挑出问题,读者反馈不容小视,请尽快处理:" } ], [ { "tag": "text", - "text": " - docs-cn 仓库中有 ${v54_zh_open_bigdata_tiup_diagnosis} PR" + "text": "- docs-cn 仓库中有 ${oncall_open_zh} PR " }, { "tag": "a", "text": "未合并", - "href": "${v54_zh_open_bigdata_tiup_diagnosis_url}" + "href": "${oncall_open_url_zh}" }, { "tag": "text", - "text": ",有 ${v54_zh_close_bigdata_tiup_diagnosis} PR" + "text": ",有 ${oncall_close_zh} PR " }, { "tag": "a", "text": "待翻译", - "href": "${v54_zh_close_bigdata_tiup_diagnosis_url}" + "href": "${oncall_close_url_zh}" } ], [ { "tag": "text", - "text": " - docs 仓库中有 ${v54_en_open_bigdata_tiup_diagnosis} PR" + "text": "- docs-cn 仓库中有 ${oncall_open_en} PR " }, { "tag": "a", "text": "未合并", - "href": "${v54_en_open_bigdata_tiup_diagnosis_url}" + "href": "${oncall_open_url_en}" }, { "tag": "text", - "text": ",有 ${v54_en_close_bigdata_tiup_diagnosis} PR" + "text": ",有 ${oncall_close_en} PR " }, { "tag": "a", "text": "待翻译", - "href": "${v54_en_close_bigdata_tiup_diagnosis_url}" + "href": "${oncall_close_url_en}" } ], [ @@ -474,7 +313,7 @@ def get_pr_no(url): [ { "tag": "text", - "text": "- sig/transaction 和 area/security" + "text": "*************************************************" } ], [ @@ -486,41 +325,7 @@ def get_pr_no(url): [ { "tag": "text", - "text": " - docs-cn 仓库中有 ${v54_zh_open_transaction_security} PR" - }, - { - "tag": "a", - "text": "未合并", - "href": "${v54_zh_open_transaction_security_url}" - }, - { - "tag": "text", - "text": ",有 ${v54_zh_close_transaction_security} PR" - }, - { - "tag": "a", - "text": "待翻译", - "href": "${v54_zh_close_transaction_security_url}" - } - ], - [ - { - "tag": "text", - "text": " - docs 仓库中有 ${v54_en_open_transaction_security} PR" - }, - { - "tag": "a", - "text": "未合并", - "href": "${v54_en_open_transaction_security_url}" - }, - { - "tag": "text", - "text": ",有 ${v54_en_close_transaction_security} PR" - }, - { - "tag": "a", - "text": "待翻译", - "href": "${v54_en_close_transaction_security_url}" + "text": "type/bug-fix 文档 bug 影响用户体验,请尽快处理:" } ], [ @@ -529,134 +334,6 @@ def get_pr_no(url): "text": "" } ], - [ - { - "tag": "text", - "text": "*************************************************" - } - ], - [ - { - "tag": "text", - "text": "type/compatibility-or-feature-change 标签" - } - ], - [ - { - "tag": "text", - "text": "兼容性变更类文档,刻不容缓,请尽快处理:" - } - ], - [ - { - "tag": "text", - "text": "- docs-cn 仓库中有 ${compat_open_zh} PR " - }, - { - "tag": "a", - "text": "未合并", - "href": "${compat_open_url_zh}" - }, - { - "tag": "text", - "text": ",有 ${compat_close_zh} PR " - }, - { - "tag": "a", - "text": "待翻译", - "href": "${compat_close_url_zh}" - } - ], - [ - { - "tag": "text", - "text": "- docs 仓库中有 ${compat_open_en} PR " - }, - { - "tag": "a", - "text": "未合并", - "href": "${compat_open_url_en}" - }, - { - "tag": "text", - "text": ",有 ${compat_close_en} PR " - }, - { - "tag": "a", - "text": "待翻译", - "href": "${compat_close_url_en}" - } - ], - [ - { - "tag": "text", - "text": "*************************************************" - } - ], - [ - { - "tag": "text", - "text": "ONCALL 标签" - } - ], - [ - { - "tag": "text", - "text": "文档被读者挑出问题,读者反馈不容小视,请尽快处理:" - } - ], - [ - { - "tag": "text", - "text": "- docs-cn 仓库中有 ${oncall_open_zh} PR " - }, - { - "tag": "a", - "text": "未合并", - "href": "${oncall_open_url_zh}" - }, - { - "tag": "text", - "text": ",有 ${oncall_close_zh} PR " - }, - { - "tag": "a", - "text": "待翻译", - "href": "${oncall_close_url_zh}" - } - ], - [ - { - "tag": "text", - "text": "- docs-cn 仓库中有 ${oncall_open_en} PR " - }, - { - "tag": "a", - "text": "未合并", - "href": "${oncall_open_url_en}" - }, - { - "tag": "text", - "text": ",有 ${oncall_close_en} PR " - }, - { - "tag": "a", - "text": "待翻译", - "href": "${oncall_close_url_en}" - } - ], - [ - { - "tag": "text", - "text": "*************************************************" - } - ], - [ - { - "tag": "text", - "text": "type/bug-fix 文档 bug 影响用户体验,请尽快处理:" - } - ], [ { "tag": "text", diff --git a/scripts/pr_reminder_basedon_assignee.py b/scripts/pr_reminder_basedon_assignee.py new file mode 100644 index 0000000000000..44537de6b3472 --- /dev/null +++ b/scripts/pr_reminder_basedon_assignee.py @@ -0,0 +1,669 @@ +from os import close +import sys +import requests +from lxml import etree +from datetime import datetime +from string import Template + +docs_cn_url = 'https://github.com/pingcap/docs-cn/pulls?q=is%3Apr' +docs_url = 'https://github.com/pingcap/docs/pulls?q=is%3Apr' +open_url = '+is%3Aopen+is%3Apr' +close_url = '+is%3Aclosed+label%3Atranslation%2Fdoing' +v54 = '+label%3Av5.4' +type_compatibility_change = '+label%3Atype%2Fcompatibility-or-feature-change' +type_oncall = '+label%3AONCALL' +type_bugfix = '+label%3Atype%2Fbug-fix' +type_enhancement = '+label%3Atype%2Fenhancement' +shichun_0415_assignee = '+assignee%3Ashichun-0415' +shichun_0415_author = '+author%3Ashichun-0415' +en_jin19_assignee = '+assignee%3Aen-jin19' +en_jin19_author = '+author%3Aen-jin19' +hfxsd_assignee = '+assignee%3Ahfxsd' +hfxsd_author = '+author%3Ahfxsd' +ran_huang_assignee = '+assignee%3Aran-huang' +ran_huang_author = '+author%3Aran-huang' +qiancai_assignee = '+assignee%3Aqiancai' +qiancai_author = '+author%3Aqiancai' +tomshawn_assignee = '+assignee%3ATomShawn' +tomshawn_author = '+author%3ATomShawn' + + +def get_pr_no(url): + + page_text = requests.get(url=url).text + tree = etree.HTML(page_text) + pr_no = tree.xpath('//div[@class="table-list-header-toggle states flex-auto pl-0"]/a[@class="btn-link selected"]/text()')[1].strip() + if pr_no: + if pr_no.endswith('d'): + return str(pr_no[:-7]) + if pr_no.endswith('n'): + return str(pr_no[:-5]) + # print("未抓取到 PR 数目") + else: + return 0 + + +TEMPLATE = ''' +************************************************* +待处理的 PR 数目报告 +查询时间:{date} +待处理 PR 数目如下 +************************************************* + +v5.4 发版文档,中文文档截止日期 2021-01-07,英文文档截止日期 2021-01-18 + +- en-jin19 + + - docs-cn:有 {en-jin19-zh-assignee-open} 个未合源语 PR 待处理,有 {en-jin19-zh-assignee-close} 个已合源语 PR 待翻译,已翻译了 {en-jin19-zh-author-open} 个 PR 未合并 + - docs:有 {en-jin19-en-assignee-open} 个未合源语 PR 待处理,有 {en-jin19-en-assignee-close} 个已合源语 PR 待翻译,已翻译了 {en-jin19-en-author-open} 个 PR 未合并 + +- shichun-0415 + + - docs-cn:有 {shichun-0415-zh-assignee-open} 个未合源语 PR 待处理,有 {shichun-0415-zh-assignee-close} 个已合源语 PR 待翻译,已翻译了 {shichun-0415-zh-author-open} 个 PR 未合并 + - docs:有 {shichun-0415-en-assignee-open} 个未合源语 PR 待处理,有 {shichun-0415-en-assignee-close} 个已合源语 PR 待翻译,已翻译了 {shichun-0415-en-author-open} 个 PR 未合并 + +- hfxsd + + - docs-cn:有 {hfxsd-zh-assignee-open} 个未合源语 PR 待处理,有 {hfxsd-zh-assignee-close} 个已合源语 PR 待翻译,已翻译了 {hfxsd-zh-author-open} 个 PR 未合并 + - docs:有 {hfxsd-en-assignee-open} 个未合源语 PR 待处理,有 {hfxsd-en-assignee-close} 个已合源语 PR 待翻译,已翻译了 {hfxsd-en-author-open} 个 PR 未合并 + +- ran-huang + + - docs-cn:有 {ran-huang-zh-assignee-open} 个未合源语 PR 待处理,有 {ran-huang-zh-assignee-close} 个已合源语 PR 待翻译,已翻译了 {ran-huang-zh-author-open} 个 PR 未合并 + - docs:有 {ran-huang-en-assignee-open} 个未合源语 PR 待处理,有 {ran-huang-en-assignee-close} 个已合源语 PR 待翻译,已翻译了 {ran-huang-en-author-open} 个 PR 未合并 + +- qiancai + + - docs-cn:有 {qiancai-zh-assignee-open} 个未合源语 PR 待处理,有 {qiancai-zh-assignee-close} 个已合源语 PR 待翻译,已翻译了 {qiancai-zh-author-open} 个 PR 未合并 + - docs:有 {qiancai-en-assignee-open} 个未合源语 PR 待处理,有 {qiancai-en-assignee-close} 个已合源语 PR 待翻译,已翻译了 {qiancai-en-author-open} 个 PR 未合并 + +- TomShawn + + - docs-cn:有 {tomshawn-zh-assignee-open} 个未合源语 PR 待处理,有 {tomshawn-zh-assignee-close} 个已合源语 PR 待翻译,已翻译了 {tomshawn-zh-author-open} 个 PR 未合并 + - docs:有 {tomshawn-en-assignee-open} 个未合源语 PR 待处理,有 {tomshawn-en-assignee-close} 个已合源语 PR 待翻译,已翻译了 {tomshawn-en-author-open} 个 PR 未合并 +************************************************* +''' + +if __name__ == "__main__": + + data = { + 'date': datetime.utcnow().strftime('%Y-%m-%d'), + 'shichun_0415_zh_assignee_open': get_pr_no(docs_cn_url + open_url + shichun_0415_assignee + v54), + 'shichun_0415_zh_assignee_close': get_pr_no(docs_cn_url + close_url + shichun_0415_assignee + v54), + 'shichun_0415_zh_author_open': get_pr_no(docs_cn_url + open_url + shichun_0415_author + v54), + 'shichun_0415_en_assignee_open': get_pr_no(docs_url + open_url + shichun_0415_assignee + v54), + 'shichun_0415_en_assignee_close': get_pr_no(docs_url + close_url + shichun_0415_assignee + v54), + 'shichun_0415_en_author_open': get_pr_no(docs_url + open_url + shichun_0415_author + v54), + 'en_jin19_zh_assignee_open': get_pr_no(docs_cn_url + open_url + en_jin19_assignee + v54), + 'en_jin19_zh_assignee_close': get_pr_no(docs_cn_url + close_url + en_jin19_assignee + v54), + 'en_jin19_zh_author_open': get_pr_no(docs_cn_url + open_url + en_jin19_author + v54), + 'en_jin19_en_assignee_open': get_pr_no(docs_url + open_url + en_jin19_assignee + v54), + 'en_jin19_en_assignee_close': get_pr_no(docs_url + close_url + en_jin19_assignee + v54), + 'en_jin19_en_author_open': get_pr_no(docs_url + open_url + en_jin19_author + v54), + 'hfxsd_zh_assignee_open': get_pr_no(docs_cn_url + open_url + hfxsd_assignee + v54), + 'hfxsd_zh_assignee_close': get_pr_no(docs_cn_url + close_url + hfxsd_assignee + v54), + 'hfxsd_zh_author_open': get_pr_no(docs_cn_url + open_url + hfxsd_author + v54), + 'hfxsd_en_assignee_open': get_pr_no(docs_url + open_url + hfxsd_assignee + v54), + 'hfxsd_en_assignee_close': get_pr_no(docs_url + close_url + hfxsd_assignee + v54), + 'hfxsd_en_author_open': get_pr_no(docs_url + open_url + hfxsd_author + v54), + 'ran_huang_zh_assignee_open': get_pr_no(docs_cn_url + open_url + ran_huang_assignee + v54), + 'ran_huang_zh_assignee_close': get_pr_no(docs_cn_url + close_url + ran_huang_assignee + v54), + 'ran_huang_zh_author_open': get_pr_no(docs_cn_url + open_url + ran_huang_author + v54), + 'ran_huang_en_assignee_open': get_pr_no(docs_url + open_url + ran_huang_assignee + v54), + 'ran_huang_en_assignee_close': get_pr_no(docs_url + close_url + ran_huang_assignee + v54), + 'ran_huang_en_author_open': get_pr_no(docs_url + open_url + ran_huang_author + v54), + 'qiancai_zh_assignee_open': get_pr_no(docs_cn_url + open_url + qiancai_assignee + v54), + 'qiancai_zh_assignee_close': get_pr_no(docs_cn_url + close_url + qiancai_assignee + v54), + 'qiancai_zh_author_open': get_pr_no(docs_cn_url + open_url + qiancai_author +v54), + 'qiancai_en_assignee_open': get_pr_no(docs_url + open_url + qiancai_assignee + v54), + 'qiancai_en_assignee_close': get_pr_no(docs_url + close_url + qiancai_assignee + v54), + 'qiancai_en_author_open': get_pr_no(docs_url + open_url + qiancai_author +v54), + 'tomshawn_zh_assignee_open': get_pr_no(docs_cn_url + open_url + tomshawn_assignee + v54), + 'tomshawn_zh_assignee_close': get_pr_no(docs_cn_url + close_url + tomshawn_assignee + v54), + 'tomshawn_zh_author_open': get_pr_no(docs_cn_url + open_url + tomshawn_author + v54), + 'tomshawn_en_assignee_open': get_pr_no(docs_url + open_url + tomshawn_assignee + v54), + 'tomshawn_en_assignee_close': get_pr_no(docs_url + close_url + tomshawn_assignee + v54), + 'tomshawn_en_author_open': get_pr_no(docs_url + open_url + tomshawn_author + v54), + 'shichun_0415_zh_assignee_open_url': docs_cn_url + open_url + shichun_0415_assignee + v54, + 'shichun_0415_zh_assignee_close_url': docs_cn_url + close_url + shichun_0415_assignee + v54, + 'shichun_0415_zh_author_open_url': docs_cn_url + open_url + shichun_0415_author + v54, + 'shichun_0415_en_assignee_open_url': docs_url + open_url + shichun_0415_assignee + v54, + 'shichun_0415_en_assignee_close_url': docs_url + close_url + shichun_0415_assignee + v54, + 'shichun_0415_en_author_open_url': docs_url + open_url + shichun_0415_author + v54, + 'en_jin19_zh_assignee_open_url': docs_cn_url + open_url + en_jin19_assignee + v54, + 'en_jin19_zh_assignee_close_url': docs_cn_url + close_url + en_jin19_assignee + v54, + 'en_jin19_zh_author_open_url': docs_cn_url + open_url + en_jin19_author + v54, + 'en_jin19_en_assignee_open_url': docs_url + open_url + en_jin19_assignee + v54, + 'en_jin19_en_assignee_close_url': docs_url + close_url + en_jin19_assignee + v54, + 'en_jin19_en_author_open_url': docs_url + open_url + en_jin19_author + v54, + 'hfxsd_zh_assignee_open_url': docs_cn_url + open_url + hfxsd_assignee + v54, + 'hfxsd_zh_assignee_close_url': docs_cn_url + close_url + hfxsd_assignee + v54, + 'hfxsd_zh_author_open_url': docs_cn_url + open_url + hfxsd_author + v54, + 'hfxsd_en_assignee_open_url': docs_url + open_url + hfxsd_assignee + v54, + 'hfxsd_en_assignee_close_url': docs_url + close_url + hfxsd_assignee + v54, + 'hfxsd_en_author_open_url': docs_url + open_url + hfxsd_author + v54, + 'ran_huang_zh_assignee_open_url': docs_cn_url + open_url + ran_huang_assignee + v54, + 'ran_huang_zh_assignee_close_url': docs_cn_url + close_url + ran_huang_assignee + v54, + 'ran_huang_zh_author_open_url': docs_cn_url + open_url + ran_huang_author + v54, + 'ran_huang_en_assignee_open_url': docs_url + open_url + ran_huang_assignee + v54, + 'ran_huang_en_assignee_close_url': docs_url + close_url + ran_huang_assignee + v54, + 'ran_huang_en_author_open_url': docs_url + open_url + ran_huang_author + v54, + 'qiancai_zh_assignee_open_url': docs_cn_url + open_url + qiancai_assignee + v54, + 'qiancai_zh_assignee_close_url': docs_cn_url + close_url + qiancai_assignee + v54, + 'qiancai_zh_author_open_url': docs_cn_url + open_url + qiancai_author + v54, + 'qiancai_en_assignee_open_url': docs_url + open_url + qiancai_assignee + v54, + 'qiancai_en_assignee_close_url': docs_url + close_url + qiancai_assignee + v54, + 'qiancai_en_author_open_url': docs_url + open_url + qiancai_author + v54, + 'tomshawn_zh_assignee_open_url': docs_cn_url + open_url + tomshawn_assignee + v54, + 'tomshawn_zh_assignee_close_url': docs_cn_url + close_url + tomshawn_assignee + v54, + 'tomshawn_zh_author_open_url': docs_cn_url + open_url + tomshawn_author + v54, + 'tomshawn_en_assignee_open_url': docs_url + open_url + tomshawn_assignee + v54, + 'tomshawn_en_assignee_close_url': docs_url + close_url + tomshawn_assignee + v54, + 'tomshawn_en_author_open_url': docs_url + open_url + tomshawn_author + v54, + } + + URL = sys.argv[1] + + d = Template("""{ + "msg_type": "post", + "content": { + "post": { + "zh-CN": { + "title": "待处理的 PR 数目报告", + "content": [ + [ + { + "tag": "text", + "text": "查询时间:${date}" + } + ], + [ + { + "tag": "text", + "text": "待处理 PR 数目如下" + } + ], + [ + { + "tag": "text", + "text": "*************************************************" + } + ], + [ + { + "tag": "text", + "text": "v5.4 发版文档,中文文档截止日期 2021-01-07,英文文档截止日期 2021-01-18" + } + ], + [ + { + "tag": "text", + "text": "" + } + ], + [ + { + "tag": "text", + "text": "- en-jin19" + } + ], + [ + { + "tag": "text", + "text": "" + } + ], + [ + { + "tag": "text", + "text": " - docs-cn:有 ${en_jin19_zh_assignee_open} 个未合源语 PR" + }, + { + "tag": "a", + "text": "待处理", + "href": "${en_jin19_zh_assignee_open_url}" + }, + { + "tag": "text", + "text": ",有 ${en_jin19_zh_assignee_close} 个已合源语 PR" + }, + { + "tag": "a", + "text": "待翻译", + "href": "${en_jin19_zh_assignee_close_url}" + }, + { + "tag": "text", + "text": ",已翻译了 ${en_jin19_zh_author_open} 个 PR" + }, + { + "tag": "a", + "text": "未合并", + "href": "${en_jin19_zh_author_open_url}" + } + ], + [ + { + "tag": "text", + "text": " - docs:有 ${en_jin19_en_assignee_open} 个未合源语 PR" + }, + { + "tag": "a", + "text": "待处理", + "href": "${en_jin19_en_assignee_open_url}" + }, + { + "tag": "text", + "text": "有 ${en_jin19_en_assignee_close} 个已合源语 PR" + }, + { + "tag": "a", + "text": "待翻译", + "href": "${en_jin19_en_assignee_close_url}" + }, + { + "tag": "text", + "text": ",已翻译了 ${en_jin19_en_author_open} 个 PR" + }, + { + "tag": "a", + "text": "未合并", + "href": "${en_jin19_en_author_open_url}" + } + ], + [ + { + "tag": "text", + "text": "" + } + ], + [ + { + "tag": "text", + "text": "- shichun-0415" + } + ], + [ + { + "tag": "text", + "text": "" + } + ], + [ + { + "tag": "text", + "text": " - docs-cn:有 ${shichun_0415_zh_assignee_open} 个未合源语 PR" + }, + { + "tag": "a", + "text": "待处理", + "href": "${shichun_0415_zh_assignee_open_url}" + }, + { + "tag": "text", + "text": "有 ${shichun_0415_zh_assignee_close} 个已合源语 PR" + }, + { + "tag": "a", + "text": "待翻译", + "href": "${shichun_0415_zh_assignee_close_url}" + }, + { + "tag": "text", + "text": ",已翻译了 ${shichun_0415_zh_author_open} 个 PR" + }, + { + "tag": "a", + "text": "未合并", + "href": "${shichun_0415_zh_author_open_url}" + } + ], + [ + { + "tag": "text", + "text": " - docs:有 ${shichun_0415_en_assignee_open} 个未合源语 PR" + }, + { + "tag": "a", + "text": "待处理", + "href": "${shichun_0415_en_assignee_open_url}" + }, + { + "tag": "text", + "text": "有 ${shichun_0415_en_assignee_close} 个已合源语 PR" + }, + { + "tag": "a", + "text": "待翻译", + "href": "${shichun_0415_en_assignee_close_url}" + }, + { + "tag": "text", + "text": ",已翻译了 ${shichun_0415_en_author_open} 个 PR" + }, + { + "tag": "a", + "text": "未合并", + "href": "${shichun_0415_en_author_open_url}" + } + ], + [ + { + "tag": "text", + "text": "" + } + ], + [ + { + "tag": "text", + "text": "- hfxsd" + } + ], + [ + { + "tag": "text", + "text": "" + } + ], + [ + { + "tag": "text", + "text": " - docs-cn:有 ${hfxsd_zh_assignee_open} 个未合源语 PR" + }, + { + "tag": "a", + "text": "待处理", + "href": "${hfxsd_zh_assignee_open_url}" + }, + { + "tag": "text", + "text": "有 ${hfxsd_zh_assignee_close} 个已合源语 PR" + }, + { + "tag": "a", + "text": "待翻译", + "href": "${hfxsd_zh_assignee_close_url}" + }, + { + "tag": "text", + "text": ",已翻译了 ${hfxsd_zh_author_open} 个 PR" + }, + { + "tag": "a", + "text": "未合并", + "href": "${hfxsd_zh_author_open_url}" + } + ], + [ + { + "tag": "text", + "text": " - docs:有 ${hfxsd_en_assignee_open} 个未合源语 PR" + }, + { + "tag": "a", + "text": "待处理", + "href": "${hfxsd_en_assignee_open_url}" + }, + { + "tag": "text", + "text": "有 ${hfxsd_en_assignee_close} 个已合源语 PR" + }, + { + "tag": "a", + "text": "待翻译", + "href": "${hfxsd_en_assignee_close_url}" + }, + { + "tag": "text", + "text": ",已翻译了 ${hfxsd_en_author_open} 个 PR" + }, + { + "tag": "a", + "text": "未合并", + "href": "${hfxsd_en_author_open_url}" + } + ], + [ + { + "tag": "text", + "text": "" + } + ], + [ + { + "tag": "text", + "text": "- ran-huang" + } + ], + [ + { + "tag": "text", + "text": "" + } + ], + [ + { + "tag": "text", + "text": " - docs-cn:有 ${ran_huang_zh_assignee_open} 个未合源语 PR" + }, + { + "tag": "a", + "text": "待处理", + "href": "${ran_huang_zh_assignee_open_url}" + }, + { + "tag": "text", + "text": "有 ${ran_huang_zh_assignee_close} 个已合源语 PR" + }, + { + "tag": "a", + "text": "待翻译", + "href": "${ran_huang_zh_assignee_close_url}" + }, + { + "tag": "text", + "text": ",已翻译了 ${ran_huang_zh_author_open} 个 PR" + }, + { + "tag": "a", + "text": "未合并", + "href": "${ran_huang_zh_author_open_url}" + } + ], + [ + { + "tag": "text", + "text": " - docs:有 ${ran_huang_en_assignee_open} 个未合源语 PR" + }, + { + "tag": "a", + "text": "待处理", + "href": "${ran_huang_en_assignee_open_url}" + }, + { + "tag": "text", + "text": "有 ${ran_huang_en_assignee_close} 个已合源语 PR" + }, + { + "tag": "a", + "text": "待翻译", + "href": "${ran_huang_en_assignee_close_url}" + }, + { + "tag": "text", + "text": ",已翻译了 ${ran_huang_en_author_open} 个 PR" + }, + { + "tag": "a", + "text": "未合并", + "href": "${ran_huang_en_author_open_url}" + } + ], + [ + { + "tag": "text", + "text": "" + } + ], + [ + { + "tag": "text", + "text": "- qiancai" + } + ], + [ + { + "tag": "text", + "text": "" + } + ], + [ + { + "tag": "text", + "text": " - docs-cn:有 ${qiancai_zh_assignee_open} 个未合源语 PR" + }, + { + "tag": "a", + "text": "待处理", + "href": "${qiancai_zh_assignee_open_url}" + }, + { + "tag": "text", + "text": "有 ${qiancai_zh_assignee_close} 个已合源语 PR" + }, + { + "tag": "a", + "text": "待翻译", + "href": "${qiancai_zh_assignee_close_url}" + }, + { + "tag": "text", + "text": ",已翻译了 ${qiancai_zh_author_open} 个 PR" + }, + { + "tag": "a", + "text": "未合并", + "href": "${qiancai_zh_author_open_url}" + } + ], + [ + { + "tag": "text", + "text": " - docs:有 ${qiancai_en_assignee_open} 个未合源语 PR" + }, + { + "tag": "a", + "text": "待处理", + "href": "${qiancai_en_assignee_open_url}" + }, + { + "tag": "text", + "text": "有 ${qiancai_en_assignee_close} 个已合源语 PR" + }, + { + "tag": "a", + "text": "待翻译", + "href": "${qiancai_en_assignee_close_url}" + }, + { + "tag": "text", + "text": ",已翻译了 ${qiancai_en_author_open} 个 PR" + }, + { + "tag": "a", + "text": "未合并", + "href": "${qiancai_en_author_open_url}" + } + ], + [ + { + "tag": "text", + "text": "" + } + ], + [ + { + "tag": "text", + "text": "- TomShawn" + } + ], + [ + { + "tag": "text", + "text": "" + } + ], + [ + { + "tag": "text", + "text": " - docs-cn:有 ${tomshawn_zh_assignee_open} 个未合源语 PR" + }, + { + "tag": "a", + "text": "待处理", + "href": "${tomshawn_zh_assignee_open_url}" + }, + { + "tag": "text", + "text": "有 ${tomshawn_zh_assignee_close} 个已合源语 PR" + }, + { + "tag": "a", + "text": "待翻译", + "href": "${tomshawn_zh_assignee_close_url}" + }, + { + "tag": "text", + "text": ",已翻译了 ${tomshawn_zh_author_open} 个 PR" + }, + { + "tag": "a", + "text": "未合并", + "href": "${tomshawn_zh_author_open_url}" + } + ], + [ + { + "tag": "text", + "text": " - docs:有 ${tomshawn_en_assignee_open} 个未合源语 PR" + }, + { + "tag": "a", + "text": "待处理", + "href": "${tomshawn_en_assignee_open_url}" + }, + { + "tag": "text", + "text": "有 ${tomshawn_en_assignee_close} 个已合源语 PR" + }, + { + "tag": "a", + "text": "待翻译", + "href": "${tomshawn_en_assignee_close_url}" + }, + { + "tag": "text", + "text": ",已翻译了 ${tomshawn_en_author_open} 个 PR" + }, + { + "tag": "a", + "text": "未合并", + "href": "${tomshawn-en-author-open_url}" + } + ] + ] + } + } + } + }""") + + headers = { + 'Content-Type': 'application/json' + } + + r_data=d.substitute(data).encode('utf-8') + + r_docs = requests.request("POST", URL, headers=headers, data=r_data) + + print(f'{r_docs.status_code} {r_docs.reason}') + # print(r_docs.text)