-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
dev/membership#18 Enhance parameters for Job.process_membership #16298
dev/membership#18 Enhance parameters for Job.process_membership #16298
Conversation
(Standard links)
|
b5b281f
to
044b4af
Compare
Great @mattwire I am happy to test when you are ready. |
@@ -470,7 +470,14 @@ function civicrm_api3_job_process_membership($params) { | |||
return civicrm_api3_create_error('Could not acquire lock, another Membership Processing process is running'); | |||
} | |||
|
|||
$result = CRM_Member_BAO_Membership::updateAllMembershipStatus(); | |||
// We need to pass this through as a simple array of membership status IDs as values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the purpose of this code is to accept variations in peoples preferences for passing parameters, I'm not sure I would be so forgiving. Instead I would expect people to pass in parameters in the correct format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mattwire I agree with @michaelmcandrew on this - but the presence of many tests was pushing me to merge it, even though this chuck of code doesn't really make sense to me
However, I am concerned that we don't declare a type on exclude_membership_status_ids in the metadata and we are not validating it at the api layer & the validation at the next layer is a bit unclear too.
I think that if it were declare as a INT with a pseudoconstant then an array would be accepted but it would be validated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton @michaelmcandrew I've added the metadata for the exclude_membership_status_ids
parameter - it's now validating as an INT but I don't get a pseudoconstant selector in the API3 UI.
Have added a few comments. Happy to comment some more. Would be easier to review if the status and types stuff was separated. |
5408dad
to
31c3b81
Compare
@elcapo - want to take a look and comment? |
Nothing to add. Looks great to me. Currently having a problem with loads of "Expired" memberships that Thanks @mattwire! |
31c3b81
to
be03a7f
Compare
bump @mattwire - do you know what else we need to do to get this merged? |
be03a7f
to
7dfc5c4
Compare
@michaelmcandrew thanks - I've just rebased and moved the other bit (disabled memberships) to #17143. Are you / @elcapo able to write some unit tests to cover the new parameters? Then this should be ready to be merged. I've just added a note on which tests could be extended to the description of this PR. |
@mattwire I've prepared a test suite for the new parameters. See commit 0205a6cb in my membership_disabled branch. I couldn't see how to make a pull request to your branch, so let me know how you want me to send you the changes. Also, some tests were failing and I wasn't sure if it was because of the tests, or because of the parameter handling, so I created a second branch, membership_disabled_fixes, that incorporates both the tests and the fixes that made the code pass all the new tests. |
Right after sending my message, I've realized I had a few asserts commented in the last test, so please consider also this additional commit 20d11c61. |
aa56310
to
b8a3bb6
Compare
Did you check out my fixes to make the tests pass? I changed a few things like checking if variables were defined in a different way, as the way they were passed as FALSE, sometimes they were ignored and assumed TRUE. Check this https://github.com/elcapo/civicrm-core/commit/7b10697389e0e5b0439eff2e9e89b228308b9b1f and let me know your thoughts about it. |
@elcapo I didn't - but now I have and it's still failing on 3 tests - any ideas? |
I've just updated the tests so they are a bit easier to use. See https://github.com/elcapo/civicrm-core/commit/68dd0d85d2ecc8d8dfc88dfea5ce550ddbf2b8ad. I was making several asserts per test and now I'm only making one, so we've now 20 tests that are showing 2 failures. Include Test MembershipsWhen using this call: civicrm_api3('job', 'process_membership', [
'exclude_test_memberships' => FALSE,
]); the membership created in Including Memberships of Inactive Membership TypesWhen using this call: $this->callAPISuccess('job', 'process_membership', [
'only_active_membership_types' => FALSE,
]); the membership created in |
5822f24
to
68cef92
Compare
Hi @mattwire, Is there any problem with the changes I can still help with? I've checked Jenkins and apparently there are some minor style issues: Let me know if you want me to fix them. |
@elcapo Yes please can you fix the style issues |
@mattwire Please, test again with the file as here: JobProcessMembershipTest.php. There are this two changes: I tested the file with civilint and it appears to be fine now. |
505c7c0
to
666a686
Compare
@elcapo I'm still getting test failures on this:
Any ideas? I squashed the commits but should have everything from your branch? |
@mattwire Your last commit fixes the issue, right? At least the one of our two tests failing. I've just executed the new tests with your branch and they all worked fine. Apparently the issue is now with standard membership tests... |
@elcapo Let's see if the tests pass now |
e463485
to
6513c2e
Compare
This has good test cover & most review has been responded to - there is just one comment by @michaelmcandrew that I think might need more response. If you were opening this today I think we would insist it was apiv4 - @colemanw that raises the same 'how would it look question' as another similar job api one today |
@eileenmcnaughton @colemanw The issue with scheduled jobs and API4 is that we can't run API4 scheduled jobs yet because the scheduled jobs manager only works with API3 - if we could remove that blocker then I'd start writing a lot more in API4! |
6513c2e
to
8a9500e
Compare
@eileenmcnaughton Have responded - pseudoconstant does not load in API3 UI but I've added it anyway. And now validating as INT |
test this please |
OK sounds good - I've removed the needs-documentation flag as I see that as optional now as I really want to pivot to a v4 focus. To be clear I don't want to discourage you - but it's less compulsory now as we try to get away from apiv3 I think |
Hi there, thank you so much for this. I came upon this wondering why my membership statuses weren't updating. After testing this out, I have a couple of comments:
I see you wanted to focus on api4 - is there somewhere else I can monitor the progression of this? I was having trouble finding anything related to this job. Thanks! |
Overview
This adds some parameters to control the Job.process_membership API/scheduled job per gitlab issues.
https://lab.civicrm.org/dev/membership/issues/18
Before
Cannot control behaviour of Job.process_membership.
After
Can control Job.process_membership:
Technical Details
Comments
@michaelmcandrew Can you write a unit test to validate the new parameters? There are a number of tests on Job.process_membership in
tests/phpunit/api/v3/JobTest.php
which could be extended/copied.