-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetch and cache slack channels #338
Conversation
65a0a6a
to
ccad1c6
Compare
logger.exception("Error refreshing slack user cache") | ||
raise | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't raise here because nothing else will catch it and asyncio
will complains that we have an unhandled exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DRY up the slack pagination (or if you prefer I can do that later on tonight)
pyslackersweb/tasks.py
Outdated
channels = [] | ||
while True: | ||
params = {} | ||
async with session.get( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add a pyslackersweb/util/slack.py
utility file that does the paging and just yields the pages to us to DRY this up a little.
At some point I'd like to pull the actual HTTP logic out of the tasks, this may be a good time to do it for the slack stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't DRY it more than that.
I took a quick look at the slack client v2 but it would still requires a bunch of code around compared to slack-sansio
We can pursue #186 - we just need to answer some questions of "what defines popularity", as showing |
28ae9e1
to
2e3d281
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor thing to relocate the slack_client
to an independent signal
pyslackersweb/contexts.py
Outdated
@@ -29,4 +34,5 @@ | |||
async def client_session(app: web.Application) -> None: | |||
async with ClientSession(raise_for_status=True) as session: | |||
app["client_session"] = session | |||
app["slack_client"] = SlackAPI(token=app["slack_token"], session=session) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be an independent context (or setup signal). It depends on this one, but shouldn't expand what the client_session
cleanup_ctx does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was afraid you where going to say that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure on the ordering of processing, but it looks like cleanup_ctx always is applied first on setup and cleanup:
b7836d6
to
9fcc1d0
Compare
9fcc1d0
to
250fad3
Compare
Relevant Issue & Description
I like the idea behind #186 and #40 . This is the first step towards thoses