Skip to content

Conversation

@pyphilia
Copy link
Contributor

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

@pyphilia pyphilia requested a review from spaenleh December 15, 2025 11:04
@pyphilia pyphilia self-assigned this Dec 15, 2025
Copy link
Member

@spaenleh spaenleh left a 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.Test from 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
Copy link
Contributor Author

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).

@pyphilia pyphilia requested a review from spaenleh December 18, 2025 16:26
@pyphilia
Copy link
Contributor Author

I applied changes on the code, not on the tests yet.
Let me know what you think.

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.

Allow to reindex

3 participants