Repository navigation
gadmin の user/group/member list で全件を取得する - #75
Open
ikedaosushi wants to merge 1 commit into
Open
ikedaosushi wants to merge 1 commit into
ikedaosushi wants to merge 1 commit into
Conversation
`$gadmin user list` は Directory API の既定の100件で切れていた。 user list / group list / member list を list_next で全ページたどる。 全件を1通にすると RTM の上限(16KB)を超えて bot が切断されるおそれが あるので、一覧は100行ずつ、2通目以降は1秒あけて送る。 member list は 404 のときだけ「合致するグループはありません」と返し、 それ以外の HttpError は内容を表示する。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
$gadmin user listが100件で切れて、アルファベット順で v より後のユーザーが出ない問題を直します。原因
gadmin.pyは Directory API のlist()を1回しか呼んでおらず、nextPageTokenをたどっていませんでした。users.list は既定で1ページ100件です。group list と member list も同じ書き方で、こちらは200件を超えると切れます(Directory API の limits)。変更
対象は
pyconjpbot/google_plugins/gadmin.pyだけです。_list_all:list_nextで全ページをたどります。1ページの件数は users 500、groups/members 200 です。_send_lines: 一覧を100行ずつに分けて送り、2通目以降は1秒あけます。botsendは RTM(websocket)で送られます。Slack は16KBを超えるメッセージを送ったクライアントを切断し、書き込みは1秒に1回までと案内しています(rate limits)。全件を1通にすると、bot が切断されるおそれがあります。member list: グループが見つからない 404 のときだけ「合致するグループはありません」と返します。それ以外のHttpError(429、5xx など)は内容を表示します。見出しと各行の書式は変えていません。
確認したこと
--isolated、tox.ini と同じ設定)、py_compile は通ります。_gadmin_group_insertの長いbotsend)だけを指摘します。この行は master でも同じ指摘が出ます。HttpMockSequenceを使い、3ページ1037件を取り切れることを確かめました。リクエストのpageTokenは None、T1、T2 の順で、maxResults=500が付いていました。_send_linesは、250行を3通(2通目以降の前に1秒待つ)、0件を見出しだけ1通で送ります。1通の RTM フレームは最大で約5KBです(日本語の氏名を含めて計測)。デプロイについて
ISSHA-3528 のとおり、ansible では今 pyconjpbot を構築できません。マージしても本番には自動では反映されません。origin.pycon.jp 上の
gadmin.pyを、このファイルで置き換えて再起動する必要があります。🤖 Generated with Claude Code