Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement an organizer customer account and fee system | Task management #452

Open
wants to merge 8 commits into
base: development
Choose a base branch
from

Conversation

lcduong
Copy link
Contributor

@lcduong lcduong commented Nov 22, 2024

This PR is part of issue #383

Apply django-celery-beat to manage tasks, this PR implement:

  • Migration file to init tasks for billing invoice which listed in this PR Implement schedule task to collect billing invoice #417 (instead of save in settings file, we use django-celery-beat to save in database)
  • /control/admin/task_management for manage all tasks, Admin can view all scheduled tasks in the systems and able to enable/disable it.

image

  • Move Event to non public after 30 days failed invoice retry

Summary by Sourcery

Implement a task management system for administrators and refactor billing tasks to use 'django-celery-beat' for better task scheduling and management.

New Features:

  • Introduce a task management system for administrators to view and manage scheduled tasks, including enabling and disabling them.

Enhancements:

  • Refactor billing-related tasks to use the 'scopes_disabled' context manager for database operations, improving error handling and task execution.

Build:

  • Integrate 'django-celery-beat' for managing periodic tasks in the database instead of settings files.

Copy link

sourcery-ai bot commented Nov 22, 2024

Reviewer's Guide by Sourcery

This PR implements a task management system using django-celery-beat to handle scheduled tasks, particularly focusing on billing-related operations. The implementation moves task scheduling from static settings to a database-backed system and adds an admin interface for managing these tasks.

Class diagram for Task Management System

classDiagram
    class TaskList {
        +template_name
        +context_object_name
        +model
        +filter_form()
        +get_queryset()
        +process_task_data(task)
        +get_context_data(**kwargs)
        +post(request, *args, **kwargs)
    }
    class TaskFilterForm {
        +name
        +status
        +filter_qs(qs)
    }
    class PeriodicTask {
        +name
        +task
        +crontab
    }
    class CrontabSchedule {
        +day_of_month
        +hour
        +minute
    }
    TaskList --> TaskFilterForm
    TaskList --> PeriodicTask
    PeriodicTask --> CrontabSchedule
Loading

File-Level Changes

Change Details Files
Refactored billing tasks to use database-backed scheduling with django-celery-beat
  • Removed static CELERY_BEAT_SCHEDULE configuration from settings
  • Added migration to initialize billing-related scheduled tasks in the database
  • Added django-celery-beat and cron-descriptor as project dependencies
  • Wrapped database operations in billing tasks with scopes_disabled() for better performance
src/pretix/settings.py
src/pretix/plugins/scheduledtasks/migrations/init_scheduled_tasks.py
src/pretix/eventyay_common/tasks.py
pyproject.toml
Implemented an admin interface for task management
  • Created a new TaskList view for managing scheduled tasks
  • Added task filtering functionality by name and status
  • Implemented UI for enabling/disabling tasks
  • Added task management to admin navigation
src/pretix/control/views/admin.py
src/pretix/control/forms/filter.py
src/pretix/control/templates/pretixcontrol/admin/task_management/task_management.html
src/pretix/static/task_management/js/task_management.js
src/pretix/control/navigation.py
src/pretix/control/urls.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@lcduong lcduong marked this pull request as draft November 22, 2024 09:46
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @lcduong - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@lcduong lcduong marked this pull request as ready for review November 25, 2024 04:25
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @lcduong - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider scoping the use of scopes_disabled() more narrowly to just the specific database queries that need it, rather than wrapping entire functions. The current broad usage could impact performance at scale.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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