Skip to content

Add sedd review data management command#4559

Draft
patrick91 wants to merge 1 commit intomainfrom
demo-data-review
Draft

Add sedd review data management command#4559
patrick91 wants to merge 1 commit intomainfrom
demo-data-review

Conversation

@patrick91
Copy link
Member

What

ToDo

@vercel
Copy link

vercel bot commented Feb 5, 2026

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

Project Deployment Actions Updated (UTC)
pycon Ready Ready Preview Feb 5, 2026 4:56pm

@claude
Copy link
Contributor

claude bot commented Feb 5, 2026

Summary

This PR adds a Django management command seed_review_data to generate test data for the review system. The command creates a conference, reviewers, submissions, grants, and associated review sessions with scores. This is useful for local development and testing of the review workflow.

Note: There's a typo in the PR title: "sedd" should be "seed".

Architecture & Design

✓ Good separation of concerns: The command is well-organized with private methods for each major entity type (_create_conference, _create_reviewers, _create_submissions, etc.), making the code readable and maintainable.

⚠️ Transaction handling: The command lacks transaction wrapping. If any part of the seeding process fails partway through, you could be left with partial/inconsistent data. Consider adding @transaction.atomic decorator to the handle method, similar to the fill_sponsor_data.py command at backend/sponsors/management/commands/fill_sponsor_data.py:15.

⚠️ Flush operation scope: The _flush() method at backend/reviews/management/commands/seed_review_data.py:115-118 deletes ALL review data globally, not just data created by this seed command. This could be dangerous if run on a database with real data. Consider:

  • Adding a clear warning in the help text that --flush deletes ALL review data
  • OR: Track seeded data (e.g., via a specific marker in conference code/name) and only delete that
  • OR: Make it clear in documentation this is for local dev only

Testing & Coverage

❌ Missing tests: There are no tests for this management command. While seed/fixture commands are sometimes not tested, this command has complex logic that would benefit from at least basic smoke tests:

  • Test that command runs without errors
  • Verify the correct number of objects are created
  • Test the --flush flag works correctly
  • Test parameter variations (--submissions, --reviewers, --grants)

⚠️ Multi-tenant considerations: The command creates data for a specific conference but doesn't appear to have any tenant isolation issues since all created objects are properly scoped to the conference being created. However, the _flush() method breaks this isolation by deleting ALL reviews globally.

Error Handling

⚠️ No error handling: The command assumes all operations succeed. Consider handling potential failures:

  • What if Conference.objects.create() fails due to unique constraint violations?
  • What if get_or_create() calls fail for related objects (topics, languages, etc.)?
  • The random.sample() call at backend/reviews/management/commands/seed_review_data.py:194 could fail if tag_names has fewer items than requested

⚠️ Silent failures: If conference creation fails or returns unexpected data, the subsequent operations may fail silently or create inconsistent state.

Performance

✓ Efficient bulk operations: The submission creation logic is reasonably efficient, creating users and submissions one at a time which is acceptable for a seeding command.

⚠️ N+1 queries potential: At backend/reviews/management/commands/seed_review_data.py:345-354, the review creation loops through submissions and reviewers, creating UserReview objects one at a time. For large datasets, consider using bulk_create():

reviews_to_create = []
for submission in submissions:
    for reviewer in selected_reviewers:
        reviews_to_create.append(UserReview(...))
UserReview.objects.bulk_create(reviews_to_create)

However, given this is a dev/test seeding script and the default is only 20 submissions, the current approach is acceptable.

✓ Reasonable defaults: The default values (20 submissions, 5 reviewers, 15 grants) are reasonable for local development.

Code Quality

⚠️ Hardcoded constants: The SCORE_OPTIONS, TALK_TITLES, and REVIEWER_NAMES at the top are good, but the speaker creation logic at backend/reviews/management/commands/seed_review_data.py:244 uses hardcoded UUID generation which might create conflicts if run multiple times without --flush. The uid prefix helps but isn't foolproof.

⚠️ LazyI18nString usage: The command correctly uses LazyI18nString for i18n fields, but only provides English translations. This is fine for seeding, but worth noting.

✓ Good output: The command provides helpful stdout messages showing what's being created, which is good UX for a management command.

Recommendations

  1. High priority: Add @transaction.atomic to prevent partial data creation on errors
  2. High priority: Fix the _flush() method to be safer (add warnings or scope to seeded data only)
  3. Medium priority: Add basic tests to ensure the command works as expected
  4. Medium priority: Add error handling for potential failures (unique constraints, etc.)
  5. Low priority: Consider using bulk_create() for reviews if you expect to increase defaults
  6. Low priority: Fix the typo in the PR title

Positive Notes

  • Clear code organization with well-named helper methods
  • Realistic test data (varied speaker levels, tags, multiple submissions per speaker)
  • Flexible command-line arguments for customization
  • Good feature: Creates speakers with multiple submissions to test that scenario

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 0% with 163 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.70%. Comparing base (41c9e3e) to head (c117348).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4559      +/-   ##
==========================================
- Coverage   94.16%   92.70%   -1.47%     
==========================================
  Files         353      354       +1     
  Lines       10347    10510     +163     
  Branches      761      780      +19     
==========================================
  Hits         9743     9743              
- Misses        502      665     +163     
  Partials      102      102              
🚀 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