Skip to content

Conversation

@Jdubrick
Copy link
Contributor

@Jdubrick Jdubrick commented Sep 2, 2025

Description

  • Adds a timestamp to the response when you update the feedback status via the PUT endpoint.

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement

Related Tickets & Documents

  • Related Issue # N/A
  • Closes # N/A

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • New Features
    • Feedback status responses now include a timestamp for each update.
    • Added support for a “match” operator in JSONPath filters for API queries.
  • Documentation
    • OpenAPI spec updated to reflect the new operator and the timestamp in feedback status; examples adjusted accordingly.
  • Tests
    • Unit tests updated to validate the presence of the timestamp in feedback status responses.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 2, 2025

Walkthrough

Adds "match" to JsonPathOperator in OpenAPI. Extends feedback status update response to include a timestamp across implementation, docs, and tests. The endpoint computes the timestamp at update time. Examples and tests are updated to expect the new field.

Changes

Cohort / File(s) Summary
OpenAPI spec updates
docs/openapi.json
Added enum value "match" to JsonPathOperator. Updated FeedbackStatusUpdateResponse example to include status.timestamp.
Endpoint behavior
src/app/endpoints/feedback.py
update_feedback_status now computes a UTC timestamp and returns it in status under the "timestamp" key.
Response examples
src/models/responses.py
Documentation/examples updated to include "timestamp" in FeedbackStatusUpdateResponse examples; no model signature changes.
Unit tests
tests/unit/app/endpoints/test_feedback.py
Adjusted two tests to accept mocker and assert presence of status.timestamp via mocker.ANY.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant API as Feedback API
  participant Store as Storage

  Client->>API: PATCH /feedback/{id}/status {updated_status}
  API->>Store: Read current status
  Store-->>API: previous_status
  rect rgba(200,240,255,0.3)
    note right of API: Compute current UTC timestamp
    API->>Store: Persist updated_status (+ timestamp)
    Store-->>API: Ack
  end
  API-->>Client: 200 OK {status: {previous_status, updated_status, updated_by, timestamp}}
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • manstis
  • tisnik

Poem

A nibble of time in a timestamp bite,
I hop through specs, make enums right.
The status now ticks—so neat, so spry,
Tests nod along as seconds fly.
Thump-thump! Docs align, all set—
A happy hare commits—and jets! 🐇⌚️

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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
Contributor

@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 (7)
src/app/endpoints/feedback.py (1)

211-219: Emit RFC3339/ISO-8601 UTC timestamp (with Z) instead of str(datetime).

str(datetime.now(UTC)) yields a space separator and microseconds; examples elsewhere tend to use ISO. Recommend normalized, second-precision RFC3339 to ease client parsing and keep docs/tests consistent.

-        current_time = str(datetime.now(UTC))
+        # RFC3339 UTC, second precision, Z-suffixed
+        current_time = (
+            datetime.now(UTC)
+            .replace(microsecond=0)
+            .isoformat()
+            .replace("+00:00", "Z")
+        )

Follow-up: if accepted, mirror the same formatting in store_feedback() for consistency.

src/models/responses.py (3)

591-599: Fix example booleans and timestamp format in docstring.

Use Python booleans and ISO 8601 UTC to match the intended payload.

-        status_response = StatusResponse(
+        status_response = StatusResponse(
             status={
-                "previous_status": true,
-                "updated_status": false,
+                "previous_status": True,
+                "updated_status": False,
                 "updated_by": "user/test",
-                "timestamp": "2023-03-15 12:34:56"
+                "timestamp": "2023-03-15T12:34:56Z"
             },
         )

610-615: Keep example timestamp consistent with RFC3339 (Zulu).

-                        "timestamp": "2023-03-15 12:34:56",
+                        "timestamp": "2023-03-15T12:34:56Z",

603-603: Consider strongly typing the status payload.

Defining a dedicated model improves validation and OpenAPI fidelity (lets you mark timestamp as date-time). Optional, since this is additive.

+class FeedbackStatusPayload(BaseModel):
+    previous_status: bool
+    updated_status: bool
+    updated_by: str
+    # Use string to match emitted RFC3339 "Z" format
+    timestamp: str = Field(
+        description="RFC3339 UTC timestamp",
+        examples=["2023-03-15T12:34:56Z"],
+    )
+
 class FeedbackStatusUpdateResponse(BaseModel):
@@
-    status: dict
+    status: FeedbackStatusPayload
docs/openapi.json (1)

1537-1547: Schema for FeedbackStatusUpdateResponse.status is too permissive; define fields and timestamp format.

Current schema allows any shape. Consider declaring explicit properties and format for better contract clarity.

-            "FeedbackStatusUpdateResponse": {
-                "properties": {
-                    "status": {
-                        "additionalProperties": true,
-                        "type": "object",
-                        "title": "Status"
-                    }
-                },
+            "FeedbackStatusUpdateResponse": {
+                "properties": {
+                    "status": {
+                        "type": "object",
+                        "title": "Status",
+                        "additionalProperties": false,
+                        "required": [
+                            "previous_status",
+                            "updated_status",
+                            "updated_by",
+                            "timestamp"
+                        ],
+                        "properties": {
+                            "previous_status": { "type": "boolean" },
+                            "updated_status": { "type": "boolean" },
+                            "updated_by":     { "type": "string"  },
+                            "timestamp":      { "type": "string", "format": "date-time" }
+                        }
+                    }
+                },
@@
-                "examples": [
+                "examples": [
                     {
                         "status": {
                             "previous_status": true,
-                            "timestamp": "2023-03-15 12:34:56",
+                            "timestamp": "2023-03-15T12:34:56Z",
                             "updated_by": "user/test",
                             "updated_status": false
                         }
                     }
                 ]
tests/unit/app/endpoints/test_feedback.py (2)

200-214: LGTM; optionally assert timestamp shape (ISO 8601 UTC).

Current ANY check is fine. If you adopt RFC3339/Z formatting, add a light regex assert.

     assert resp.status == {
         "previous_status": True,
         "updated_status": False,
         "updated_by": "test_user_id",
         "timestamp": mocker.ANY,
     }
+    # Optional: enforce format
+    import re
+    assert re.match(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$", resp.status["timestamp"])

217-231: LGTM; mirror the optional timestamp format assertion here.

     assert resp.status == {
         "previous_status": True,
         "updated_status": True,
         "updated_by": "test_user_id",
         "timestamp": mocker.ANY,
     }
+    import re
+    assert re.match(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$", resp.status["timestamp"])
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9c51e77 and 1b6b850.

📒 Files selected for processing (4)
  • docs/openapi.json (2 hunks)
  • src/app/endpoints/feedback.py (1 hunks)
  • src/models/responses.py (2 hunks)
  • tests/unit/app/endpoints/test_feedback.py (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/app/endpoints/feedback.py (1)
src/models/responses.py (1)
  • FeedbackStatusUpdateResponse (583-619)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: e2e_tests
  • GitHub Check: build-pr
🔇 Additional comments (1)
docs/openapi.json (1)

1663-1665: Verify backend supports the new "match" operator.

OpenAPI now advertises "match", but if server-side JWT role evaluation doesn’t implement it, clients will get misleading docs.

Would you like me to scan the codebase for JsonPathOperator handling and confirm support paths?

Copy link
Contributor

@tisnik tisnik left a comment

Choose a reason for hiding this comment

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

LGTM

@tisnik tisnik merged commit e8f07b0 into lightspeed-core:main Sep 3, 2025
19 checks 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