Skip to content

feat(schedule): add attendees count column to workshop admin list#4642

Merged
estyxx merged 2 commits into
mainfrom
feature/schedule-attendees-count
May 15, 2026
Merged

feat(schedule): add attendees count column to workshop admin list#4642
estyxx merged 2 commits into
mainfrom
feature/schedule-attendees-count

Conversation

@estyxx
Copy link
Copy Markdown
Member

@estyxx estyxx commented May 15, 2026

Summary

  • Adds an Attendees column to the ScheduleItem admin list view, visible when filtering by type=training (workshops)
  • Displays registered attendees as N / capacity when a capacity is set, or just N when there is none
  • Annotates the queryset with Count("attendees", distinct=True) to avoid N+1 queries — a single SQL COUNT per row rather than a separate query per row

Test plan

  • Open /admin/schedule/scheduleitem/?type__exact=training and verify the new Attendees column appears
  • Check that items with attendees_total_capacity set show N / capacity format
  • Check that items without a capacity show just the count

@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pycon Error Error May 15, 2026 2:59pm

Shows registered attendees as "N / capacity" (or just "N" when no
capacity is set) using an annotated queryset to avoid N+1 queries.
@estyxx estyxx force-pushed the feature/schedule-attendees-count branch from 106d17f to 9ee3c07 Compare May 15, 2026 14:53
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 15, 2026

Adds an attendees_count column to the ScheduleItemAdmin list view showing registered attendees (and capacity when set), and refactors spaces_left to reuse the same queryset annotation.

Testing

No tests added for the new functionality:

  • attendees_count() — both the "no capacity" and "with capacity" display branches are uncovered
  • spaces_left() — the change from obj.attendees.count() to obj.attendees_count_annotation is a behaviour-affecting refactor with no test coverage; a regression here would be invisible

Error Handling

spaces_left and attendees_count both read obj.attendees_count_annotation directly. If a ScheduleItem object is ever fetched outside of the custom get_queryset (e.g. in a test, a signal handler, or a future change_view override), this raises AttributeError. The old obj.attendees.count() was unconditionally safe. A getattr(obj, 'attendees_count_annotation', None) fallback (or a comment marking the dependency) would prevent a hard crash.

Architecture

attendees_count is unconditionally in list_display, so it appears for talks, keynotes, and all other item types — not just trainings. Those rows will show 0 or 0 / N, which is misleading. A get_list_display() override that adds the column only when request.GET.get('type') == 'training' would make the intent match the implementation.

Minor

@admin.display on attendees_count could set ordering="attendees_count_annotation" to make the column sortable, which is the main usability reason to annotate rather than calling .count().

@estyxx estyxx merged commit 81ff672 into main May 15, 2026
7 of 8 checks passed
@estyxx estyxx deleted the feature/schedule-attendees-count branch May 15, 2026 15:01
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.52%. Comparing base (b26753e) to head (8d5826e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4642   +/-   ##
=======================================
  Coverage   92.52%   92.52%           
=======================================
  Files         359      359           
  Lines       10791    10791           
  Branches      821      821           
=======================================
  Hits         9984     9984           
  Misses        696      696           
  Partials      111      111           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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