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 readability & caching on CRM_Contact_BAO_Relationship::isInheritedMembershipInvalidated #15061

Merged
merged 1 commit into from
Aug 22, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Aug 17, 2019

Overview
Mostly code readability but also improves caching

Before

Sql query & some hard-to-read & unnecessary wrangling

After

More readable. Introduction of a cached function improves performance

Technical Details

@seamuslee001 looking at this I was going to use the 'fields' cache but of course the name was wrong so I figured adding a generic 'metadata' cache would cover a lot of uses (including probably what 'fields' currently is....

Comments

@civibot
Copy link

civibot bot commented Aug 17, 2019

(Standard links)

@civibot civibot bot added the master label Aug 17, 2019
@eileenmcnaughton eileenmcnaughton changed the title Fix readability & caching on CRM_Contact_BAO_Relationship::isInherite… Fix readability & caching on CRM_Contact_BAO_Relationship::isInheritedMembershipInvalidated Aug 17, 2019
return [$relTypeId, $isDeletable];
$membershipType = CRM_Member_BAO_MembershipType::getMembershipType($membershipValues['membership_type_id']);
$relTypeIds = $membershipType['relationship_type_id'];
$membshipInheritedFrom = $membershipValues['owner_membership_id'] ?? NULL;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just broke the IF into 2 because it was hard to read & a later fix would be more nuanced on the second part

@eileenmcnaughton
Copy link
Contributor Author

Refactoring relates to #14410

eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Aug 17, 2019
…relationship

This pulls out some of the good work & test written in civicrm#14410, but treating the parts as separate bugs
with separate cleanup requirements.

I put up cleanup in civicrm#15061

And this addresses the need for the relationship to not be deleted if a valid one still exists
- wrangled out into a separate function
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Aug 17, 2019
…relationship

This pulls out some of the good work & test written in civicrm#14410, but treating the parts as separate bugs
with separate cleanup requirements.

I put up cleanup in civicrm#15061

And this addresses the need for the relationship to not be deleted if a valid one still exists
- wrangled out into a separate function
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Aug 18, 2019
…relationship

This pulls out some of the good work & test written in civicrm#14410, but treating the parts as separate bugs
with separate cleanup requirements.

I put up cleanup in civicrm#15061

And this addresses the need for the relationship to not be deleted if a valid one still exists
- wrangled out into a separate function
@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001 this failed on something to do with the cache - possibly I need to add a clear. Before I dig - do you agree with adding this cache?

@seamuslee001
Copy link
Contributor

I think that makes sense

@eileenmcnaughton eileenmcnaughton force-pushed the agile branch 2 times, most recently from 7356f2c to f8c1556 Compare August 18, 2019 07:47
@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001 looks like it was the 'clear' thing - passing now

…dMembershipInvalidated

This removes an sql query & some hard wrangling & uses the api - wrapped in a caching helper.
@eileenmcnaughton
Copy link
Contributor Author

Actually I just pushed a tweak so they are re-running

eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Aug 21, 2019
…relationship

This pulls out some of the good work & test written in civicrm#14410, but treating the parts as separate bugs
with separate cleanup requirements.

I put up cleanup in civicrm#15061

And this addresses the need for the relationship to not be deleted if a valid one still exists
- wrangled out into a separate function
@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001 this is passing now

@seamuslee001
Copy link
Contributor

I think the code looks fine to me and i think we should have enough test coverage in this are. Merging

@seamuslee001 seamuslee001 merged commit 0ab0e4b into civicrm:master Aug 22, 2019
@seamuslee001 seamuslee001 deleted the agile branch August 22, 2019 01:07
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Aug 29, 2019
…relationship

This pulls out some of the good work & test written in civicrm#14410, but treating the parts as separate bugs
with separate cleanup requirements.

I put up cleanup in civicrm#15061

And this addresses the need for the relationship to not be deleted if a valid one still exists
- wrangled out into a separate function
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Oct 14, 2019
…relationship

This pulls out some of the good work & test written in civicrm#14410, but treating the parts as separate bugs
with separate cleanup requirements.

I put up cleanup in civicrm#15061

And this addresses the need for the relationship to not be deleted if a valid one still exists
- wrangled out into a separate function
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Oct 25, 2019
…relationship

This pulls out some of the good work & test written in civicrm#14410, but treating the parts as separate bugs
with separate cleanup requirements.

I put up cleanup in civicrm#15061

And this addresses the need for the relationship to not be deleted if a valid one still exists
- wrangled out into a separate function
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Oct 26, 2019
…relationship

This pulls out some of the good work & test written in civicrm#14410, but treating the parts as separate bugs
with separate cleanup requirements.

I put up cleanup in civicrm#15061

And this addresses the need for the relationship to not be deleted if a valid one still exists
- wrangled out into a separate function
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Oct 27, 2019
…relationship

This pulls out some of the good work & test written in civicrm#14410, but treating the parts as separate bugs
with separate cleanup requirements.

I put up cleanup in civicrm#15061

And this addresses the need for the relationship to not be deleted if a valid one still exists
- wrangled out into a separate function
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Oct 28, 2019
…relationship

This pulls out some of the good work & test written in civicrm#14410, but treating the parts as separate bugs
with separate cleanup requirements.

I put up cleanup in civicrm#15061

And this addresses the need for the relationship to not be deleted if a valid one still exists
- wrangled out into a separate function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants