Skip to content

Conversation

@VKTB
Copy link
Contributor

@VKTB VKTB commented Nov 11, 2025

Description

Similar to ral-facilities/object-storage-api#154. It replaces the manual duplicate name checks. Also ensures we shouldn't have race conditions due to concurrency which would otherwise allow some catalogue categories/manufacturers/systems/units/usage statuses with duplicate names from getting added to the database. This should not require any changes to your local MongoDB instance, calling docker compose up should be sufficient to get the indexes setup for the tests and development.

The README(s) and the mongodb-entrypoint.sh script will need updating in the docker-ims.

Notes

  • Uses unique compound indexes on code and sometimes parent_id (both ascending) - This has the side effect of changing the order results are returned when filtering by parent_id to be code ascending whereas before they were typically in creation order (although MongoDB doesn't guarantee the order unless you use sort explicitly anyway).

Testing instructions

  • Review code
  • Check Actions build
  • Review changes to test coverage
  • Ensure you cannot create catalogue categories/manufacturers/systems/units/usage statuses with duplicate names (either though creating or editing)

Agile board tracking

closes #512

@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.24%. Comparing base (53b01e7) to head (1501afe).

Additional details and impacted files
@@                            Coverage Diff                             @@
##           implement-authorisation-for-units-#609     #646      +/-   ##
==========================================================================
- Coverage                                   97.27%   97.24%   -0.03%     
==========================================================================
  Files                                          58       58              
  Lines                                        2016     1996      -20     
==========================================================================
- Hits                                         1961     1941      -20     
  Misses                                         55       55              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@VKTB VKTB linked an issue Nov 12, 2025 that may be closed by this pull request
@VKTB VKTB marked this pull request as ready for review November 12, 2025 16:46
@VKTB VKTB requested a review from joelvdavies November 18, 2025 09:34
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.

Use indexing for duplicate name prevention

2 participants