-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Discussion] Autocompletion in comment boxes #9755
Comments
I've been playing around with this a bit and I think I understand it. I created a new method in search_service.rb with the recently active query from above.
Now the issue is with the plots2/app/services/search_criteria.rb Lines 20 to 22 in 700fdf4
The recently_active_users query does not require a query string so it returns an error that says {"error":"query is missing"} . I'm not sure how to move forward.
|
Hi Tilda, I think from the tests plots2/test/unit/api/search_service_test.rb Lines 9 to 11 in 700fdf4
From the discussion we had yesterday, I think all you need to do is make the method you have written above The query can be included in the users.rb file, then accessed in the action within the controller and the results rendered in json. For example, In the modeldef search_recently_active_users(limit = 10, order = 'last_updated DESC') In the controllerdef search_active_users Ensure you have registered the search_active_users action in routes.rbget 'users/active' => 'controller_name#search_active_users' Alternatively, you could write the method
Let me know if it makes sense |
Also, I am not sure why the |
@RuthNjeri To execute a search this method is called Line 101 in 700fdf4
Lines 399 to 401 in 700fdf4
which in turn calls the Line 403 in 700fdf4
|
I think the controller would be user_controller.rb and the model would be user.rb Thanks @RuthNjeri it makes perfect sense. |
Just to note that I'm not 100% sure all the scenarios this API is used for, so it may be important to preserve the current behavior and switch to a different one only in the prese of a specific URL parameter. But I'm not quite sure! Can anyone think of another use? I guess regular user search on the sidebar of the search page maybe? |
But I guess that's not going to use recently active, just general user search. So maybe we are OK. |
@jywarren So, @RuthNjeri's suggestion is okay? |
Thanks @TildaDares, and how is the code above related to the search_service? |
@jywarren maybe in the case for research notes, wikis, and questions? |
@RuthNjeri I'm not sure how but maybe you'll understand it better https://github.com/publiclab/plots2/blob/main/doc/API.md#api-code |
I think this all looks great and so does your PR - i'll make comments there! I think you were way ahead of what i noted in my comment. Great to see it! |
I've been looking through At.js docs https://github.com/ichord/At.js/wiki/Callbacks, https://github.com/ichord/At.js/wiki and https://github.com/publiclab/plots2/blob/main/app/assets/javascripts/atWhoAutoComplete.js. From what I understand I think the
data
key is what is supposed to hold the pre-fetched usernamesBut instead of hardcoded names, the names are generated from recently active users on the site. I looked through the repo for the query that gets the recently active users on the site and I found this
plots2/app/controllers/users_controller.rb
Lines 137 to 142 in 700fdf4
I'm a little confused on how to display the results of that query in json format in https://github.com/publiclab/plots2/blob/700fdf41a08d52bfd51d7774902dc9217ed225b5/app/api/srch/search.rb
@jywarren @cesswairimu @RuthNjeri
The text was updated successfully, but these errors were encountered: