rfcx / arbimon

Ecoacoustic analysis platform empowering conservationists to analyze acoustic data and to derive insights about the ecosystem at scale
https://arbimon.org
Apache License 2.0
4 stars 1 forks source link

Slug/url mismatched on legacy and bio #1959

Closed naluinui closed 4 months ago

naluinui commented 4 months ago

Describe the bug When you create a new project, the slug or url that was auto generated were different between bio and legacy. For example, my project called "TEst". Bio's auto generated slug was t-est where as in legacy it was ${core_project_id}_test. (I tested it on staging and my legacy's project id is 5858)

To Reproduce Steps to reproduce the behavior:

  1. Create new project
  2. Check both database to see url

Expected behavior Url should be the same in bio and legacy

Screenshots Related problem from this issue

https://github.com/rfcx/arbimon-legacy/assets/9149523/05de2ea8-46fa-4e77-b0e0-dd1d7ed9aded

Context

antonyharfield commented 4 months ago

The problem is that legacy is generating the url/slug itself, you can see the problem here: https://github.com/rfcx/arbimon-legacy/blob/5ef38dfd2c92d3bd23acbd3ae9f460399e75444b/app/routes/data-api/integration.js#L22

Suggested fix:

  1. Remove findUniqueUrl from everywhere in the codebase - Legacy is not allowed to define the url/slug
  2. Update the code to pass the url/slug to legacy
  3. Throw an error 400 if the url is not unique on the legacy side (it should be if the dbs are in sync)

Extra:

  1. Remove description from create project endpoint on legacy as that is no longer needed
antonyharfield commented 4 months ago

The problem is that legacy is generating the url/slug itself, you can see the problem here:

https://github.com/rfcx/arbimon-legacy/blob/5ef38dfd2c92d3bd23acbd3ae9f460399e75444b/app/routes/data-api/integration.js#L22

Suggested fix:

  1. Remove findUniqueUrl from everywhere in the codebase - Legacy is not allowed to define the url/slug ...

That's not going to work because the create project is called from Core and Core doesn't have the slug.

New suggested fix:

  1. After the project is created, update the url/slug in Legacy directly from Arbimon (in the project create bll)
antonyharfield commented 4 months ago

I've added a url parameter to the update endpoint on legacy: https://github.com/rfcx/arbimon-legacy/commit/70aefee82005a0ccd3a938da70e6af4a3b8c554c

naluinui commented 4 months ago

Released on production https://github.com/rfcx/arbimon/actions/runs/9009608086