-
Notifications
You must be signed in to change notification settings - Fork 166
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
Add a Slack user cache #131
Conversation
@@ -11,6 +10,7 @@ class Meta: | |||
app_id = models.CharField(max_length=50, blank=False, null=False) | |||
external_id = models.CharField(max_length=50, blank=False, null=False) | |||
display_name = models.CharField(max_length=50, blank=False, null=False) | |||
full_name = models.CharField(max_length=50, blank=True, null=True) |
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 was added to consolidate slack profile data returning fullname
and the ExternalUser
model not including it. Having read the Slack docs, fullname != display_name
so we can't substitute one for another.
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.
Interesting. Any idea how they differ? Should we consider also returning full_name
in the API response?
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.
The difference seems to be this: https://get.slack.help/hc/en-gb/articles/115004692303-Change-how-names-are-displayed
We probably want full_name
on the UI, so yeah, I'll add it to the API response.
break | ||
|
||
|
||
def get_user_profile(external_id): |
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.
In another PR, we should replace all usages of settings.SLACK_CLIENT.get_user_profile with this to take advantage of the cache.
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've left a few minor comments, but looks good otherwise 👍
@@ -11,6 +10,7 @@ class Meta: | |||
app_id = models.CharField(max_length=50, blank=False, null=False) | |||
external_id = models.CharField(max_length=50, blank=False, null=False) | |||
display_name = models.CharField(max_length=50, blank=False, null=False) | |||
full_name = models.CharField(max_length=50, blank=True, null=True) |
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.
Interesting. Any idea how they differ? Should we consider also returning full_name
in the API response?
response/slack/cache.py
Outdated
|
||
def update_user_cache(): | ||
cursor = None | ||
while True: |
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.
You could do while cursor != "":
here and remove the check below (I've just remembered that #85 does this)
"name": "chrisevans", | ||
"deleted": "False", | ||
"color": "9f69e7", | ||
"real_name": "Glinda Southgood", |
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.
😮 @evnsio you never told us about your real name!
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.
Dammit 🤦♀ . I thought I'd removed all of mention of Chris in the test data. Sorry :(
c77a1af
to
0a0e928
Compare
File has also been "improved" by `black`.
File has also been run through black
This fixes the test data to match real data based on slack docs: https://api.slack.com/docs/pagination File has also been processed by Black.
Names aren't static, yo.
353326e
to
2850375
Compare
2850375
to
fd6e9db
Compare
e243a08
to
6b22dd9
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.
LGTM 👍
Part of the work for pre-loading all external users to the database.
Tested locally to ensure all users are added to the database and returned from the users api endpoint.