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

Connected groups as replacement for acts_as_dag #30

Open
wants to merge 43 commits into
base: master
Choose a base branch
from

Conversation

fiedl
Copy link
Owner

@fiedl fiedl commented Oct 20, 2017

Example:

    group1
      |---- group2 --- group3
      |---- event1
              |------ attendees_group

  In the example, groups 1, 2, and 3 are connected groups. But the
attendees_group
  is not connected to them, because a non-group object, event1, is in
between.
…h is independent of the indirect DagLink objects.
This allows to find indirect memberships of groups.
This is because we do not want to consider officers of a group
necessarily as members of the group.

Trello:
https://trello.com/c/wLS0CY6w/807-memberships-man-ist-ein-gruppen-mitgli
ed-wenn-man-officer-attendee-oder-contactperson-ist
…pMemberships. Also, recalculate indirect memberships on creation of the direct ones.

This makes all specs pass again.
This also required:

1. When finding memberships using a MembershipCollection, initialize
the membership with the validity range. This saves time, since each
membership does not need to fetch the validity range separately.

2. Fixing MembershipCollection#find_all_memberships_by_user_and_group
to support also multiple memberships, for example when a user is a
member in a group, leaves and rejoins later.
One has to use `Membership.where(…).uniq` rather than
`Membership.where(…).to_a.uniq`, since the Array will compare the
objects by their object id rather than their properties.
This method allows to create new memberships.

    membership = Membership.create(user: u, group: g)
    membership = Membership.create(user: u, group: g, valid_from:
1.month_ago, valid_to: 1.day.ago)
…alization.

We need this when modifying the validity range through forms.
This only works for direct memberships and directly refers to the id of
the corresponding DagLink.
There has been an issue where the wrong group has been associated with
the membership.
…d behaviour

Now, a `Membership` is built rather than a `UserGroupMembership :<
DagLink`.
I thought, I would use this for group_members#index. But it turns out,
this dos not result in the expected behaviour.

In a super group, rather than seeing the date of joining the current
direct group, I want to see when the user joined one of the direct
groups the first time.
…ges_of_indirect_memberships.

This joins indirect memberships when they are of the same user and the
same group but different validity ranges:

    |-----------|                   first indirect membership in @Group1
                |---------          second indirect membership in
@Group2
    |---------------------          joined indirect membership

This is needed, since in `group_members#index` of indirect groups, the
users should be listed only once. They should be listed with the
earliest valid_from of the direct memberships. It’s not enough to use
`MembershipCollection#first_per_group`, because this would only
consider current direct memberships.
…he new mechanism.

This includes interface changes, since `User#groups` is now an `Array`,
not an Association. This only affects write access.
…ism.

`Group#members` now returns a `MemberCollection`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant