Skip to content

refactor (gql-server): Convert pres_annotation_history_curr.annotationInfo to type Jsonb instead of String - #21578

Merged
gustavotrott merged 1 commit into
bigbluebutton:v3.0.x-releasefrom
gustavotrott:anottations-his-json-type
Oct 31, 2024
Merged

gustavotrott merged 1 commit into
bigbluebutton:v3.0.x-releasefrom
gustavotrott:anottations-his-json-type

Conversation

@gustavotrott

Copy link
Copy Markdown
Contributor

This PR updates the annotationInfo field to jsonb, removing the need to check if it’s a JSON or a string. For removed annotations, the value will be null. This change, as confirmed by @KDSBrowne, will simplify client code.

Related: #21509
Supports: #21571

Example:

subscription {
  pres_annotation_history_curr {
    annotationId
    annotationInfo
    pageId
    presentationId
    updatedAt
    userId
  }
}
{
  "data": {
    "pres_annotation_history_curr": [
      {
        "annotationId": "shape:yqoGH5E81xtAgcUU1qX8s",
        "annotationInfo": {
          "x": 946.1111111111111,
          "y": 323.00347222222223,
          "id": "shape:yqoGH5E81xtAgcUU1qX8s",
          "meta": {
            "createdBy": "w_evuaiobx1vx8",
            "updatedBy": "w_evuaiobx1vx8"
          },
          "type": "draw",
          "index": "a1",
          "props": {
            "dash": "draw",
            "fill": "none",
            "size": "m",
            "color": "black",
            "isPen": false,
            "isClosed": false,
            "segments": [
              {
                "type": "free",
                "points": [
                  {
                    "x": 0,
                    "y": 0,
                    "z": 0.5
                  },
                  {
                    "x": 0,
                    "y": 0.56,
                    "z": 0.5
                  },
                  {
                    "x": -28.89,
                    "y": 268.89,
                    "z": 0.5
                  },
                  {
                    "x": -27.78,
                    "y": 267.78,
                    "z": 0.5
                  }
                ]
              }
            ],
            "isComplete": true
          },
          "opacity": 1,
          "isLocked": false,
          "parentId": "page:1",
          "rotation": 0,
          "typeName": "shape",
          "isModerator": true
        },
        "meetingId": "d1536302cffb5587becb2d018a891e6cf1108d9e-1730320326926",
        "pageId": "aa68eade1e0508159eb86fdf638dab1b5d90d5d4-1730320326928/1",
        "presentationId": "aa68eade1e0508159eb86fdf638dab1b5d90d5d4-1730320326928",
        "updatedAt": "2024-10-30T20:32:15.491+00:00",
        "userId": "w_evuaiobx1vx8",
        "userIsModerator": true
      },
      {
        "annotationId": "shape:oPzZyOgJnap9xbUMQ13Sz",
        "annotationInfo": {
          "x": 1102.7777777777778,
          "y": 317.4479166666667,
          "id": "shape:oPzZyOgJnap9xbUMQ13Sz",
          "meta": {
            "createdBy": "w_evuaiobx1vx8",
            "updatedBy": "w_evuaiobx1vx8"
          },
          "type": "draw",
          "index": "a2",
          "props": {
            "dash": "draw",
            "fill": "none",
            "size": "m",
            "color": "black",
            "isPen": false,
            "isClosed": false,
            "segments": [
              {
                "type": "free",
                "points": [
                  {
                    "x": 0,
                    "y": 0,
                    "z": 0.5
                  },
                  {
                    "x": -229.44,
                    "y": 321.67,
                    "z": 0.5
                  },
                  {
                    "x": -231.67,
                    "y": 321.67,
                    "z": 0.5
                  },
                  {
                    "x": -232.78,
                    "y": 321.67,
                    "z": 0.5
                  },
                  {
                    "x": -235,
                    "y": 319.44,
                    "z": 0.5
                  }
                ]
              }
            ],
            "isComplete": true
          },
          "opacity": 1,
          "isLocked": false,
          "parentId": "page:1",
          "rotation": 0,
          "typeName": "shape",
          "isModerator": true
        },
        "meetingId": "d1536302cffb5587becb2d018a891e6cf1108d9e-1730320326926",
        "pageId": "aa68eade1e0508159eb86fdf638dab1b5d90d5d4-1730320326928/1",
        "presentationId": "aa68eade1e0508159eb86fdf638dab1b5d90d5d4-1730320326928",
        "updatedAt": "2024-10-30T20:32:15.921+00:00",
        "userId": "w_evuaiobx1vx8",
        "userIsModerator": true
      },
      {
        "annotationId": "shape:2lb8rHrNIOUqclLMKhzDB",
        "annotationInfo": {
          "x": 1196.111111111111,
          "y": 410.78125,
          "id": "shape:2lb8rHrNIOUqclLMKhzDB",
          "meta": {
            "createdBy": "w_evuaiobx1vx8",
            "updatedBy": "w_evuaiobx1vx8"
          },
          "type": "draw",
          "index": "a3",
          "props": {
            "dash": "draw",
            "fill": "none",
            "size": "m",
            "color": "black",
            "isPen": false,
            "isClosed": false,
            "segments": [
              {
                "type": "free",
                "points": [
                  {
                    "x": 0,
                    "y": 0,
                    "z": 0.5
                  },
                  {
                    "x": -280.56,
                    "y": 267.78,
                    "z": 0.5
                  }
                ]
              }
            ],
            "isComplete": true
          },
          "opacity": 1,
          "isLocked": false,
          "parentId": "page:1",
          "rotation": 0,
          "typeName": "shape",
          "isModerator": true
        },
        "meetingId": "d1536302cffb5587becb2d018a891e6cf1108d9e-1730320326926",
        "pageId": "aa68eade1e0508159eb86fdf638dab1b5d90d5d4-1730320326928/1",
        "presentationId": "aa68eade1e0508159eb86fdf638dab1b5d90d5d4-1730320326928",
        "updatedAt": "2024-10-30T20:32:16.321+00:00",
        "userId": "w_evuaiobx1vx8",
        "userIsModerator": true
      },
      {
        "annotationId": "shape:yqoGH5E81xtAgcUU1qX8s",
        "annotationInfo": null,
        "meetingId": "d1536302cffb5587becb2d018a891e6cf1108d9e-1730320326926",
        "pageId": "aa68eade1e0508159eb86fdf638dab1b5d90d5d4-1730320326928/1",
        "presentationId": "aa68eade1e0508159eb86fdf638dab1b5d90d5d4-1730320326928",
        "updatedAt": "2024-10-30T20:32:30.335+00:00",
        "userId": "w_evuaiobx1vx8",
        "userIsModerator": true
      }
    ]
  }
}

@gustavotrott gustavotrott added this to the Release 3.0 milestone Oct 30, 2024
@coderabbitai

coderabbitai Bot commented Oct 30, 2024 •

Copy link
Copy Markdown
Contributor

Walkthrough

The pull request introduces significant modifications to the PresAnnotationHistoryDAO.scala and the SQL schema for the bbb-graphql-server project. In PresAnnotationHistoryDAO.scala, the annotationInfo field in both the PresAnnotationHistoryDbModel and PresAnnotationHistoryDbTableDef classes has been changed from a String type to an Option[JsValue], allowing for the representation of absent annotation information. The methods insertOrUpdateMap and deleteAnnotations have been updated to accommodate these changes, ensuring that annotationInfo is wrapped in a Some(...) when present and set to None for deleted annotations.

In the SQL schema, several new functions, tables, and views have been added to enhance the management of meetings and users. Key additions include the creation of a new meeting table and associated tables for breakout rooms and recording policies. The annotationInfo field in the pres_annotation_history table has been modified to use the jsonb data type, improving data flexibility. Multiple triggers have also been introduced to automate updates based on changes in related tables.

Possibly related PRs

Suggested reviewers

  • KDSBrowne
  • TiagoJacobs

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
bbb-graphql-server/bbb_schema.sql (1)

1381-1381: LGTM! The type change improves data integrity and query performance.

The change from TEXT to JSONB type for annotationInfo is a good improvement as it:

  • Ensures JSON validity at the database level
  • Enables native JSON operations and indexing
  • Provides better performance for JSON data storage and retrieval

Consider adding a GIN index if you need to query inside the JSON content:

CREATE INDEX idx_annotation_history_info ON pres_annotation_history USING gin (annotationInfo);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f7a931b and e53ae29.

📒 Files selected for processing (2)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresAnnotationHistoryDAO.scala (4 hunks)
  • bbb-graphql-server/bbb_schema.sql (1 hunks)
🔇 Additional comments (3)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/PresAnnotationHistoryDAO.scala (2)

5-5: LGTM: Required import for JSON handling

The addition of spray.json.JsValue import is appropriate for the type conversion.


51-51: LGTM: Proper handling of deleted annotations

Setting annotationInfo to None for deleted annotations is the correct approach and aligns with the PR objectives.

bbb-graphql-server/bbb_schema.sql (1)

1381-1381: Verify the data migration plan.

Ensure there's a migration plan to convert existing TEXT data to JSONB format. Invalid JSON data in existing rows could cause migration failures.

Run this script to check for invalid JSON in existing data:

@gustavotrott
gustavotrott merged commit 6934f50 into bigbluebutton:v3.0.x-release Oct 31, 2024
@gustavotrott
gustavotrott deleted the anottations-his-json-type branch October 31, 2024 00:54
@github-actions

Copy link
Copy Markdown

Automated tests Summary

✅ All the CI tests have passed!

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.

2 participants