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

dev/core#982 add dedupe.getstatistics api #14298

Merged
merged 1 commit into from
May 27, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented May 22, 2019

Overview

Add dedupe.getstatistics api action

Before

No action for this

After

Action exists

Technical Details

Per gitlab the intent is to add a bunch of api so get the logic out of the form into somewhere more accessible.

One goal is to get rid of calls to CRM_Core_BAO_PrevNextCache::retrieve which just takes awful parameters. In here I add Dedupe.get & Dedupe.getstatistics & use these from CRM_Dedupe_Merger::getMergeStats instead of CRM_Core_BAO_PrevNextCache::retrieve

Comments

I'm open to a different naming option - currently looking at

Dedupe.getstatistics- gets stats about the results of an attempted merge
Dedupe.getmatches - gets matches for a criteria set, optional param as to whether to reload the cache is empty (possibly should also offer empty+ reload option)

Discussed with @colemanw on gitlab & this is implemented according to concept from him https://chat.civicrm.org/civicrm/pl/pqtuciyswtrcmkxedz1aarabcr

@JKingsnorth

@civibot
Copy link

civibot bot commented May 22, 2019

(Standard links)

@civibot civibot bot added the master label May 22, 2019
@eileenmcnaughton eileenmcnaughton force-pushed the dedupe_stats branch 5 times, most recently from 7cd216a to 65c137e Compare May 22, 2019 23:13
if (!empty($previousStats)) {
if ($previousStats[0]['merged']) {
$merged = $merged + $previousStats[0]['merged'];
if ($previousStats['merged']) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was hit by tests so has cover

@eileenmcnaughton eileenmcnaughton force-pushed the dedupe_stats branch 7 times, most recently from 2df7630 to 39a55a7 Compare May 23, 2019 23:08
Per gitlab the intent is to add a bunch of api so get the logic out of the form into somewhere more accessible.

Following agreement on this I would change all calls to CRM_Dedupe_Merger::getMergeStats to call this api
and get rid of the call to CRM_Core_BAO_PrevNextCache::retrieve from getMergeStats since that retrieve
function really does differrent stuff & is being kinda pointlessly overloaded here.
@eileenmcnaughton
Copy link
Contributor Author

@colemanw ok - getting this past syntax conformance was a challenge but I got there

// This is so bad. We actually have a camel case field name in the DB. Don't do that.
// Intercept the pain here.
$params['cacheKey'] = $params['cachekey'];
unset($params['cachekey']);
Copy link
Member

Choose a reason for hiding this comment

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

Oh no. We should fix this!!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's bad isn't it!

@colemanw colemanw merged commit 3f80dc2 into civicrm:master May 27, 2019
@colemanw
Copy link
Member

I wish this were a little bit thinner with more logic in a BAO function and less in an api3 function, because that would make it easier to port it to api4. But it's useful and has a test, so merging.

@colemanw colemanw deleted the dedupe_stats branch May 27, 2019 21:59
@eileenmcnaughton
Copy link
Contributor Author

@colemanw yeah hopefully we can move that way - but I think we have to go from the outside in here....

@eileenmcnaughton
Copy link
Contributor Author

@colemanw what we could do is create a NEW BAO that extends the prevnext cache DAO but is called 'Dedupe' - that might help in that direction

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.

2 participants