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

feat(server): add photooverlay property [VIZ-1340] #1462

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hexaforce
Copy link
Contributor

@hexaforce hexaforce commented Mar 3, 2025

Overview

I have added PhotoOverlay to the properties of infobox-beta.

What I've done

Similar to position, padding, and gap, it can be added as a member of a single property.
※ It is not a property of ItemGroup.

  • SchemaGroupID: default
  • FieldID: photooverlay
  • ItemID: (not use)

1.manifest.yml

  - id: infobox-beta
    name: Infobox Beta
    type: infobox
    description: Create an information area that appears when a layer is highlighted. Text, pictures, video, etc can be added to an infobox.
    schema:
      groups:
        - id: default
          title: Basic
          fields:
            - id: enabled
              type: bool
              title: Enable Infobox
              ~~~~~~~~~~~~~~
            - id: position
              type: string
              title: Position
              ~~~~~~~~~~~~~~
            - id: padding
              type: spacing
              title: Padding
              ~~~~~~~~~~~~~~
            - id: gap
              type: number
              title: gap
              ~~~~~~~~~~~~~~
+            - id: photooverlay
+              type: photooverlay
+              title: PhotoOverlay

2. graphql

note PHOTOOVERLAY, like TIMELINE, is defined as a non-primitive type.

+type PhotoOverlay {
+  enabled: Boolean
+  cameraDuration: Int
+}

enum ValueType {
  BOOL
  NUMBER
  STRING
  REF
  URL
  LATLNG
  LATLNGHEIGHT
  CAMERA
  TYPOGRAPHY
  COORDINATES
  POLYGON
  RECT
  SPACING
  ARRAY
  TIMELINE
+  PHOTOOVERLAY
}
  • I will revert the debugging library for the server.
  • I have added property tests for the story page.

What I haven't done

How I tested

Which point I want you to review particularly

I updated reearthx, but a nil exception occurred because the Role repository could not be referenced.

Since this prevents adding members to the team, I am now referencing a custom branch of reearthx (chore/panic-to-error).

https://github.com/reearth/reearthx/tree/chore/panic-to-error

Memo

Summary by CodeRabbit

  • New Features

    • Introduced Photo Overlay functionality, allowing users to configure overlay settings such as activation and camera duration. A new extension option expands creative possibilities.
    • Enhanced property update handling across scene and storytelling workflows for a more consistent experience.
    • Added new test functions to validate property updates and infobox creation, ensuring robust functionality.
  • Bug Fixes

    • Resolved an issue with scene data retrieval to improve stability and reliability.
    • Corrected a typographical error in constant naming for improved query accuracy.

@hexaforce hexaforce self-assigned this Mar 3, 2025
@github-actions github-actions bot added the server label Mar 3, 2025
Copy link

coderabbitai bot commented Mar 3, 2025

Walkthrough

The pull request introduces a new logging function and updates several E2E test functions to return additional property identifiers. A typographical error in a GraphQL constant has been corrected. The GraphQL schema and related adapter code have been enhanced to support a new "PhotoOverlay" type, including resolver functions, model definitions, and enum updates. Additional tests and extensions have been added to validate these changes, and a dependency version has been updated in the project’s go.mod file.

Changes

File(s) Modified Change Summary
server/e2e/common.go
server/e2e/gql_nlslayer_test.go
server/e2e/gql_project_export_import_test.go
server/e2e/gql_property_test.go
server/e2e/gql_storytelling_test.go
server/e2e/seeder.go
Added a new logging function (RequestDump), updated functions to return an additional property ID, fixed a typo in a constant, and introduced new test functions for infobox and property updates, as well as revised layer ID handling.
server/go.mod Updated the reearthx dependency version.
server/gql/_shared.graphql
server/gql/property.graphql
Reformatted input type and added the new PhotoOverlay type and a PHOTOOVERLAY enum value to the GraphQL schema.
server/internal/adapter/gql/generated.go
server/internal/adapter/gql/gqlmodel/convert_property.go
server/internal/adapter/gql/gqlmodel/models_gen.go
Extended GraphQL resolvers and models with a new PhotoOverlay struct, added new resolver functions, and updated enum definitions accordingly.
server/pkg/builtin/manifest.yml
server/pkg/property/value.go
server/pkg/property/value_photooverlay.go
Introduced a new extension entry and property type handling for "photooverlay" by adding a new file and updating existing maps to include ValueTypePhotoOverlay.
server/schemas/plugin_manifest.json Expanded the enum of valuetype to include the new value "photooverlay".

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant G as GraphQL Endpoint
    participant R as Resolver
    C->>G: Sends query with PhotoOverlay fields
    G->>R: Resolves PhotoOverlay (enabled, cameraDuration)
    R-->>G: Returns PhotoOverlay data
    G-->>C: Responds with PhotoOverlay information
Loading

Suggested labels

web

Suggested reviewers

  • pyshx
  • soneda-yuya
  • mkumbobeaty

Poem

In meadows of code I hop with glee,
Debug logs dancing like leaves on a tree.
PhotoOverlay fields now join the play,
Testing and queries brightening the day.
With each change, I celebrate and cheer,
A rabbit’s rhythm in code so clear.
HOP to the beat of progress, my dear!

✨ Finishing Touches
  • 📝 Generate Docstrings

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 generate docstrings to generate docstrings for this 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.

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.

Copy link

netlify bot commented Mar 3, 2025

Deploy Preview for reearth-web ready!

Name Link
🔨 Latest commit 5143f1c
🔍 Latest deploy log https://app.netlify.com/sites/reearth-web/deploys/67c6a46efdab580008cfef3d
😎 Deploy Preview https://deploy-preview-1462--reearth-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (6)
server/e2e/common.go (1)

192-192: Consider enabling the debugging utility when needed.

This commented-out line could be helpful during development, but should remain commented in production code. If you're having issues with specific GraphQL requests, you can uncomment this line temporarily for debugging.

server/e2e/gql_nlslayer_test.go (1)

741-741: Consider utilizing returned values.

The function call ignores all returned values. Since the propertyId is now being returned and might be useful for assertions or further operations, consider storing it in a variable for potential use.

- _, _, _, _ = createInfobox(e, layerId)
+ _, _, _, propertyId := createInfobox(e, layerId)
server/e2e/gql_storytelling_test.go (2)

166-168: Consider utilizing the returned property IDs.

The function calls ignore the returned property ID (the fourth return value). Since these property IDs might be useful for assertions or further operations, consider storing them in variables for potential use.

- _, _, blockIDa, _ := createBlock(e, sceneID, storyID1, pageID1, "reearth", "textStoryBlock", lo.ToPtr(1))
- _, _, blockIDb, _ := createBlock(e, sceneID, storyID1, pageID1, "reearth", "textStoryBlock", lo.ToPtr(2))
+ _, _, blockIDa, propIDa := createBlock(e, sceneID, storyID1, pageID1, "reearth", "textStoryBlock", lo.ToPtr(1))
+ _, _, blockIDb, propIDb := createBlock(e, sceneID, storyID1, pageID1, "reearth", "textStoryBlock", lo.ToPtr(2))

187-187: Consider utilizing the returned property ID.

Similar to the above comment, consider storing the returned property ID for potential use in assertions or further operations.

- _, _, blockID3, _ := createBlock(e, sceneID, storyID1, pageID1, "reearth", "textStoryBlock", lo.ToPtr(3))
+ _, _, blockID3, propID3 := createBlock(e, sceneID, storyID1, pageID1, "reearth", "textStoryBlock", lo.ToPtr(3))
server/e2e/gql_property_test.go (2)

161-167: Add missing test coverage.
We see a TODO comment to “Write detailed tests,” but there is no actual logic here. This might leave parts of the scene property untested.

Shall I help provide a more comprehensive test to improve coverage for TestUpdateScenePropertyValue?


197-198: Remove unnecessary commented code.
The commented-out "height" and "aspectRatio" fields remain in the camera object. If they are not needed, it’s best to remove them for clarity.

-     // "height":      313.66307524391044,
-     // "aspectRatio": 0.42407108239095315,
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1fadbe7 and 93d7e1e.

⛔ Files ignored due to path filters (1)
  • server/go.sum is excluded by !**/*.sum
📒 Files selected for processing (16)
  • server/e2e/common.go (2 hunks)
  • server/e2e/gql_nlslayer_test.go (5 hunks)
  • server/e2e/gql_project_export_import_test.go (2 hunks)
  • server/e2e/gql_property_test.go (2 hunks)
  • server/e2e/gql_storytelling_test.go (4 hunks)
  • server/e2e/seeder.go (2 hunks)
  • server/go.mod (1 hunks)
  • server/gql/_shared.graphql (2 hunks)
  • server/gql/property.graphql (1 hunks)
  • server/internal/adapter/gql/generated.go (7 hunks)
  • server/internal/adapter/gql/gqlmodel/convert_property.go (2 hunks)
  • server/internal/adapter/gql/gqlmodel/models_gen.go (3 hunks)
  • server/pkg/builtin/manifest.yml (1 hunks)
  • server/pkg/property/value.go (1 hunks)
  • server/pkg/property/value_photooverlay.go (1 hunks)
  • server/schemas/plugin_manifest.json (2 hunks)
✅ Files skipped from review due to trivial changes (2)
  • server/e2e/gql_project_export_import_test.go
  • server/go.mod
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: deploy-server / deploy_test
  • GitHub Check: Redirect rules - reearth-web
  • GitHub Check: Header rules - reearth-web
  • GitHub Check: Pages changed - reearth-web
🔇 Additional comments (31)
server/e2e/seeder.go (2)

49-49: Global variable addition aligns with consistent NLS layer ID tracking.

This new global variable provides a consistent ID for NLS layers across the e2e tests, which helps with predictable test behavior.


408-408: Method signature update to use consistent ID for layer creation.

Changed from using a newly generated ID to using the predefined nlsLayerId global variable. This provides consistency in tests where layer identity is important.

server/pkg/builtin/manifest.yml (1)

2712-2714: PhotoOverlay property added to infobox-beta schema.

This addition aligns with the PR objectives to introduce a new PhotoOverlay property to the infobox-beta component. The structure follows the established pattern used by other properties in the manifest.

server/gql/property.graphql (1)

195-195: New PHOTOOVERLAY enum value added to ValueType.

This addition properly extends the GraphQL schema to support the new PhotoOverlay type, maintaining alphabetical ordering in the enum list which follows good practices.

server/e2e/common.go (1)

279-283: Good debugging utility function added.

This function provides a clean way to inspect GraphQL requests, which can be valuable during development and troubleshooting. The indent formatting makes the output more readable.

server/internal/adapter/gql/gqlmodel/convert_property.go (2)

53-57: Implementation looks correct for the PhotoOverlay conversion.

The conversion from property.PhotoOverlay to GraphQL model is correctly implemented, handling both the Enabled and CameraDuration fields.


122-126: Implementation looks correct for the reverse PhotoOverlay conversion.

The conversion from GraphQL model back to property.PhotoOverlay is properly implemented, maintaining symmetry with the corresponding ToPropertyValue implementation.

server/schemas/plugin_manifest.json (1)

37-38: Added "photooverlay" to valuetype enum correctly.

The photooverlay type has been correctly added to the valuetype enum in the JSON schema, allowing it to be used in plugin manifests.

server/gql/_shared.graphql (1)

103-106: PhotoOverlay type definition looks good.

The GraphQL type definition for PhotoOverlay properly defines the two fields needed:

  1. enabled: Boolean - to control if the overlay is active
  2. cameraDuration: Int - to specify the duration for camera transitions

This aligns with the PR objective to add a PhotoOverlay property to the infobox-beta component.

server/pkg/property/value.go (1)

37-37:

✅ Verification successful

Properly registered PhotoOverlay type handler.

The PhotoOverlay type has been correctly registered in the types map to enable property value conversion and validation for this new type.

Let's verify the implementation of the PhotoOverlay type handler:


🏁 Script executed:

#!/bin/bash
# Check for the PhotoOverlay implementation file
find server/pkg/property -name "*photooverlay*" -type f
# If found, display the content to verify implementation
find server/pkg/property -name "*photooverlay*" -type f -exec cat {} \;

Length of output: 1783


Properly Registered PhotoOverlay Type Handler

The PhotoOverlay type is correctly registered and implemented. The registration in server/pkg/property/value.go matches the implementation in server/pkg/property/value_photooverlay.go, where all conversion, validation, and JSON schema methods (I2V, V2I, Validate, String, and JSONSchema) are properly defined. No additional changes are required.

server/internal/adapter/gql/gqlmodel/models_gen.go (4)

761-764: New struct implementation looks good.

The implementation of the PhotoOverlay struct with appropriate field types (pointers to bool and int) follows the project's pattern for similar types. The use of pointers allows for nil values when these properties aren't set.


2266-2266: Enum value added correctly.

The ValueTypePhotooverlay enum value follows the naming convention of existing enum values in the ValueType type.


2285-2285: AllValueType array updated appropriately.

The new ValueTypePhotooverlay has been correctly added to the AllValueType array to ensure it's included in validation checks.


2290-2291: IsValid method properly updated.

The IsValid method has been correctly updated to include the new ValueTypePhotooverlay in its validation check.

server/e2e/gql_nlslayer_test.go (3)

502-534: Function signature update aligns with API changes.

The createInfobox function now properly returns the propertyId from the GraphQL response, which is necessary for testing the PhotoOverlay property. This change is consistent with the PR objectives of adding PhotoOverlay as a property.


781-837: Great test implementation for the new PhotoOverlay property.

The TestInfoboxProperty function provides comprehensive coverage for testing the new PhotoOverlay property alongside other existing properties. The test correctly verifies that the PhotoOverlay properties (enabled and cameraDuration) can be set and are correctly returned in the response.


828-836: Well-structured PhotoOverlay test case.

The test correctly sets both the enabled flag and cameraDuration properties, matching the PhotoOverlay struct definition. The assertions verify that the values are properly persisted.

server/e2e/gql_storytelling_test.go (2)

824-864: Improved query formatting increases readability.

The GraphQL query has been reformatted with proper indentation and line breaks, making it more readable while maintaining functionality. The query now also includes the property.id field, which is used to extract the property ID in the return value.


883-886: Function return value enhanced to include property ID.

The function now correctly extracts and returns the block's property ID from the GraphQL response, which is aligned with similar changes in other parts of the codebase. This enables testing property-related functionality for story blocks.

server/internal/adapter/gql/generated.go (9)

566-569: New PhotoOverlay complexity struct looks good.

This correctly adds the complexity calculation functions for the new PhotoOverlay type, defining both CameraDuration and Enabled fields that will be used to determine query complexity.


4022-4035: Complexity handling for PhotoOverlay fields is implemented correctly.

The implementation follows the established pattern in the codebase for handling field complexity. The conditional checks ensure that no errors occur if complexity functions aren't defined.


6942-6945: PhotoOverlay type definition is properly structured.

The GraphQL type definition includes the necessary fields as mentioned in the PR objectives:

  • enabled: Boolean field to toggle the overlay
  • cameraDuration: Int field to specify the duration

This matches the requirements from the PR description.


7945-7945: ValueType enum correctly updated with PHOTOOVERLAY.

This addition to the ValueType enum properly identifies PhotoOverlay as a valid value type in the GraphQL schema, which is consistent with the PR objectives.


29034-29060: Resolver for PhotoOverlay.enabled looks good.

The implementation follows the standard resolver pattern in the codebase, including proper error handling, context management, and null value handling.


29075-29101: Resolver for PhotoOverlay.cameraDuration is properly implemented.

The implementation correctly extracts and returns the cameraDuration field from PhotoOverlay objects, with appropriate error handling and type marshaling.


57669-57705: PhotoOverlay GraphQL type integration is complete.

The implementation properly:

  1. Defines PhotoOverlay implementors
  2. Creates the handler function for PhotoOverlay objects
  3. Handles field selection and dispatching
  4. Integrates with the deferred resolution system

This follows the established pattern for type handlers in the codebase.


29062-29073: Field context functions are properly implemented.

Both field context functions for the PhotoOverlay type follow the standard pattern in the codebase, correctly setting up the field context with appropriate metadata and child field handlers.

Also applies to: 29102-29114


6881-6884:

✅ Verification successful

Note about Pagination input type.

This input type definition appears to be part of the generated code but doesn't seem directly related to the PhotoOverlay feature. Ensure this change is intentional and needed for the PR.


🏁 Script executed:

#!/bin/bash
# Check if Pagination input was newly added or was already present in the schema
grep -r "input Pagination" --include="*.graphql" .

Length of output: 100


Pagination input type inclusion is expected

The Pagination input type in the generated file comes from the shared schema (server/gql/_shared.graphql) as confirmed by the grep output. Its appearance isn’t a new addition related to the PhotoOverlay feature but rather an expected part of the generated code. No action is required unless the PhotoOverlay feature specifically needs a modification of this type.

server/e2e/gql_property_test.go (3)

121-156: Potential panic risk for array indexing.
In addPropertyItem(), lines 152–153 rely on items[0] and groups[0] without any defensive check. If the GraphQL response array is empty, this could cause an out-of-range error.

Would you like to add guards to verify the existence of items and groups before attempting to index them?


210-213: Consider validating cameraDuration values.
Adding a large or negative cameraDuration could result in undesired behavior. Consider constraints or validation to ensure realistic values.


214-217: Verify date/time format compatibility.
You are passing a date string "2025-03-06T11:05:44+09:00" for the timePoint. Confirm that the backend correctly parses and handles this format.

Comment on lines +14 to +22
func (c *PhotoOverlay) Clone() *PhotoOverlay {
if c == nil {
return nil
}
return &PhotoOverlay{
Enabled: c.Enabled,
CameraDuration: c.CameraDuration,
}
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use true deep copy for pointer fields.
In (*PhotoOverlay).Clone(), assigning the same pointers to Enabled and CameraDuration does not create a true deep copy. Mutating the copy could unexpectedly affect the original.

Consider this approach:

func (c *PhotoOverlay) Clone() *PhotoOverlay {
    if c == nil {
        return nil
    }
    enabledCopy := lo.ClonePtr(c.Enabled)           // or manually copy
    cameraDurationCopy := lo.ClonePtr(c.CameraDuration)
    return &PhotoOverlay{
-       Enabled:        c.Enabled,
-       CameraDuration: c.CameraDuration,
+       Enabled:        enabledCopy,
+       CameraDuration: cameraDurationCopy,
    }
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func (c *PhotoOverlay) Clone() *PhotoOverlay {
if c == nil {
return nil
}
return &PhotoOverlay{
Enabled: c.Enabled,
CameraDuration: c.CameraDuration,
}
}
func (c *PhotoOverlay) Clone() *PhotoOverlay {
if c == nil {
return nil
}
enabledCopy := lo.ClonePtr(c.Enabled) // or manually copy
cameraDurationCopy := lo.ClonePtr(c.CameraDuration)
return &PhotoOverlay{
Enabled: enabledCopy,
CameraDuration: cameraDurationCopy,
}
}

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93d7e1e and 83e4f5a.

⛔ Files ignored due to path filters (1)
  • server/go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • server/e2e/gql_workspace_test.go (1 hunks)
  • server/go.mod (1 hunks)
  • server/pkg/property/value_photooverlay.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • server/go.mod
  • server/pkg/property/value_photooverlay.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: ci-server / ci-server-test

@hexaforce hexaforce changed the title feat(server): add photooverlay property feat(server): add photooverlay property [VIZ-1340] Mar 3, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
server/internal/adapter/gql/gqlmodel/models_gen.go (2)

2268-2268: Ensure consistent naming convention with other value types.

While the implementation is correct, I notice that the constant name uses lowercase 'o' in "Photooverlay" while the struct type uses uppercase 'O' in "PhotoOverlay". This is a minor inconsistency, but it's worth checking if this aligns with the project's naming conventions for other similar value types.

-ValueTypePhotooverlay ValueType = "PHOTOOVERLAY"
+ValueTypePhotoOverlay ValueType = "PHOTOOVERLAY"

761-764: Consider adding documentation for the PhotoOverlay type and its fields.

To improve maintainability, it would be beneficial to add documentation comments explaining the purpose of the PhotoOverlay type and the meaning of its fields. In particular, documentation about the expected range of values for CameraDuration would be helpful for future developers.

+// PhotoOverlay represents configuration for photo overlay functionality in the infobox-beta component.
 type PhotoOverlay struct {
+   // Enabled determines whether the photo overlay feature is active
    Enabled        *bool `json:"enabled,omitempty"`
+   // CameraDuration specifies the duration (in milliseconds) for camera transitions
    CameraDuration *int  `json:"cameraDuration,omitempty"`
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cdfb2b0 and 5143f1c.

📒 Files selected for processing (7)
  • server/go.mod (1 hunks)
  • server/gql/property.graphql (1 hunks)
  • server/internal/adapter/gql/generated.go (7 hunks)
  • server/internal/adapter/gql/gqlmodel/convert_property.go (2 hunks)
  • server/internal/adapter/gql/gqlmodel/models_gen.go (3 hunks)
  • server/pkg/builtin/manifest.yml (1 hunks)
  • server/schemas/plugin_manifest.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • server/gql/property.graphql
  • server/schemas/plugin_manifest.json
  • server/pkg/builtin/manifest.yml
  • server/go.mod
  • server/internal/adapter/gql/gqlmodel/convert_property.go
🔇 Additional comments (12)
server/internal/adapter/gql/gqlmodel/models_gen.go (4)

761-764: LGTM! The PhotoOverlay type definition is well-structured.

The new PhotoOverlay type is correctly defined with appropriate JSON tags and follows the project's conventions for optional fields by using pointer types for both Enabled and CameraDuration fields.


2287-2287: LGTM! The ValueType enum is properly updated.

The new PhotoOverlay type is correctly added to the AllValueType slice, ensuring it's recognized by the system.


2292-2293: LGTM! The IsValid method is properly updated.

The ValueTypePhotooverlay is correctly added to the IsValid method, ensuring proper validation throughout the application.


761-764:

❓ Verification inconclusive

Consider adding validation for the CameraDuration field.

Currently, there's no validation for the CameraDuration field. If there are valid ranges for this value (e.g., minimum or maximum duration), you might want to add validation logic elsewhere in the codebase to ensure that invalid values are not accepted.


🏁 Script executed:

#!/bin/bash
# Search for validation patterns applied to similar duration fields
echo "Searching for duration validation patterns in the codebase..."
rg "Duration.*[<>]" --type go

Length of output: 164


Action Required: Validate the CameraDuration field as needed

The code search for duration validations (via patterns like Duration.*[<>]) returned no results, confirming that similar validation logic is absent. If the CameraDuration field should have defined minimum or maximum values, please evaluate and add the appropriate validation logic. Given that the file is generated code, consider implementing this validation in the upstream business logic or input handling layer rather than modifying generated output directly.

  • File under review: server/internal/adapter/gql/gqlmodel/models_gen.go (lines 761-764)
  • No existing duration validation patterns were found in the codebase.
  • Recommendation: Determine the valid range for CameraDuration and implement validation in the proper layer.
server/internal/adapter/gql/generated.go (8)

566-569: Structure looks correct for GraphQL complexity calculation.

The PhotoOverlay struct with its two complexity calculation functions follows the established pattern in the codebase for handling GraphQL query complexity.


4022-4035: Complexity calculation implementation is properly structured.

The implementation for complexity calculation of the PhotoOverlay fields follows the consistent pattern used for other types in the codebase, with appropriate null checks before accessing the complexity functions.


6942-6945: Clear GraphQL type definition for PhotoOverlay.

The PhotoOverlay type is correctly defined with the two fields mentioned in the PR objectives:

  • enabled: Boolean - Controls whether the overlay is active
  • cameraDuration: Int - Defines the duration for the camera

This matches the requirements described in the PR summary.


7946-7946: ValueType enum updated correctly.

The enum ValueType is properly updated to include PHOTOOVERLAY as mentioned in the PR description. This is necessary to support the new non-primitive type.


29035-29061: Resolver implementation for enabled field follows standard pattern.

The resolver for the enabled field of PhotoOverlay is implemented correctly with proper error handling, middleware integration, and nil checking before accessing the resolved value.


29076-29102: Resolver implementation for cameraDuration field follows standard pattern.

The resolver for the cameraDuration field of PhotoOverlay is implemented correctly with proper error handling, middleware integration, and nil checking before accessing the resolved value.


57672-57706: Overall PhotoOverlay type implementation is correct.

The implementation for the PhotoOverlay type follows the established pattern in the codebase:

  1. Correct field collection and handling
  2. Proper dispatch of field resolution
  3. Appropriate error handling and invalid detection
  4. Correct management of deferred fields

This matches the implementation of other GraphQL types in the file.


57670-57671: Implementors list correctly defined.

The photoOverlayImplementors slice is correctly defined with just the "PhotoOverlay" string, which is appropriate for a concrete type that doesn't implement any interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant