Skip to content
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

Autocompletion of usernames in comment boxes #9773

Merged
merged 1 commit into from
Jun 11, 2021

Conversation

TildaDares
Copy link
Member

@TildaDares TildaDares commented Jun 10, 2021

Fixes #9755

Part of larger planning issue in #9667

Test here https://unstable.publiclab.org/

Screen.Recording.2021-06-10.at.16.39.36.mov

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with rake test
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updation
  • ask @publiclab/reviewers for help, in a comment below

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

@TildaDares TildaDares requested a review from a team as a code owner June 10, 2021 15:43
@gitpod-io
Copy link

gitpod-io bot commented Jun 10, 2021

app/models/user.rb Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jun 10, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@471e413). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head f3e816e differs from pull request most recent head 1006127. Consider uploading reports for the commit 1006127 to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9773   +/-   ##
=======================================
  Coverage        ?   78.23%           
=======================================
  Files           ?       98           
  Lines           ?     5940           
  Branches        ?        0           
=======================================
  Hits            ?     4647           
  Misses          ?     1293           
  Partials        ?        0           

@TildaDares TildaDares force-pushed the autocomplete branch 2 times, most recently from 9098aa6 to 6ca6da8 Compare June 10, 2021 16:08
Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great and the video is awesome. Just had a question about the difference between 2 queries; maybe a comment would help! Thanks!!!

app/models/user.rb Show resolved Hide resolved
app/assets/javascripts/atWhoAutoComplete.js Show resolved Hide resolved
@codeclimate
Copy link

codeclimate bot commented Jun 11, 2021

Code Climate has analyzed commit 1006127 and detected 0 issues on this pull request.

View more on Code Climate.

Copy link
Collaborator

@Tlazypanda Tlazypanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TildaDares This looks great!! 🎉 another consideration can be to play around a bit with the ordering of the clauses in our query and benchmark the results ✌️

@jywarren
Copy link
Member

@TildaDares This looks great!! 🎉 another consideration can be to play around a bit with the ordering of the clauses in our query and benchmark the results ✌️

Yes and you can also watch the rails log when running locally, and see if all the chained conditions are rolled up into a single query, and it should provide a timestamp of how long it took in development mode. But, if your local is a pretty small database, it may not really show performance issues on the scale we're looking at in the live site.

Great ideas! Thanks!

.where("rusers.status = 1")
.group('rusers.id')
.order(order)
.limit(limit)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, i wonder -- is 5 enough? What if we changed the limit to 15? Or, alternatively, what if there were a way to narrow this list based on something specific to the current user? But, that might increase the complexity of the query and therefore slow it down a lot.

Finally, i wonder if we could add caching to this query. That could make this really speedy and it seems OK for there to be at least an hour long cache here, maybe? Look at this example -

@tags = Rails.cache.fetch("stats-subscriptions-query", expires_in: 24.hours) do

This can be added in followup, so I'll go ahead and merge this now, but these are maybe some more refinements we can make -- and they're simple enough that maybe they could be an FTO too!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we changed the limit to 15?

@jywarren Setting the limit to 15 sounds like a good idea.

Finally, i wonder if we could add caching to this query. That could make this really speedy and it seems OK for there to be at least an hour long cache here, maybe? Look at this example -

The query already has a cache or is there somewhere else I'm supposed to add it? The cache has an expiration time of 24 hours so I'll change it to an hour.

Rails.cache.fetch('users/active', expires_in: 24.hours) do

@jywarren jywarren merged commit 0feb101 into publiclab:main Jun 11, 2021
@jywarren
Copy link
Member

Just noting that I think this is ready to go -- we can test it in stable, and we won't be publishing to the live site for at least a few days or maybe longer -- and the extra ideas I suggested above could be done in another PR!

Thanks, everyone! @TildaDares this is great work!

@jywarren
Copy link
Member

jywarren commented Jun 11, 2021 via email

reginaalyssa pushed a commit to reginaalyssa/plots2 that referenced this pull request Oct 16, 2021
billymoroney1 pushed a commit to billymoroney1/plots2 that referenced this pull request Dec 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Discussion] Autocompletion in comment boxes
3 participants