Skip to content

feat: add customizable notification period#3567

Merged
nijel merged 7 commits intomainfrom
notify
Mar 20, 2026
Merged

feat: add customizable notification period#3567
nijel merged 7 commits intomainfrom
notify

Conversation

@nijel
Copy link
Member

@nijel nijel commented Mar 20, 2026

No description provided.

@nijel nijel self-assigned this Mar 20, 2026
@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 97.72727% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.30%. Comparing base (543cfb7) to head (393b9c5).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3567      +/-   ##
==========================================
+ Coverage   86.12%   86.30%   +0.18%     
==========================================
  Files          65       65              
  Lines        7576     7655      +79     
  Branches      712      715       +3     
==========================================
+ Hits         6525     6607      +82     
+ Misses        799      798       -1     
+ Partials      252      250       -2     
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a per-customer setting to send one additional “upcoming payment” notification N days before expiry, and adjusts the recurring payments notifier to consider these earlier notifications.

Changes:

  • Add Customer.upcoming_payment_notification_days with a max-value validator and CRM display.
  • Extend Donation.should_notify() and Subscription.should_notify() to trigger on the customer-configured day offset.
  • Update recurring_payments command logic and add tests covering extra notification behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
weblate_web/payments/models.py Adds the new customer field and validation for configurable notification lead time.
weblate_web/payments/migrations/0057_customer_upcoming_payment_notification_days.py Persists the new field in the DB schema.
weblate_web/models.py Uses the new field to decide whether to notify for donations/subscriptions.
weblate_web/management/commands/recurring_payments.py Expands the expiry scan window based on the maximum configured customer lead time and tweaks summary inclusion.
weblate_web/tests.py Adds validation and behavior tests for the new notification timing.
weblate_web/crm/templates/payments/customer_detail.html Displays the configured extra notification period on the customer detail page.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

weblate_web/management/commands/recurring_payments.py:69

  • expires_notify is now extended to the maximum upcoming_payment_notification_days across all customers, which makes the command load and iterate over every subscription/donation expiring within that maximum window (up to 90 days) even though only a small subset will actually match should_notify(timestamp) on a given run. This can significantly increase runtime on large datasets once any customer sets a large value. Consider querying the default 31-day window as before and adding a separate, narrower query for customers with non-zero extra days (e.g., per distinct extra-day value or by filtering to expiries exactly timestamp + extra_days) so the command doesn’t scan the whole max window each time.
        summary_notify = timestamp + timedelta(days=31)
        customer_notification_days = (
            Customer.objects.aggregate(Max("upcoming_payment_notification_days"))[
                "upcoming_payment_notification_days__max"
            ]
            or 0
        )
        expires_notify = timestamp + timedelta(days=max(31, customer_notification_days))

        # Expiring subscriptions
        subscriptions = Subscription.objects.filter(
            expires__lte=expires_notify, enabled=True
        ).exclude(payment=None)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nijel nijel enabled auto-merge (squash) March 20, 2026 08:04
@nijel nijel merged commit 1b21257 into main Mar 20, 2026
36 checks passed
@nijel nijel deleted the notify branch March 20, 2026 08:20
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