-
Notifications
You must be signed in to change notification settings - Fork 302
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
Autocomplete usernames when inviting students and teachers #6032
base: main
Are you sure you want to change the base?
Changes from 3 commits
a723cf8
d2d25fe
b4f6348
7873c27
edda8d4
0f3c014
789af85
021fee9
7ffb480
c7230df
7e7c031
ca1a443
95105aa
98a9c87
663d913
64c7570
4583954
d6b97ed
33f1af8
7c0de85
f59758d
7699527
f51a50a
6196fbe
9b71abf
e86309f
266c548
d43c232
fff9674
6a92120
6b4631d
600356f
ad41ee1
76aec99
c4d28c3
a13c024
1571862
416cf3c
f7dc9fe
75c9df1
af827cf
7d046fd
5535cd6
3c7bdc4
3672693
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% for username in usernames %} | ||
<li class="p-4 m-1 bg-blue-100 rounded cursor-pointer w-4/5" >{{ username}}</li> | ||
{% endfor %} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -109,7 +109,8 @@ def __init__(self): | |||||
}), | ||||||
indexes=[ | ||||||
dynamo.Index('email'), | ||||||
dynamo.Index('epoch', sort_key='created') | ||||||
dynamo.Index('epoch', sort_key='created'), | ||||||
dynamo.Index('username', sort_key='epoch', keys_only=True) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No please.
Suggested change
Also, putting a Condition on a PK doesn't make sense. A partition must always be matched with full key equality. If the DynamoDB layer allowed you to formulate the query below, something is wrong EDIT: There was a bug that would only manifest for tables with only a partition key and not a sort key. In that case, the protection that should give you an error when trying to put a condition onto the PK wouldn't work. I fixed it in the linked PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see, the abstraction layer complains if you use the same partition key multiple times so you were forced to reverse the keys to get it to do anything at all. That restriction is not strictly necessary. It's not enforced by Dynamo, but by our abstraction layer for the convenience of identifying which index to query. Let me see what I can do about that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is a PR you will need to merge before you can set up the indexes the way you need them: #6034. Unfortunately, this will also require you to annotate all existing epoch queries to indicate what index to use. I know at least one of them in the admin interface, and there aren't any tests on those, so do have a good look around. The motivation for the design decisions is in the linked PR. (BTW I created the necessary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, so I thought I was making a mistake. Thanks for pointing it out and fixing it.
Neat! |
||||||
] | ||||||
) | ||||||
self.tokens = dynamo.Table(storage, 'tokens', 'id', | ||||||
|
@@ -1156,6 +1157,9 @@ def get_username_role(self, username): | |||||
role = "teacher" if self.users.get({"username": username}).get("is_teacher") == 1 else "student" | ||||||
return role | ||||||
|
||||||
def get_users_that_starts_with(self, search): | ||||||
return self.users.get_many({'username': dynamo.BeginsWith(search)}, limit=10) | ||||||
|
||||||
|
||||||
def batched(iterable, n): | ||||||
"Batch data into tuples of length n. The last batch may be shorter." | ||||||
|
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.
Probably you want to only do an actual search once you've gotten at least one character.
Otherwise the first query will always return the same first 10 items from the users table
["000_test", "4242 i like kittens", "aaron a. aaronson", ...]
. Not useful, and people will get tired of it.Just return an empty list otherwise.
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.
Oh for sure! I was thinking about that yesterday, I'm only going to look data if I there's more than one character.