Skip to content

If the queryset given to TaxonManager.update_display_names() is falsy… - #1508

Draft
kra wants to merge 6 commits into
mainfrom
kra/model-split-tests-storage-taxonomy-updatedisplaynames
Draft

kra wants to merge 6 commits into
mainfrom
kra/model-split-tests-storage-taxonomy-updatedisplaynames

Conversation

@kra

@kra kra commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Remove unused and minorly problematic default to TaxonManager.update_display_names().

List of Changes

taxonomy.py
test_taxonomy.py

Detailed Description

If the queryset given to TaxonManager.update_display_names() is falsy, it gets and uses the default queryset. An empty queryset is falsy, so selecting that will cause the default queryset to be used. Fixed this by removing the None default (which the admin action, the only caller, doesn't use anyway), so the given queryset must be used.

How to Test the Changes

Ran through the action at http://localhost:8000/admin/main/taxon/
Ran the unit tests

Summary by CodeRabbit

  • Taxonomy
    • Taxonomy information continues to support project-aware visibility, observation and verification counts, and filtering by project defaults.
    • Verified observations are reflected in counts for the determined taxon and its ancestors.
  • Refactor
    • Taxonomy functionality is now organized separately while preserving compatibility with existing database migrations.

@kra
kra requested a review from mihow October 9, 2026 19:00
@netlify

netlify Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for antenna-preview canceled.

Name Link
🔨 Latest commit 8653f06
🔍 Latest deploy log https://app.netlify.com/projects/antenna-preview/deploys/6ad7f4aa93f4bbc611dfb1a7

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5a6b5da6-bdb1-4e46-af32-aa3c475cebff
📥 Commits

Reviewing files that changed from the base of the PR and between dc79bb3 and 8653f06.

📒 Files selected for processing: 1
  • ami/main/models_future/taxonomy.py

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e7d3cc4d-f155-4d63-b387-2ceda2d533f6
📥 Commits

Reviewing files that changed from the base of the PR and between 1862f40 and dc79bb3.

📒 Files selected for processing: 5
  • ami/main/models.py
  • ami/main/models_future/__init__.py
  • ami/main/models_future/enums.py
  • ami/main/models_future/taxonomy.py
  • ami/main/models_future/tests/test_taxonomy.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The taxonomy enums, models, managers, querysets, and helpers now reside in ami.main.models_future. ami.main.models re-exports the taxonomy names. A new test suite covers taxonomy model and queryset behavior.

Changes: Taxonomy models and queries

Layer / File(s) Summary
Taxonomy declarations and module boundary
ami/main/models.py, ami/main/models_future/enums.py, ami/main/models_future/taxonomy.py, ami/main/models_future/__init__.py
TaxonRank, DEFAULT_RANKS, and taxonomy declarations reside in models_future. models.py re-exports these names and removes the former in-file implementations.
Taxon hierarchy and model operations
ami/main/models_future/taxonomy.py, ami/main/models_future/tests/test_taxonomy.py
Managers build taxon trees and update ancestor data. Taxon methods provide occurrence data and update calculated fields. Taxa-list lookup and creation support global and project-scoped lists. Tests cover these operations.
Taxon queryset annotations and filters
ami/main/models_future/taxonomy.py, ami/main/models_future/tests/test_taxonomy.py
Querysets annotate observation and verification counts, select example occurrences, and filter by project defaults and user visibility. Tests cover filters, occurrence selection, and duplicate-join handling.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to dc79b

This change moves the taxonomy models into their own module without changing their schema. It also fixes the bug where an empty selection updated every taxon's display name. Existing callers already pass a selection, and no concrete merge risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 32.73% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 165 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the TaxonManager.update_display_names() issue addressed by the pull request and is specific to the main fix.
Description check Passed The description includes a summary, changed files, detailed rationale, and test instructions. It omits the template checklist and deployment or issue notes, but the core information is complete.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch kra/model-split-tests-storage-taxonomy-updatedisplaynames
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

- _case_from_map
- verified_taxon_counts
- TaxonRank
- TaxonQuerySet
- TaxonManager
- TaxonParent
- Taxon
- TaxaListQuerySet
- TaxaListManager
- TaxaList
- Tag

Because main.models still has to re-export from models_future until migrations and other code stops referencing it:
- Added imports in some methods, since module-level imports must be avoided to avoid circular imports.
- Changed type hinting for some methods to strings (to be evauluated by the linter without a change in behavior) to avoid circular imports.

Added unit tests for models_future.taxonomy. Some of these were driven by coverage needs. I didn't remove tests from ami.main, which means we have duplicate coverage. The tests were all blatted out by AI and I didn't work hard to understand them.

There should be no functionality changes, including possible bugfixes.
@kra
kra force-pushed the kra/model-split-tests-storage-taxonomy branch from e4819a3 to 87c836c Compare October 9, 2026 22:18
…, it gets and uses the default queryset. An empty queryset is falsy, so selecting that will cause the default queryset to be used. Fixed this by removing the None default (which the admin action, the only caller, doesn't use anyway), so the given queryset must be used.
@kra
kra force-pushed the kra/model-split-tests-storage-taxonomy-updatedisplaynames branch from 63acf04 to e9723af Compare October 9, 2026 23:07
- _case_from_map
- verified_taxon_counts
- TaxonRank
- TaxonQuerySet
- TaxonManager
- TaxonParent
- Taxon
- TaxaListQuerySet
- TaxaListManager
- TaxaList
- Tag

Because main.models still has to re-export from models_future until migrations and other code stops referencing it:
- Added imports in some methods, since module-level imports must be avoided to avoid circular imports.
- Changed type hinting for some methods to strings (to be evauluated by the linter without a change in behavior) to avoid circular imports.

Added unit tests for models_future.taxonomy. Some of these were driven by coverage needs. I didn't remove tests from ami.main, which means we have duplicate coverage. The tests were all blatted out by AI and I didn't work hard to understand them.

There should be no functionality changes, including possible bugfixes.
@kra
kra force-pushed the kra/model-split-tests-storage-taxonomy branch from 0c23191 to 6c6dd45 Compare October 13, 2026 20:34
@kra
kra force-pushed the kra/model-split-tests-storage-taxonomy branch from 4cc24a3 to 36db85e Compare October 19, 2026 21:18
Base automatically changed from kra/model-split-tests-storage-taxonomy to main October 19, 2026 22:44
@netlify

netlify Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for antenna-ssec canceled.

Name Link
🔨 Latest commit 8653f06
🔍 Latest deploy log https://app.netlify.com/projects/antenna-ssec/deploys/6ad7f4a8fd998341ac344ce5

@kra
kra marked this pull request as draft October 21, 2026 01:07
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.

1 participant