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

Make inviting_user in invitationsView nullable #1124

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

zenovich
Copy link
Collaborator

@zenovich zenovich commented Jul 20, 2024

The situation where inviting_user (group_membership_changes.initiator_id) is null even for pending invitations having a corresponding (latest, with action='invitation_created') group membership change is possible and real. Actually, it's what we have in our dev database (and possibly the prod database too).

mysql> select at, group_id, member_id, type, action from group_pending_requests JOIN LATERAL (SELECT initiator_id, action FROM group_membership_changes WHERE group_membership_changes.group_id=group_pending_requests.group_id AND group_membership_changes.member_id=group_pending_requests.member_id ORDER BY at DESC LIMIT 1) AS latest_change ON latest_change.action='invitation_created' where type='invitation' AND action IS NOT NULL AND initiator_id IS NULL ORDER BY at;
+---------------------+---------------------+---------------------+------------+--------------------+
| at                  | group_id            | member_id           | type       | action             |
+---------------------+---------------------+---------------------+------------+--------------------+
| 2016-05-30 08:47:52 | 1061441261823291025 |  395414163411905857 | invitation | invitation_created |
| 2016-06-09 10:22:58 |  524710592747926617 |  758424489137954341 | invitation | invitation_created |
| 2016-09-12 16:45:07 |  265634762887890771 |   43494452251133038 | invitation | invitation_created |
| 2016-09-12 16:47:28 |  265634762887890771 |   64106307088691560 | invitation | invitation_created |
| 2017-06-02 23:23:28 |  351088315787638674 |  127087297316779357 | invitation | invitation_created |
| 2017-12-21 17:13:32 |  281477260571403056 |  694708648158149243 | invitation | invitation_created |
| 2018-09-21 21:41:51 |  162115639603334619 |  205404017817317958 | invitation | invitation_created |
| 2018-09-27 12:14:16 |  162115639603334619 |  590538280986825160 | invitation | invitation_created |
| 2018-10-10 14:36:33 |  940836791310406061 |  851979882668439468 | invitation | invitation_created |
| 2019-03-02 10:58:31 |  860323942498157720 | 1909944900306129841 | invitation | invitation_created |
| 2019-05-01 21:03:39 |  474667219360029565 | 1909944900306129841 | invitation | invitation_created |
| 2019-07-07 16:10:50 |   95223015275745886 |  261728824945523043 | invitation | invitation_created |
| 2019-07-10 15:10:15 |  125310545739285762 |  131067918929082935 | invitation | invitation_created |
| 2019-08-01 18:29:04 |  306882785614785617 |  796451867380488914 | invitation | invitation_created |
+---------------------+---------------------+---------------------+------------+--------------------+
14 rows in set (0.23 sec)

Because of 'ON DELETE SET NULL' in

  CONSTRAINT `fk_group_membership_changes_initiator_id_users_group_id` FOREIGN KEY (`initiator_id`) REFERENCES `users` (`group_id`) ON DELETE SET NULL,

new group_membership_changes rows having action='invitation_created' and initiator_id=NULL can be created from time to time.

Also, there are pending invitations that don't have corresponding (latest, with action='invitation_created') group membership changes (see #1123).

Here, in this PR, we address both situations. Also, when there is no corresponding group membership change, we use 'at' field from group_pending_requests instead of one from group_membership_changes.

Depends on #1122

…e it is null in get_group_invitations.feature
@zenovich zenovich added the Type: Bug Something isn't working label Jul 20, 2024
@zenovich zenovich requested a review from smadbe July 20, 2024 09:55
Base automatically changed from speed_up_getGroupInvitations to master July 23, 2024 15:18
@zenovich zenovich merged commit 6f518f0 into master Jul 25, 2024
4 checks passed
@zenovich zenovich deleted the getGroupInvitations_inviting_user_nullable branch July 25, 2024 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants