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

[REF] Move more code to the trait [WIP] #16936

Closed
wants to merge 10 commits into from

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Mar 31, 2020

Overview

Follow on cleanup commits from #16935

This affects code to send emails called from

  • search results - most entities
  • individual contact (cid is in url)
  • new email form (standalone mode)

Before

Emails task forms work. Code very nasty

After

Emails task forms work. Code moving towards readability

Technical Details

I'll keep adding to this & likely spin stuff off if #16935 is merged (unless someone wants to review / merge this)

Comments

@civibot
Copy link

civibot bot commented Mar 31, 2020

(Standard links)

@civibot civibot bot added the master label Mar 31, 2020
@eileenmcnaughton eileenmcnaughton force-pushed the email2 branch 8 times, most recently from 7f392e5 to 4e08a5f Compare April 1, 2020 10:02
@eileenmcnaughton eileenmcnaughton changed the title [REF] Move more code to the trait [REF] Move more code to the trait [WIP] Apr 1, 2020
@eileenmcnaughton
Copy link
Contributor Author

eileenmcnaughton commented Apr 1, 2020

@colemanw I wanted to check your thoughts on this - 4e08a5f - basically it's an attempt to change the ad-hoc ajax to be an entity reference (& over up the refine search goodness). That patch only touches the BCC field (not to or cc) However, I hit a couple of limitations

  1. the ad hoc ajax returns contact id & email - the email might not be the primary one but my current effort is v3 Contact api - which only searches primary email
  2. the adhoc code searches email or sort name which I can't obviously do through the api
  3. the email isn't displayed like with the ad hoc code - which is really useful when it's an email you are getting

Thoughts on the best approach? Note that the query gets slow if you do sort_name LIKE 'c%' OR email LIKE 'c%' & you really need a union

The function CRM_Contact_Page_AJAX::getContactEmail is one of our  earlier  ajax attempts & this approach has been largely
replaced with entity Reference fields. In order to switch over we need to bring Email.getlist api to parity which  means
1) searching on sortname first, if less than 10 results on emails include emails
2) appropriate respect for includeWildCardInName (this should already be in the generic getlist)
3) filter out on_hold, is_deceased, do_not_email
4) acl support (should already  be part of the api).

The trickiest of these to support is the first - because we need to avoid using a non-performant OR
My current solution is the idea of a fallback field to search if the search results are less than the limit.
in most cases this won't require a second query but when it does it should be fairly quick.
The function CRM_Contact_Page_AJAX::getContactEmail is one of our  earlier  ajax attempts & this approach has been largely
replaced with entity Reference fields. In order to switch over we need to bring Email.getlist api to parity which  means
1) searching on sortname first, if less than 10 results on emails include emails
2) appropriate respect for includeWildCardInName (this should already be in the generic getlist)
3) filter out on_hold, is_deceased, do_not_email
4) acl support (should already  be part of the api).

The trickiest of these to support is the first - because we need to avoid using a non-performant OR
My current solution is the idea of a fallback field to search if the search results are less than the limit.
in most cases this won't require a second query but when it does it should be fairly quick.
This is still overriden on the contact email.
I have duplicated this code rather than moving it in case any non-core code calls it. We can remove in a bit
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.

1 participant