OpenSlides / openslides-autoupdate-service

Autoupdate service for OpenSlides 4+
MIT License
2 stars 21 forks source link

The AU-service does not send information about speakers in a LOS when the LOS is currently projected #377

Closed GabrielInTheWorld closed 2 years ago

GabrielInTheWorld commented 2 years ago

As superadmin, I sent this request:

{
    "collection": "meeting",
    "ids": [
        6
    ],
    "fields": {
        "description": null,
        "name": null,
        "start_time": null,
        "end_time": null,
        "is_active_in_organization_id": null,
        "id": null,
        "reference_projector_id": {
            "type": "relation",
            "collection": "projector",
            "fields": {
                "name": null,
                "scale": null,
                "scroll": null,
                "width": null,
                "aspect_ratio_numerator": null,
                "aspect_ratio_denominator": null,
                "color": null,
                "background_color": null,
                "header_background_color": null,
                "header_font_color": null,
                "header_h1_color": null,
                "chyron_background_color": null,
                "chyron_font_color": null,
                "show_header_footer": null,
                "show_title": null,
                "show_logo": null,
                "show_clock": null,
                "used_as_reference_projector_meeting_id": null,
                "id": null,
                "current_projection_ids": {
                    "type": "relation-list",
                    "collection": "projection",
                    "fields": {
                        "stable": null,
                        "type": null,
                        "options": null,
                        "weight": null,
                        "content": null,
                        "current_projector_id": null,
                        "id": null,
                        "content_object_id": {
                            "type": "generic-relation",
                            "fields": {
                                "title": null,
                                "number": null,
                                "created": null,
                                "sequential_number": null,
                                "text": null,
                                "reason": null,
                                "recommendation_id": null,
                                "tag_ids": null,
                                "personal_note_ids": null,
                                "block_id": null,
                                "category_id": null,
                                "lead_motion_id": null,
                                "comment_ids": null,
                                "modified_final_version": null,
                                "state_extension": null,
                                "recommendation_extension": null,
                                "agenda_item_id": null,
                                "amendment_paragraph_$": {
                                    "type": "template"
                                },
                                "poll_ids": null,
                                "origin_id": null,
                                "id": null,
                                "is_directory": null,
                                "parent_id": null,
                                "child_ids": null,
                                "mimetype": null,
                                "filesize": null,
                                "create_timestamp": null,
                                "has_inherited_access_groups": null,
                                "pdf_information": null,
                                "closed": null,
                                "content_object_id": null,
                                "speaker_ids": null,
                                "internal": null,
                                "open_posts": null,
                                "phase": null,
                                "candidate_ids": null,
                                "description": null,
                                "default_poll_description": null,
                                "number_poll_candidates": null,
                                "item_number": null,
                                "comment": null,
                                "type": null,
                                "is_hidden": null,
                                "is_internal": null,
                                "duration": null,
                                "weight": null,
                                "level": null,
                                "meeting_id": null,
                                "first_name": null,
                                "last_name": null,
                                "username": null,
                                "vote_weight_$": {
                                    "type": "template"
                                },
                                "structure_level_$": {
                                    "type": "template"
                                },
                                "number_$": {
                                    "type": "template"
                                },
                                "email": null,
                                "gender": null,
                                "is_active": null,
                                "is_physical_person": null,
                                "is_present_in_meeting_ids": null,
                                "last_email_send": null,
                                "default_number": null,
                                "default_structure_level": null,
                                "default_vote_weight": null,
                                "comment_$": {
                                    "type": "template"
                                },
                                "about_me_$": {
                                    "type": "template"
                                },
                                "default_password": null,
                                "entitled_group_ids": null,
                                "state": null,
                                "pollmethod": null,
                                "voted_ids": null,
                                "votescast": null,
                                "votesinvalid": null,
                                "votesvalid": null,
                                "option_ids": null,
                                "onehundred_percent_base": null,
                                "global_option_id": null,
                                "global_yes": null,
                                "global_no": null,
                                "global_abstain": null,
                                "min_votes_amount": null,
                                "max_votes_amount": null,
                                "entitled_users_at_stop": null,
                                "message": null,
                                "default_time": null,
                                "countdown_time": null,
                                "running": null,
                                "list_of_speakers_id": {
                                    "type": "relation",
                                    "collection": "list_of_speakers",
                                    "fields": {
                                        "closed": null,
                                        "content_object_id": null,
                                        "speaker_ids": {
                                            "type": "relation-list",
                                            "collection": "speaker",
                                            "fields": {
                                                "begin_time": null,
                                                "end_time": null,
                                                "point_of_order": null,
                                                "speech_state": null,
                                                "weight": null,
                                                "note": null,
                                                "id": null,
                                                "user_id": {
                                                    "type": "relation",
                                                    "collection": "user",
                                                    "fields": {
                                                        "title": null,
                                                        "first_name": null,
                                                        "last_name": null,
                                                        "username": null,
                                                        "id": null
                                                    }
                                                }
                                            }
                                        },
                                        "id": null
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

In case a content-object is projected, I get the following result from the AU-service:

{
    "list_of_speakers/20/closed": false,
    "list_of_speakers/20/content_object_id": "motion/6",
    "list_of_speakers/20/id": 20,
    "list_of_speakers/20/speaker_ids": [
        18,
        20,
        28,
        29
    ],
    "meeting/6/description": "",
    "meeting/6/end_time": 1637794800,
    "meeting/6/id": 6,
    "meeting/6/is_active_in_organization_id": 1,
    "meeting/6/name": "Pokémonwelt (2)",
    "meeting/6/reference_projector_id": 7,
    "meeting/6/start_time": 1637794800,
    "motion/6/agenda_item_id": 17,
    "motion/6/created": 1637919583,
    "motion/6/id": 6,
    "motion/6/list_of_speakers_id": 20,
    "motion/6/meeting_id": 6,
    "motion/6/number": "1",
    "motion/6/option_ids": [
        14
    ],
    "motion/6/poll_ids": [
        6
    ],
    "motion/6/sequential_number": 1,
    "motion/6/text": "<p>Hagrid</p>",
    "motion/6/title": "Willkommen in Hogwarts",
    "projection/23/content": {
        "change_recommendations": null,
        "collection": "motion",
        "id": 6,
        "line_length": 85,
        "line_numbering": "outside",
        "number": "1",
        "preamble": "The assembly may decide:",
        "show_sidebox": false,
        "submitters": [
            "Dr. Administrator"
        ],
        "text": "<p>Hagrid</p>",
        "title": "Willkommen in Hogwarts"
    },
    "projection/23/content_object_id": "motion/6",
    "projection/23/current_projector_id": 7,
    "projection/23/id": 23,
    "projection/23/options": {
        "mode": "original"
    },
    "projection/23/stable": false,
    "projector/7/aspect_ratio_denominator": 9,
    "projector/7/aspect_ratio_numerator": 16,
    "projector/7/background_color": "#ffffff",
    "projector/7/chyron_background_color": "#317796",
    "projector/7/chyron_font_color": "#ffffff",
    "projector/7/color": "#000000",
    "projector/7/current_projection_ids": [
        23
    ],
    "projector/7/header_background_color": "#317796",
    "projector/7/header_font_color": "#f5f5f5",
    "projector/7/header_h1_color": "#317796",
    "projector/7/id": 7,
    "projector/7/name": "Default projector",
    "projector/7/scale": 0,
    "projector/7/scroll": 0,
    "projector/7/show_clock": true,
    "projector/7/show_header_footer": true,
    "projector/7/show_logo": true,
    "projector/7/show_title": true,
    "projector/7/used_as_reference_projector_meeting_id": 6,
    "projector/7/width": 1200,
    "speaker/18/id": 18,
    "speaker/18/speech_state": "pro",
    "speaker/18/user_id": 1,
    "speaker/18/weight": 2,
    "speaker/20/id": 20,
    "speaker/20/note": "awdfwdf",
    "speaker/20/point_of_order": true,
    "speaker/20/user_id": 1,
    "speaker/20/weight": 1,
    "speaker/28/id": 28,
    "speaker/28/user_id": 22,
    "speaker/28/weight": 3,
    "speaker/29/id": 29,
    "speaker/29/user_id": 23,
    "speaker/29/weight": 4,
    "user/1/first_name": "",
    "user/1/id": 1,
    "user/1/last_name": "Administrator",
    "user/1/title": "Dr.",
    "user/1/username": "admin",
    "user/22/first_name": "Professor",
    "user/22/id": 22,
    "user/22/last_name": "Snape",
    "user/22/username": "Professor Snape 4",
    "user/23/first_name": "Professor",
    "user/23/id": 23,
    "user/23/last_name": "Dumbledore",
    "user/23/username": "Professor Dumbledore"
}

In case the LOS of the same content-object is projected, I get the following result from the AU-service:

{
    "list_of_speakers/20/closed": false,
    "list_of_speakers/20/content_object_id": "motion/6",
    "list_of_speakers/20/id": 20,
    "list_of_speakers/20/meeting_id": 6,
    "list_of_speakers/20/speaker_ids": [
        18,
        20,
        28,
        29
    ],
    "meeting/6/description": "",
    "meeting/6/end_time": 1637794800,
    "meeting/6/id": 6,
    "meeting/6/is_active_in_organization_id": 1,
    "meeting/6/name": "Pokémonwelt (2)",
    "meeting/6/reference_projector_id": 7,
    "meeting/6/start_time": 1637794800,
    "projection/24/content": {
        "closed": false,
        "collection": "list_of_speakers",
        "current": null,
        "finished": null,
        "number_of_waiting_speakers": 4,
        "title_information": {
            "collection": "motion",
            "content_object_id": "motion/6",
            "title": "Willkommen in Hogwarts",
            "number": "1",
            "agenda_item_number": ""
        },
        "waiting": [
            {
                "user": "Dr. Administrator",
                "speech_state": "",
                "note": "awdfwdf",
                "point_of_order": true
            },
            {
                "user": "Dr. Administrator",
                "speech_state": "pro",
                "note": "",
                "point_of_order": false
            },
            {
                "user": "Professor Snape",
                "speech_state": "",
                "note": "",
                "point_of_order": false
            },
            {
                "user": "Professor Dumbledore",
                "speech_state": "",
                "note": "",
                "point_of_order": false
            }
        ]
    },
    "projection/24/content_object_id": "list_of_speakers/20",
    "projection/24/current_projector_id": 7,
    "projection/24/id": 24,
    "projection/24/options": {},
    "projection/24/stable": false,
    "projector/7/aspect_ratio_denominator": 9,
    "projector/7/aspect_ratio_numerator": 16,
    "projector/7/background_color": "#ffffff",
    "projector/7/chyron_background_color": "#317796",
    "projector/7/chyron_font_color": "#ffffff",
    "projector/7/color": "#000000",
    "projector/7/current_projection_ids": [
        24
    ],
    "projector/7/header_background_color": "#317796",
    "projector/7/header_font_color": "#f5f5f5",
    "projector/7/header_h1_color": "#317796",
    "projector/7/id": 7,
    "projector/7/name": "Default projector",
    "projector/7/scale": 0,
    "projector/7/scroll": 0,
    "projector/7/show_clock": true,
    "projector/7/show_header_footer": true,
    "projector/7/show_logo": true,
    "projector/7/show_title": true,
    "projector/7/used_as_reference_projector_meeting_id": 6,
    "projector/7/width": 1200
}

As you can see, there is something missing. Why is this happening?

ostcar commented 2 years ago

This is not a bug of the autoupdate service, but the result of your (buggy?) request.

You request the field:

meeting/1/reference_projector_id/current_projection_ids/content_object_id/list_of_speakers_id/speaker_ids

But you don't request the field:

meeting/1/reference_projector_id/current_projection_ids/content_object_id/speaker_ids

If projection/content_object_id is an object that has the field list_of_speakers_id, then list_of_speakers_id/speaker_ids can be found by the autoupdate-service. But if the projection/content_object_id does not have the field list_of_speakers_id, then the autoupdate-service can not find the field list_of_speakers_id/speaker_ids.

To fix this, one solution would be, to change the request and add all the fields below list_of_speakers_id to projection/content_object_id. I understand that this is ugly and not DRY. Another (also ugly) solution would be to add a field list_of_speakers/list_of_speakers_idthat always has the same content as list_of_speakers/id.

GraphQL solves this problem with interfaces: https://www.apollographql.com/docs/apollo-server/schema/unions-interfaces/#interface-type

We could add interface-collections to the models.yml and replace all generic-relations with interface-relations. This could make the requests more readable. But it would not solve your current problem. If we would create a los-collection-interface that requires a field list_of_speakers_id, then all of these collections could be used. But the list_of_speaker-collection does not have the field list_of_speaker_id.

ostcar commented 2 years ago

@GabrielInTheWorld can I close this?

ostcar commented 2 years ago

If this is still a problem, then please reopen with an answer.