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/#/233 Expose information about where a contact has been merged to #12489

Merged
merged 2 commits into from
Jul 18, 2018

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Jul 17, 2018

Overview

Exposes information about what contact a contact deleted by merge has been merged from. Via the api it exposes this and also which contacts have been merged into a given contact.

Before

Poor visibility on where a contact has been deleted as part of a merge
screenshot 2018-07-17 17 25 11

After

Merged nature is much clearer.
screenshot 2018-07-17 17 25 27

In addition the calculus for the 'merged to' & 'merged from' is exposed via api

Technical Details

We have a fairly opaque data structure for linking merged contacts to the contacts they have been merged to. There have been various discussions about changing it so I feel like the ownership of exposing this relationship should sit in core.

Examples of where this could be used by an extension are

  1. extended reports offers an address history report (which can be a contact summary tab) - it should provide this history across multiple contacts
  2. various privacy extensions should find and delete data for contacts deleted by merge as well as the current contact.

The apis used here (open to any form of bikeshedding on action name / params) are:

$result = civicrm_api3('Contact', 'getmergedto', ['contact_id' => $contactID]);

$result = [
  'values' => [5 => ['id' => 5],
  'count'.....
];
$result = civicrm_api3('Contact', 'getmergedfrom', ['contact_id' => $contactID]);

$result = [
  'values' => [5 => ['id' => 5], 6 => ['id' => 6]]
  'count'.....
];

In each case result is an array of one (getmergedto) or n (getmergedfrom) contact records, with only 'id' populated.

Comments

https://lab.civicrm.org/dev/core/issues/233

@totten @colemanw @JKingsnorth

@civibot
Copy link

civibot bot commented Jul 17, 2018

(Standard links)

@eileenmcnaughton eileenmcnaughton changed the title Mergees dev/core/#/233 Expose information about where a contact has been merged to Jul 17, 2018
…stination contact and source contacts for merged contacts.

This 'data structure' is 'owned' by core & somewhat subject to future change so establishing a tested methodology for retrieving contact history in
core can support extensions such as
- extended reports - which exposes an address_history tab
- privacy extensions - which need to recover and potentially delete contacts that were merged
into the current contact
@eileenmcnaughton
Copy link
Contributor Author

test fail is unrelated

@totten
Copy link
Member

totten commented Jul 18, 2018

(CiviCRM Review Template WORD-1.1)

  • (r-explain) Pass
  • (r-test) Undecided: There's a failure in api_v3_ReportTemplateTest.testActivitySummary. I don't recall this as a common false-negative, but if you do recall it as a common false-negative, then I'll believe you. ;)
  • (r-code) Pass: Code style is generally consistent.
  • (r-doc) Soft Pass: The UX change is subtle enough that it doesn't need user docs, IMHO. It's up to whether the DX needs docs.
  • (r-maint) Pass: Adds coverage for new functions.
  • (r-run) Undecided: Not assessed
  • (r-user) Pass: The UI updates in the screenshot look sensible.
  • (r-tech) Pass: Mostly new code. Hard to see how it would break anything else.

@eileenmcnaughton
Copy link
Contributor Author

@totten yes test is a known bug (from a merge yesterday although hopefully fix is in) - what is holding this up now?

@eileenmcnaughton
Copy link
Contributor Author

test this please

@eileenmcnaughton
Copy link
Contributor Author

(there is space in test queue to re-running as it's harder to get people to look when there is a red flag)

@stesi561
Copy link
Contributor

In addition to the above.

  • Run it (r-run) Pass after merging a contact it shows as advertised. Tried merging the contact that a contact had been merged into - it correctly points to the final contact. Had a look at the api, works as expected.

@eileenmcnaughton
Copy link
Contributor Author

@stesi561 you are my new favourite person - really appreciate this.

Adding merge-on-pass

@eileenmcnaughton
Copy link
Contributor Author

unrelated fail

@eileenmcnaughton eileenmcnaughton merged commit b6bba74 into civicrm:master Jul 18, 2018
@eileenmcnaughton eileenmcnaughton deleted the mergees branch July 18, 2018 10:36
@JKingsnorth
Copy link
Contributor

I'm a bit late to this party, but it looks OK to me.

I have some reservations about the display of the (This contact has been merged into...). (It might have been nicer on the next line down after the name, rather than inline). But not so strong as to block anything, and it doesn't impact the inline editing of the name because that's not possible on a deleted contact.

@eileenmcnaughton
Copy link
Contributor Author

I'll happily merge a prettier version if you have an idea

@@ -306,7 +306,7 @@ public static function checkUserPermission($page, $contactID = NULL) {
*/
public static function setTitle($contactId, $isDeleted = FALSE) {
static $contactDetails;
$displayName = $contactImage = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the declaration of display name deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because it was that funny grey in phpstorm (ie. it's immediately re-defined)

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be grey because PHPStorm thinks it's being overwritten:

image

But really it's just confused. I think we should either leave it in, or remove the $contactImage declaration too, by the same logic =]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isn't the contactImage declaration removed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope, just on the next line down =]

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I agree with @JKingsnorth that we should remove both.

eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Sep 4, 2018
…ct and source contacts for merged contacts.

Backport of civicrm#12489

This 'data structure' is 'owned' by core & somewhat subject to future change so establishing a tested methodology for retrieving contact history in
core can support extensions such as
- extended reports - which exposes an address_history tab
- privacy extensions - which need to recover and potentially delete contacts that were merged
into the current contact

dev/core/#/233 Use merged data api to display navigation help on contact deleted by merge

Bug: T199748
Change-Id: I299725a8d39cd45d205874b1f07641283cbb5c96
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.

6 participants