eileenmcnaughton / org.wikimedia.relationshipblock

Other
5 stars 11 forks source link

Expired relationships being displayed #17

Closed privaterra closed 3 years ago

privaterra commented 5 years ago

The contact summary works well, however I've noticed a bug related to - expired - relationships still appearing. I would like to propose a verification be made that the relationship is current/active before it gets displayed.

If there's an interest to display - expired - relationships, then there should be an option to enable that.

Thanks!

eileenmcnaughton commented 5 years ago

Hmm I guess that makes sense - there is also a scheduled job that disables expired relationships you might like to try out

privaterra commented 5 years ago

I ran the contract that expires the relationships. That works. However the extension doesn’t seem to distinguish between disabled expired and current

-- Robert Guerra

On January 18, 2019 at 6:54:51 PM, Eileen McNaughton ( notifications@github.com) wrote:

Hmm I guess that makes sense - there is also a scheduled job that disables expired relationships you might like to try out

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/eileenmcnaughton/org.wikimedia.relationshipblock/issues/17#issuecomment-455724553, or mute the thread https://github.com/notifications/unsubscribe-auth/ABN4r0cqjcZeqZZhJTpv-KQgC5HLysaKks5vEl7LgaJpZM4aIogB .

eileenmcnaughton commented 5 years ago

Hmm I would have thought this line would filter out inactive relationships

https://github.com/eileenmcnaughton/org.wikimedia.relationshipblock/blob/master/CRM/Relationshipblock/Utils/RelationshipBlock.php#L21

colemanw commented 5 years ago

I think the OP is saying that the extension does filter out inactive relationships but does not filter out relationships with a past end date. The api call you referenced @eileenmcnaughton looks that way. Note that if we did want to filter out past relationships it can't be done via api call because there is no api3 syntax for "IS NULL OR < now" (although that can be done with api4).

privaterra commented 5 years ago

You are correct - I want to filter out relationships with a past end date. I have api 4 installed.. is there a simple change I can implement ? I ask, as I’ve had to remove the fields in question from displaying until a fix is found

Thanks

Robert

-- Robert Guerra

On January 31, 2019 at 9:08:53 AM, colemanw (notifications@github.com) wrote:

I think the OP is saying that the extension does filter out inactive relationships but does not filter out relationships with a past end date. The api call you referenced @eileenmcnaughton https://github.com/eileenmcnaughton looks that way. Note that if we did want to filter out past relationships it can't be done via api call because there is no api3 syntax for "IS NULL OR < now" (although that can be done with api4).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/eileenmcnaughton/org.wikimedia.relationshipblock/issues/17#issuecomment-459357053, or mute the thread https://github.com/notifications/unsubscribe-auth/ABN4r_CDXoKHJrrTL-BEiIQ_nWF4irvdks5vIvj1gaJpZM4aIogB .

colemanw commented 5 years ago

@privaterra the cron job eileen mentioned should solve your immediate problem, as it will disable all relationships that have a past end date. Then they will disappear from this extension.

privaterra commented 5 years ago

@privaterra the cron job eileen mentioned should solve your immediate problem, as it will disable all relationships that have a past end date. Then they will disappear from this extension.

Let me try running the job again and see if that fixes the issue. If it doesn't, i'll include more details and a redacted screenshot of what i'm seeing..

colemanw commented 5 years ago

Ok, keep in mind that the job needs to run periodically, as part of your Scheduled Jobs configuration. I would set it to run at least once an hour to keep things up-to-date.

privaterra commented 5 years ago

I've run the job and looked at the log. It seems there's an "invalid relationship" that is causing the processing to fail. Any advice on how I can identify the relationship that's invalid and fix it for the processing to continue..

screen shot 2019-01-31 at 2 10 21 pm
eileenmcnaughton commented 5 years ago

I think the issue is that you have a relationship that is invalid for the contact types concerned - ie. a situation where an Organization is child of an Individual.

I would imagine if you run the query

SELECT id FROM civicrm_relationship WHERE is_active = 1 AND end_date < CURDATE()

it will be the first one in the list

privaterra commented 5 years ago

I think the issue is that you have a relationship that is invalid for the contact types concerned - ie. a situation where an Organization is child of an Individual.

I would imagine if you run the query

SELECT id FROM civicrm_relationship WHERE is_active = 1 AND end_date < CURDATE()

it will be the first one in the list

I deleted the results - which were the expired relationships. The expiry job started working again. Thanks!

vitius1 commented 5 years ago

The my solution of displaying expired relationships is: In php file civicrm/ext/org.wikimedia.relationshipblock-1.3/CRM/Relationshipblock/Utils/RelationshipBlock.php I just edit few line.

on line 24-26 add to return end_date: 'return' => ['id', 'relationship_type_id', 'contact_id_a', 'contact_id_b', 'contact_id_a.display_name', 'contact_id_b.display_name', 'contact_id_a.is_deceased', 'contact_id_b.is_deceased', 'end_date'],

add after line 30 condition (after foreach): if ( !isset($rel['end_date']) || ($rel['end_date'] < $now )) {

and end condition after line 50 (before end of foreach): }

relationshipblock.zip

colemanw commented 5 years ago

@vitius1 please submit those changes as a pull-request. You can do so by:

  1. Browse to the file on github
  2. Click the edit button (pencil)
  3. Make your changes
  4. Click save/commit and then fill out the pull-request form.
jensschuppe commented 4 years ago

Just crosslinking #29, which makes displaying expired and pending relationships configurable per relationship type.

jensschuppe commented 3 years ago

Wasn't this solved with #29, which got merged and released with 1.4 already?

eileenmcnaughton commented 3 years ago

Thanks @jensschuppe I'll close this then