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

fix: hourly cron job to check for prematurely expired memberships #3060

Merged
merged 4 commits into from
Apr 11, 2024

Conversation

dkoo
Copy link
Contributor

@dkoo dkoo commented Apr 11, 2024

All Submissions:

Changes proposed in this Pull Request:

Addresses the same issue as in #3050, but with a more performant approach.

Rather than filtering data at the moment any membership/subscription is fetched, this implements an hour cron job that iterates through all active subscriptions on the site, checks any memberships associated with those subscriptions, and reactivates memberships that aren't in an active state. This should ensure that anyone with an active subscription should have access to the memberships their subscription(s) grant them.

How to test the changes in this Pull Request:

Follow the same testing instructions as in #3050, but also note that if you have define( 'NEWSPACK_LOG_LEVEL', 2 ); defined in wp-config.php, you'll see some additional logging showing that the cron job is working:

[11-Apr-2024 16:51:00 UTC] [325]  [NEWSPACK][Newspack\Memberships::fix_expired_memberships_for_active_subscriptions]: Checking for expired memberships linked to active subscriptions...
[11-Apr-2024 16:51:02 UTC] [325]  [NEWSPACK][Newspack\Memberships::fix_expired_memberships_for_active_subscriptions]: Reactivated 5 memberships linked to active subscriptions.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@dkoo dkoo added the [Status] Needs Review The issue or pull request needs to be reviewed label Apr 11, 2024
@dkoo dkoo self-assigned this Apr 11, 2024
@dkoo dkoo requested a review from a team as a code owner April 11, 2024 17:06
Copy link
Contributor

@claudiulodro claudiulodro left a comment

Choose a reason for hiding this comment

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

Looks solid. I think we may run into scalability issues if it's processing thousands of subscriptions, but since it's cron it won't really affect the site functionality and there are a few different ways we can adjust it to compensate. I'd like to see if it does run into issues first though :)

@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Apr 11, 2024
@claudiulodro claudiulodro merged commit 77eeee3 into release Apr 11, 2024
7 checks passed
@claudiulodro claudiulodro deleted the fix/cron-job-for-expired-memberships branch April 11, 2024 17:45
matticbot pushed a commit that referenced this pull request Apr 11, 2024
## [3.6.8](v3.6.7...v3.6.8) (2024-04-11)

### Bug Fixes

* hourly cron job to check for prematurely expired memberships ([#3060](#3060)) ([77eeee3](77eeee3))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 3.6.8 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Apr 11, 2024
# [3.7.0-alpha.2](v3.7.0-alpha.1...v3.7.0-alpha.2) (2024-04-11)

### Bug Fixes

* hourly cron job to check for prematurely expired memberships ([#3060](#3060)) ([77eeee3](77eeee3))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 3.7.0-alpha.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released on @alpha released [Status] Approved The pull request has been reviewed and is ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants