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

APIv4 - Specify BridgeEntities to assist with joins #17808

Merged
merged 1 commit into from
Jul 20, 2020

Conversation

colemanw
Copy link
Member

Overview

In our schema we have these tiny tables like civicrm_entity_tag which serve no purpose other than to "bridge" 2 other tables together. Arguably they don't deserve to be their own API entities, but what I've done here is to at least distinguish them as "bridge" entities so they can receive separate treatment in search screens.
I've also taught the API to create joins through these bridge entities with a fairly simple syntax that, to the API consumer, only feels like 1 join, when behind the scenes the api constructs both joins and figures out which FKs link the 3 tables together.

Comments

This gets us closer to having things like Activities and Tags in the new SearchCreator. It still doesn't solve the problem of groups, which use 2 tables + caching to deal with smart groups. It also doesn't yet solve the problem of getting these things easily discoverable in the SearchCreator UI, but it's a step in the right direction.

@civibot
Copy link

civibot bot commented Jul 13, 2020

(Standard links)

@civibot civibot bot added the master label Jul 13, 2020
@eileenmcnaughton
Copy link
Contributor

I think the test cover is appropriate to this change

@eileenmcnaughton eileenmcnaughton merged commit d2302f9 into civicrm:master Jul 20, 2020
@eileenmcnaughton eileenmcnaughton deleted the bridge branch July 20, 2020 00:45
@MegaphoneJon
Copy link
Contributor

@colemanw With regard to groups in APIv4 - there was some discussion some years back and some folks thought it made sense to get rid of civicrm_group_contact_cache, and store smart group contacts in civicrm_group_contact.

I think that would simplify your APIv4 work, simplify code generally, and solve some performance issues (e.g. a query that searches for members of a smart group and a static group will always involve an unindexed join).

@eileenmcnaughton
Copy link
Contributor

@MegaphoneJon any idea where the links are - I recall some discussion

@MegaphoneJon
Copy link
Contributor

@eileenmcnaughton They're on JIRA on CRM-18146. Nicolas was advocating for this as a deadlock improvement issue; I'm suggesting it as a way to simplify queries (and also address issues like CRM-20049.

I have several ideas for improving smart group performance, but at the moment I think it makes sense to focus on whether this makes sense as a way to save effort on APIv4, similar to the relationship vortex table.

@mattwire
Copy link
Contributor

@MegaphoneJon Funnily enough I suggested the opposite - storing everything in civicrm_group_contact_cache :-) but I don't think it matters which way it happens - it would certainly significantly simplify group checking from a query perspective.

@colemanw
Copy link
Member Author

@MegaphoneJon yes we've been discussing that. @totten has captured some possible approaches:
https://gist.github.com/totten/93350feec3d11c7c3ca48d2cc086a608

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants