-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add a page with reindex functionality #101
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
base: main
Are you sure you want to change the base?
Conversation
spaenleh
left a comment
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.
Thank you very much for you first contribution to the admin project 🎉
Overall it looks nice and the demo videos show that it also works !
I have a few comments on the code to align with the existing style.
Regarding tests, I see that you use application config to set the http_client and you build a fake one in the tests. I see multiple issues with this.
Application configuration is global this means that when you use Application.put_env in a test it changes for all the code that is currently executing. This means that parallel tests will have their configuration changed and this can lead to issues.
- For this I would propose to use something like the
Req.Testfrom the Req package. You can define stubs, they have nice example. This is concurrency safe.
I am unsure about how we need to handle the required env vars.
If we think that the application can absolutely not start without them, we should use System.fetch_env!/1 which will raise if the value is not defined and halt the program.
This is the behaviour for the DATABASE_URL. The app can not function without it.
I think that our case is less critical. The rest of the app can work. Only the re-index would not work.
I would only put the base URL and hardcode the path in the module since the path should not change. In a "near" future we should have a deployment that allows us to remove this extra host and just use the PHX_HOST value (should be dev.graasp.org, or graasp.org).
For setting the custom headers I like how they do it in the testing example docs: https://hexdocs.pm/req/Req.Test.html#module-example
This shows how the config is more code than just configuration.
The example also shows them splitting the "building the request" and "parsing the response" as two functions isolating them.
I hope these comments make sens and that they help you. Thank you again for the work, let me know if there is anything I can help with !
| end | ||
|
|
||
| config :admin, base_host: base_host | ||
| config :admin, backend_host: base_host |
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'm not really sure here.
In local I used localhost:3000 that automatically redirects to /api.
Using api.graasp.org in prod would work as it redirects to /api too, but using graasp.org would require /api (so it's not a host anymore).
|
I applied changes on the code, not on the tests yet. |
The reindex feature use the node.js backend to reindex the search index.
Next step would be to show the index status to keep track of the progress.
Screen.Recording.2025-12-15.at.12.00.58.mov
Screen.Recording.2025-12-15.at.12.02.28.mov
close #100