Skip to content

feat: add well counts and groups filter for projects view (BDMS-876)#722

Merged
jirhiker merged 2 commits into
stagingfrom
BDMS-876-projects-view
Jun 16, 2026
Merged

feat: add well counts and groups filter for projects view (BDMS-876)#722
jirhiker merged 2 commits into
stagingfrom
BDMS-876-projects-view

Conversation

@jeremyzilar

Copy link
Copy Markdown
Contributor

Summary

  • Adds well_count to group list and GET responses for the Projects page
  • Adds virtual groups filter and sort on the water-well list so wells can be scoped by project
  • Eager-loads group associations on well list queries

Test plan

  • uv run pytest tests/test_group.py tests/test_thing.py -k "well_count or groups"
  • GET /group returns well_count per project
  • GET /thing/water-well?filter=... filters by linked project id via groups eq
  • Sort by groups returns 200

Notes

  • Open question: should well counts include all group types or only project-like groups?
  • Merge before or with the matching OcotilloUI PR

Groups list responses now include well counts, and the wells list can filter and sort by linked projects through the virtual groups field.
@jeremyzilar jeremyzilar requested a review from jirhiker June 13, 2026 18:24
@jeremyzilar jeremyzilar self-assigned this Jun 13, 2026
@jeremyzilar jeremyzilar changed the title BDMS-876: Projects view API (well counts and groups filter) feat: add well counts and groups filter for projects view (BDMS-876) Jun 15, 2026
@jirhiker

Copy link
Copy Markdown
Member

Comment thread services/query_helper.py
nlg = _linked_group_select(g.name.ilike(f"%{value}%"))
return sql.where(~exists(nlg))

if operator == "contains":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this functionality is duplicated in _linked_thing_select. consider moving to a separate function

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been updated @jirhiker !

…ry shape.

_apply_thing_contacts_filter, _apply_thing_groups_filter, and
_apply_contact_things_filter all defined the same inner function pattern:
select(1).from(assoc).join(target).where(owner_fk, [extra], predicate).

Extracted that pattern into a module-level _build_assoc_exists helper and
replaced all three inner functions with calls to it. Behaviour is unchanged;
the null/nnull unconditional checks pass no predicate (optional arg).
@jeremyzilar jeremyzilar requested a review from jirhiker June 16, 2026 14:10
@jirhiker jirhiker merged commit afb7d51 into staging Jun 16, 2026
9 checks passed
@jirhiker jirhiker deleted the BDMS-876-projects-view branch June 16, 2026 16:47
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.

2 participants