[PR #678] [CLOSED] [FEATURE] Confirm that spools exists in inventory without NFCTag associated before creating a new one #1092

Closed
opened 2026-05-06 12:35:00 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/maziggy/bambuddy/pull/678
Author: @wreuel
Created: 3/12/2026
Status: Closed

Base: devHead: feature/associateExistingBambuLabSpoolBeforeCreateOne


📝 Commits (10+)

  • c415c6d Add a check to associate an unassigned spool based on brand, color, and type. If a matching unused spool exists, reuse it; otherwise, create a new spool.
  • d7a6d4d Merge branch 'dev' into feature/associateExistingBambuLabSpoolBeforeCreateOne
  • 7957b08 Merge branch 'dev' into feature/associateExistingBambuLabSpoolBeforeCreateOne
  • 6f529bf Complying with PR comments
  • 44e4bb5 Merge branch 'dev' into feature/associateExistingBambuLabSpoolBeforeCreateOne
  • df6e2e1 Merge branch 'dev' into feature/associateExistingBambuLabSpoolBeforeCreateOne
  • 64beb1c Merge branch 'dev' into feature/associateExistingBambuLabSpoolBeforeCreateOne
  • bcf8847 Adding racing condition using lock
  • 609df90 Merge branch 'dev' into feature/associateExistingBambuLabSpoolBeforeCreateOne
  • d95d1f9 adding test on race condition

📊 Changes

4 files changed (+1134 additions, -2 deletions)

View changed files

📝 backend/app/main.py (+22 -2)
📝 backend/app/services/spool_tag_matcher.py (+124 -0)
backend/tests/unit/services/test_spool_match_race.py (+337 -0)
📝 backend/tests/unit/services/test_spool_tag_matcher.py (+651 -0)

📄 Description

Description

Add a check to associate an unassigned spool based on brand, color, and type. If a matching unused spool exists, reuse it; otherwise, create a new spool.

#538

Fixes #

#538

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test addition or update

Changes Made

  • Added find_matching_inventory_spool()
  • Added link_tag_to_spool() — links RFID tag data (tag_uid, tray_uuid) to a matched inventory spool with data_origin="rfid_linked".
  • Updated AMS auto-management flow to use a 3-step fallback:
    a. Tag match
    b. Inventory match
    c. Create new — (existing, now last resort)

Screenshots

Testing

  • I have tested this on my local machine
  • I have tested with my printer model:

Checklist

  • My code follows the project's coding style
  • I have commented my code where necessary
  • I have updated the documentation (if needed)
  • My changes generate no new warnings
  • I have tested my changes thoroughly

Additional Notes

Still need to confirm with testing on my side


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/maziggy/bambuddy/pull/678 **Author:** [@wreuel](https://github.com/wreuel) **Created:** 3/12/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `feature/associateExistingBambuLabSpoolBeforeCreateOne` --- ### 📝 Commits (10+) - [`c415c6d`](https://github.com/maziggy/bambuddy/commit/c415c6d6e9a949830b9233c1642b77eb8f9db2ab) Add a check to associate an unassigned spool based on brand, color, and type. If a matching unused spool exists, reuse it; otherwise, create a new spool. - [`d7a6d4d`](https://github.com/maziggy/bambuddy/commit/d7a6d4d89551c03cd066e20b7c49923f3fd72ed2) Merge branch 'dev' into feature/associateExistingBambuLabSpoolBeforeCreateOne - [`7957b08`](https://github.com/maziggy/bambuddy/commit/7957b08da8191b95b4a1e14a87b1bac4a6f569f2) Merge branch 'dev' into feature/associateExistingBambuLabSpoolBeforeCreateOne - [`6f529bf`](https://github.com/maziggy/bambuddy/commit/6f529bf2c132cf5fd1ad0ef46fe74e5c5810251d) Complying with PR comments - [`44e4bb5`](https://github.com/maziggy/bambuddy/commit/44e4bb5aeea261224b9d075f459cc6067bf70e7a) Merge branch 'dev' into feature/associateExistingBambuLabSpoolBeforeCreateOne - [`df6e2e1`](https://github.com/maziggy/bambuddy/commit/df6e2e146814d26a95693baa6be2192a26d3182b) Merge branch 'dev' into feature/associateExistingBambuLabSpoolBeforeCreateOne - [`64beb1c`](https://github.com/maziggy/bambuddy/commit/64beb1c4b749397bfd83401a877fd810674c806e) Merge branch 'dev' into feature/associateExistingBambuLabSpoolBeforeCreateOne - [`bcf8847`](https://github.com/maziggy/bambuddy/commit/bcf8847fd929224ff0b47f4716a1febb24ec58cc) Adding racing condition using lock - [`609df90`](https://github.com/maziggy/bambuddy/commit/609df90dd67d00f531ca40ee804e7cead0b7762e) Merge branch 'dev' into feature/associateExistingBambuLabSpoolBeforeCreateOne - [`d95d1f9`](https://github.com/maziggy/bambuddy/commit/d95d1f935cf8d3a1b2aee218d9150c2209b2820a) adding test on race condition ### 📊 Changes **4 files changed** (+1134 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `backend/app/main.py` (+22 -2) 📝 `backend/app/services/spool_tag_matcher.py` (+124 -0) ➕ `backend/tests/unit/services/test_spool_match_race.py` (+337 -0) 📝 `backend/tests/unit/services/test_spool_tag_matcher.py` (+651 -0) </details> ### 📄 Description ## Description Add a check to associate an unassigned spool based on brand, color, and type. If a matching unused spool exists, reuse it; otherwise, create a new spool. ## Related Issue #538 Fixes # #538 ## Type of Change <!-- Mark the relevant option with an "x" --> - [ ] Bug fix (non-breaking change that fixes an issue) - [X] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [ ] Test addition or update ## Changes Made <!-- List the specific changes made in this PR --> - Added find_matching_inventory_spool() - Added link_tag_to_spool() — links RFID tag data (tag_uid, tray_uuid) to a matched inventory spool with data_origin="rfid_linked". - Updated AMS auto-management flow to use a 3-step fallback: a. Tag match b. Inventory match c. Create new — (existing, now last resort) ## Screenshots <!-- If applicable, add screenshots to demonstrate your changes --> ## Testing <!-- Describe how you tested your changes --> - [ ] I have tested this on my local machine - [ ] I have tested with my printer model: <!-- e.g., X1C, P1S, A1 --> ## Checklist - [ ] My code follows the project's coding style - [ ] I have commented my code where necessary - [ ] I have updated the documentation (if needed) - [ ] My changes generate no new warnings - [ ] I have tested my changes thoroughly ## Additional Notes <!-- Add any additional information that reviewers should know --> Still need to confirm with testing on my side --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:35:00 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/bambuddy#1092
No description provided.