Question

Photo of Michael Garrison

0

Trouble with Known Relationships and Lava

I know I've still only scratched the surface of Rock's database table structure, but this one's got me stumped ... and to a certain extent I'm pretty sure there's a bug. I'm just not sure where the bug is so I wanted to get some thoughts from the community.

- I've got a profile badge that uses Lava to check for the existence of a certain known relationship.
- When deleting or modifying an existing known relationship of this type, the badge does not disappear.
- After deleting this known relationship, if I create another, TWO badges appear. Although only one "known relationship" is shown on the profile.
- I can use lava to discover the Known Relationship groups- using the group viewer on the given IDs I can see that both the deleted and the current "known relationship" groups still exist, are active, and have both people as members.
- Querying the [Group] and [GroupMember] tables on the given Groups, I can see no difference between the deleted and the current "known relationship".

I confess I'm mystified as to why deleting a known relationship does not simply delete the group. But since there's obviously a method that Rock uses to tell whether a given Known Relationship is active or not, I suppose that I'm simply curious as to why and how that's accomplished.

The bigger deal, I think, is that Lava seems to be equally at a loss as I am to tell a current Known Relationship from a deleted one. Is that a bug in the Known Relationship mechanism? A bug in Lava? Or am I using the Person | Groups filter wrong? I'm looping through all Known Relationships like so, looking for a specific phrase in the Role:

{% assign groupMembers = Person | Groups: "11" %}
{% for groupMember in groupMembers %}
  {% if groupMember.GroupRole.Name contains 'Surviving' %}
     <div class="badge">
     <img src="//ccof.net/images/site/angel.png" style="vertical-align:bottom;height:45px;" alt="Deceased Family Member" title="{{ Person.NickName }} has lost a family member- please see the &quot;Known Relationships&quot; box at the bottom of their profile for details." />
     </div>
  {% endif %}
{% endfor %}

(Note I'm looking for just "Surviving" so that it matches EITHER my custom "Surviving Spouse" and "Surviving Parent" known relationship roles that we created).

Obviously a fix for the double badge appearance is to simply exit the loop once one is found. But that wouldn't fix the fact that if I delete all such relationships, the badge persists.

  • Photo of Michael Garrison

    0

    OK, I think that I've been helped to the bottom of this. It's unfortunately a critical detail that I left out of my OP that one of the partners in the known relationship is marked as deceased in Rock.

    First: the mechanics of Known Relationships:
    Each person is the "Owner" (role) of one Known Relationship-type group. Their partner is added as a member of that group with the defined role. Likewise on inverse relationships, they are added to the known relationship group owned by their partner with the inverse role. So my lava works, only because it finds the appropriate role for the person presently displayed, in their partner's known relationship group. But there may be several known relationships of this kind, so I had to add a variable to store whether the role in question was already found- if so it skips the part of the loop where it displays another badge. Then I added a bit of lava where it displays the badge, to update that variable when the badge is displayed. (I couldn't find an endloop lava tag to terminate the loop early so I had to build in a nested IF statement).

    Now for the bug:

    Rock doesn't update inverse relationships where the "other" partner is deceased (or perhaps simply inactive, not sure which). My understanding is that's a bug that will be fixed. That explains why when I delete the relationship from the surviving spouse, the badge remains: they remain a member of their (deceased) spouse's known relationship group which was set either before they were marked as deceased, or from their own profile.

    There's possibly another bug where Rock created additional Known Relationship groups on deceased people, but I can't be sure enough of how that group was created to say that's definitely a bug- that's being looked into. Either way, it's almost certainly a side-effect of the actual bug.

    Perhaps this will help someone else =)

  • Photo of David Leigh

    0

    Michael,

    Perhaps the Known Relationship is simply inactivated instead of being deleted.
    Are you able to add a check to determine if GroupMember.GroupMemberStatus is Active instead of Inactive?

     

    • Michael Garrison

      By looking up the group by ID in the group viewer, I can see that both people's "Member Status" is "Active" for both the deleted and the current known relationship group.


      I should have mentioned originally (and actually thought I did) that I looked up the groups in question in a SQL query- other than the GroupId column, all data was identical between the given groups between the current and deleted known relationship group, checking both the [Group] and the [GroupMember] tables.