Skip to content

Subscription IsCustom #2414

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Subscription IsCustom #2414

wants to merge 1 commit into from

Conversation

GAlexIHU
Copy link
Contributor

@GAlexIHU GAlexIHU commented Mar 11, 2025

Overview

  • Storing the timestamp of the last edit on the subscription
  • Adding IsCustom field: if a subscription doesn't have a plan ref (created as a custom sub) or is edited (has edit timestamp) it will be a custom subscription.
  • We don't try to guess last edit times for existing subscriptions: for existing subs, they'll only be custom if they dont have a planref

Summary by CodeRabbit

  • New Features
    • Subscriptions now show a “custom” indicator to reveal whether they were customized.
    • A “last edited” timestamp has been added to subscription details, offering better visibility into recent modifications.
    • Updates to subscription editing now validate that customizations are provided, ensuring users receive clear error feedback when input is missing.

@GAlexIHU GAlexIHU added the release-note/feature Release note: Exciting New Features label Mar 11, 2025
@GAlexIHU GAlexIHU requested a review from solkimicreb March 11, 2025 13:27
@GAlexIHU GAlexIHU self-assigned this Mar 11, 2025
@GAlexIHU GAlexIHU requested a review from a team as a code owner March 11, 2025 13:27
Copy link

coderabbitai bot commented Mar 11, 2025

📝 Walkthrough

Walkthrough

This pull request introduces two major changes to the subscription models. First, a new boolean field (IsCustom/isCustom) is added to various subscription definitions (both API schemas and client models) to indicate custom subscriptions. Second, a new timestamp field (last_edited_at) is integrated into the database schema and the ORM layer with comprehensive support through added methods for setting, clearing, and querying. Additional repository and service logic has been updated to handle marking subscriptions as edited, and new SQL migrations ensure the database schema reflects these changes.

Changes

File(s) Change Summary
api/api.gen.go, api/client/go/client.gen.go, api/client/javascript/src/client/schemas.ts, api/openapi.{cloud,yaml}, api/spec/src/productcatalog/subscription.tsp Added a new boolean field (IsCustom/isCustom) to the Subscription and SubscriptionExpanded models/schemas. Minor updates to the swaggerSpec string were also applied.
openmeter/ent/db/{migrate/schema.go, mutation.go, setorclear.go, subscription.go, subscription/where.go, subscription_create.go, subscription_update.go}, openmeter/ent/schema/subscription.go Introduced a new last_edited_at column/field. Added methods for setting, clearing, and querying this field in mutations and updates, updated scanning/assignment logic, and adjusted foreign keys and indices accordingly.
openmeter/{productcatalog/subscription/http/mapping.go, subscription/repo/{mapping.go, subscriptionrepo.go}, subscription/{repository.go, service/service.go, service/workflowservice{.go,_test.go}, subscription.go} Enhanced API mapping and domain logic to propagate the IsCustom and LastEditedAt fields. Added a repository method (MarkEdited) and updated the service layer to mark subscriptions as edited, including additional validation and error handling (with corresponding test updates).
tools/migrate/migrations/{20250312103404_subscription-editedat.up.sql, 20250312103404_subscription-editedat.down.sql} Added SQL migration files to create a new last_edited_at column in the subscriptions table and to provide a rollback operation by dropping this column.

Possibly related PRs

  • List Customer Subscriptions #2429: The changes in the main PR are related to those in the retrieved PR as both introduce a new boolean field IsCustom to the Subscription and SubscriptionExpanded structs, indicating whether a subscription is custom.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

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.

@GAlexIHU GAlexIHU force-pushed the galexi/subs-edited-status branch from a6d0ca1 to c95aa7e Compare March 11, 2025 13:31
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

🔭 Outside diff range comments (1)
openmeter/subscription/subscription.go (1)

32-46: 💡 Verification agent

🧩 Analysis chain

The AsEntityInput method doesn't propagate the new LastEditedAt field.

The AsEntityInput() method doesn't include the newly added LastEditedAt field when creating a CreateSubscriptionEntityInput. This might lead to the edit timestamp being lost when converting between representations.


🏁 Script executed:

#!/bin/bash
# Check if CreateSubscriptionEntityInput has a LastEditedAt field
# and how this field is used in other parts of the codebase

echo "Checking if CreateSubscriptionEntityInput struct has LastEditedAt field:"
rg "type CreateSubscriptionEntityInput struct" -A 20

echo -e "\nChecking where AsEntityInput is used:"
rg "AsEntityInput\(\)" -B 2 -A 2

Length of output: 2667


Action Required: Propagate the New LastEditedAt Field in the Entity Conversion

The current implementation of the AsEntityInput method in openmeter/subscription/subscription.go does not include the new LastEditedAt field. This omission means that when converting a Subscription into a CreateSubscriptionEntityInput, any updated timestamp indicating the last edit is not propagated, potentially resulting in stale edit metadata. To resolve this, please:

  • Update the CreateSubscriptionEntityInput struct (located in openmeter/subscription/repository.go) to include a LastEditedAt field if it’s meant to track edit timestamps.
  • Modify the AsEntityInput method to assign s.LastEditedAt to the corresponding field of the input struct.
  • Verify the changes wherever AsEntityInput is used (e.g., in openmeter/subscription/service/service.go) to ensure that the edit timestamp is correctly passed through the conversion.
🧹 Nitpick comments (10)
api/openapi.yaml (2)

15830-15841: Clear documentation for the isCustom property.
The added schema for isCustom is well documented, explaining that a subscription is custom if it either lacks a plan reference or has been edited. One minor nitpick: the description uses "it's original form" where the correct possessive is "its original form." Consider fixing this for grammatical accuracy.


16005-16016: Replication of the isCustom field in the expanded schema.
The changes correctly integrate the isCustom field into this part of the schema, mirroring the previous definition. The description is clear; however, as noted earlier, please update "it's original form" to "its original form" for grammatical correctness.

tools/migrate/migrations/20250311123806_subscription-editedat.down.sql (1)

1-2: SQL Down Migration: Revert last_edited_at Column Addition

The migration correctly drops the last_edited_at column from the "subscriptions" table as part of the rollback process. Consider verifying that there are no dependent queries or application logic that might break when the column is removed. Optionally, you might add an IF EXISTS clause to avoid errors if the column does not exist in some environments.

api/client/javascript/src/client/schemas.ts (2)

7110-7113: Code looks good with a minor grammatical issue

The implementation of the isCustom field in the Subscription schema is well-documented and aligns with the PR objectives. The field correctly identifies custom subscriptions based on the specified criteria.

There is a small grammatical error in the documentation:

-      /** @description Whether the subscription is custom. A subscription is custom if
-       *     - it was customized at creation (not based on a plan, has no PlanReference)
-       *     - or if it has been edited (even if eventually edited back to it's original form) */
+      /** @description Whether the subscription is custom. A subscription is custom if
+       *     - it was customized at creation (not based on a plan, has no PlanReference)
+       *     - or if it has been edited (even if eventually edited back to its original form) */

7232-7235: Same grammatical issue in SubscriptionExpanded schema

The implementation for the SubscriptionExpanded schema looks good but contains the same grammatical error.

-      /** @description Whether the subscription is custom. A subscription is custom if
-       *     - it was customized at creation (not based on a plan, has no PlanReference)
-       *     - or if it has been edited (even if eventually edited back to it's original form) */
+      /** @description Whether the subscription is custom. A subscription is custom if
+       *     - it was customized at creation (not based on a plan, has no PlanReference)
+       *     - or if it has been edited (even if eventually edited back to its original form) */
tools/migrate/migrations/20250311123806_subscription-editedat.up.sql (1)

1-3: New SQL Migration: Adding "last_edited_at" Column

The migration script correctly adds the new nullable "last_edited_at" column of type timestamptz to the "subscriptions" table. This aligns with the PR objectives to store the last edit timestamp, which will serve as an indicator for custom subscriptions.

Suggestions:

  • Index Consideration: If the last_edited_at column is expected to be frequently queried (e.g., sorting or filtering by edit timestamps), consider adding an index on this column in a future migration.
  • Default Value: Confirm that having this column nullable (with no default value) fits the requirements for both new and existing subscriptions.
api/openapi.cloud.yaml (2)

15550-15561: Property Definition for isCustom

The new isCustom property is clearly defined with type boolean and a detailed description explaining its criteria. One minor suggestion: consider correcting the possessive typo in the description—change "it's original form" to "its original form" to improve clarity.


15725-15736: Schema Extension with isCustom for Subscription Mapping

The inclusion of the isCustom field in the schema—with its associated type and descriptive text—provides a clear and self-documenting mechanism for identifying custom subscriptions. Again, please consider updating the phrase "even if eventually edited back to it's original form" to "its original form" for grammatical correctness.

api/api.gen.go (2)

4654-4657: Documentation comment has a minor typo

The documentation for the IsCustom field has a small grammatical error in the third bullet point. It should be "its" (possessive) rather than "it's" (contraction for "it is").

 // IsCustom Whether the subscription is custom. A subscription is custom if
 // - it was customized at creation (not based on a plan, has no PlanReference)
-// - or if it has been edited (even if eventually edited back to it's original form)
+// - or if it has been edited (even if eventually edited back to its original form)
 IsCustom bool `json:"isCustom"`

4749-4752: Same typo in the second documentation block

This documentation comment has the same grammatical error as the previous one.

 // IsCustom Whether the subscription is custom. A subscription is custom if
 // - it was customized at creation (not based on a plan, has no PlanReference)
-// - or if it has been edited (even if eventually edited back to it's original form)
+// - or if it has been edited (even if eventually edited back to its original form)
 IsCustom bool `json:"isCustom"`
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c425d7b and c95aa7e.

⛔ Files ignored due to path filters (1)
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum
📒 Files selected for processing (25)
  • api/api.gen.go (5 hunks)
  • api/client/go/client.gen.go (3 hunks)
  • api/client/javascript/src/client/schemas.ts (2 hunks)
  • api/openapi.cloud.yaml (4 hunks)
  • api/openapi.yaml (4 hunks)
  • api/spec/src/productcatalog/subscription.tsp (1 hunks)
  • openmeter/ent/db/migrate/schema.go (3 hunks)
  • openmeter/ent/db/mutation.go (10 hunks)
  • openmeter/ent/db/setorclear.go (1 hunks)
  • openmeter/ent/db/subscription.go (4 hunks)
  • openmeter/ent/db/subscription/subscription.go (3 hunks)
  • openmeter/ent/db/subscription/where.go (2 hunks)
  • openmeter/ent/db/subscription_create.go (5 hunks)
  • openmeter/ent/db/subscription_update.go (4 hunks)
  • openmeter/ent/schema/subscription.go (1 hunks)
  • openmeter/productcatalog/subscription/http/mapping.go (2 hunks)
  • openmeter/subscription/repo/mapping.go (1 hunks)
  • openmeter/subscription/repo/subscriptionrepo.go (1 hunks)
  • openmeter/subscription/repository.go (1 hunks)
  • openmeter/subscription/service/service.go (1 hunks)
  • openmeter/subscription/service/workflowservice.go (1 hunks)
  • openmeter/subscription/service/workflowservice_test.go (1 hunks)
  • openmeter/subscription/subscription.go (2 hunks)
  • tools/migrate/migrations/20250311123806_subscription-editedat.down.sql (1 hunks)
  • tools/migrate/migrations/20250311123806_subscription-editedat.up.sql (1 hunks)
🔇 Additional comments (56)
api/openapi.yaml (2)

15753-15759: Insertion of the new isCustom field in field listings.
The new field isCustom is correctly added in the field list alongside existing fields such as activeFrom, status, and customerId. This ensures that clients are aware of the field as part of the model.


15931-15937: Consistent inclusion of isCustom in the properties list.
The update in this section consistently includes the isCustom field in the list of properties along with activeFrom, status, customerId, currency, and phases. This maintains uniformity across the model definitions.

api/openapi.cloud.yaml (2)

15473-15479: New Required Field Addition: isCustom in Object List

The addition of the - isCustom element to the list ensures that this new field is explicitly required in the object. This aligns with the subscription logic whereby a subscription is considered custom if it either lacks a plan reference or has been edited. Verify that this change is consistent with your overall API design and that downstream consumers are aware of the new required property.


15651-15657: Consistent Inclusion of isCustom in Required Lists

This hunk introduces - isCustom consistently within another related object’s required list. Ensure that marking isCustom as required for both objects is intentional and that any necessary documentation or client library adjustments are made to reflect this requirement.

openmeter/ent/schema/subscription.go (1)

38-38: LGTM: Added last_edited_at field to track subscription edits

The new last_edited_at field is well-defined with appropriate modifiers:

  • Optional() allows the field to be omitted
  • Nillable() allows the field to be explicitly set to NULL

This implementation aligns with the PR objective of tracking when a subscription was last edited.

api/spec/src/productcatalog/subscription.tsp (1)

99-104: LGTM: Well-documented isCustom property

The new isCustom boolean property is added with comprehensive documentation that clearly defines when a subscription is considered custom:

  1. When created without a plan reference
  2. When it has been edited at any point

This implementation matches the PR objectives and provides clear guidance for API consumers.

openmeter/subscription/service/workflowservice.go (1)

89-91: Good addition: Empty customizations validation

This validation check prevents processing empty customization lists, failing early with a clear error message. This is a good defensive programming practice that improves error handling in the workflow service.

openmeter/subscription/repository.go (1)

51-52: LGTM: New MarkEdited method for tracking subscription customizations

The new MarkEdited method provides a clean interface for marking subscriptions as custom when they're edited. This method:

  • Takes a timestamp parameter to record when the edit occurred
  • Returns the updated subscription
  • Has a clear, concise description

This implementation supports the PR objective of tracking subscription edits.

openmeter/ent/db/subscription.go (5)

50-51: Well-structured field addition for tracking subscription edits.

The LastEditedAt field addition is properly documented and follows the same pattern as other nullable time fields in the struct. This aligns with the PR objective to store the timestamp of the last edit made to a subscription.


124-125: Correctly updated scan values method to handle the new field.

The scanValues method is appropriately updated to include the new LastEditedAt field, ensuring it's handled as a sql.NullTime type during database operations.


231-237: Properly implemented value assignment for LastEditedAt.

The assignment logic is consistent with other nullable time field implementations, correctly handling type checking, validity verification, and value assignment.


340-344: String method correctly updated to include LastEditedAt.

The String method is properly updated to include the new field in the string representation, with appropriate null checking and time formatting.


19-56:

❌ Incorrect review comment

Missing IsCustom method in the Subscription struct.

The PR objectives specify that an IsCustom field/method should be added to determine whether a subscription is custom based on either lacking a plan reference or having an edit timestamp. This functionality appears to be missing from the implementation.

Please verify this with the following script:


🏁 Script executed:

#!/bin/bash
# Check if IsCustom method exists in other files in the codebase
rg -A 5 "func \(\w+ (Subscription|subscription)\) IsCustom\(\)" --type go

Length of output: 284


Clarification: The IsCustom method is not missing.
The necessary IsCustom functionality is implemented in the repository within the file openmeter/subscription/subscription.go:

  • The method signature is:
    func (s Subscription) IsCustom() bool {
        return s.LastEditedAt != nil || s.PlanRef == nil
    }
  • This implementation meets the PR objectives to determine if a subscription is custom (i.e., lacking a plan reference or having a non-nil edit timestamp).

Please update the documentation or references if needed to point to this implementation.

Likely an incorrect or invalid review comment.

openmeter/ent/db/subscription/subscription.go (3)

43-44: Appropriate field constant declaration.

The constant for the new field follows the existing naming pattern and clearly documents its purpose.


101-101: Correctly added LastEditedAt to Columns slice.

The field is properly added to the Columns slice, ensuring it's included in database operations.


205-208: Well-implemented ordering function for LastEditedAt.

The ByLastEditedAt function follows the same pattern as other ordering functions, allowing proper ordering by the new field in queries.

openmeter/subscription/repo/mapping.go (1)

48-53: Correctly mapped LastEditedAt in the domain model.

The field mapping is properly implemented, ensuring that the LastEditedAt timestamp is converted to UTC and included in the mapped subscription object. This maintains consistency with other time fields in the mapping function.

openmeter/subscription/service/service.go (1)

203-207: Properly implemented edit timestamp tracking.

The edit timestamp is now correctly updated during subscription modifications by calling the MarkEdited method with the current time. This implementation aligns with the PR objective to track the last edit time for subscriptions.

openmeter/subscription/repo/subscriptionrepo.go (1)

32-47: Looks good - Implementation follows proper repository pattern

The implementation of MarkEdited follows the established repository pattern in the codebase, properly using transactions, error handling, and UTC time conversion. This aligns with the PR's objective to track modifications to subscriptions by storing the edit timestamp.

openmeter/ent/db/setorclear.go (1)

2088-2100: Implementation correctly follows the established pattern

The new SetOrClearLastEditedAt methods for both SubscriptionUpdate and SubscriptionUpdateOne types follow the consistent pattern seen throughout the file. They handle the nullable LastEditedAt field appropriately, ensuring it can be either set or cleared based on whether a value is provided.

api/api.gen.go (3)

13964-14008: Auto-generated Swagger spec changes look good

These changes to the embedded Swagger specification correctly reflect the addition of the IsCustom field to the API models. This is auto-generated content that properly documents the API changes.


14022-14025: Auto-generated Swagger spec changes (continued)

Continuing the auto-generated changes to the Swagger specification. No issues found.


14040-14364: Remaining auto-generated Swagger spec changes look good

The rest of the changes to the embedded Swagger specification continue to document the API changes. This is expected for auto-generated content.

openmeter/subscription/subscription.go (2)

27-29: Well-structured field addition for tracking subscription edits.

The LastEditedAt field is properly implemented as a pointer to time.Time with an appropriate JSON tag that includes omitempty. This aligns well with the PR objective of storing the timestamp of the last edit to a subscription.


73-75: Clear and concise implementation of the IsCustom logic.

The method correctly implements the custom subscription logic as defined in the PR objectives - a subscription is custom if it either lacks a plan reference or has been edited (indicated by LastEditedAt not being nil).

api/client/go/client.gen.go (3)

4553-4556: Implementation of IsCustom field looks good.

The new IsCustom boolean field has been properly added to the Subscription struct with clear documentation explaining when a subscription is considered custom. The field follows Go naming conventions and is correctly tagged for JSON serialization.


4648-4651: Implementation of IsCustom field is consistent.

The IsCustom field has been implemented consistently in the SubscriptionExpanded struct with identical documentation and JSON tagging, maintaining consistency across related structs.


30428-30742: Swagger spec updates align with model changes.

The swagger spec has been appropriately updated to include the new isCustom field. These changes appear to be auto-generated and align with the model definition changes made above.

openmeter/productcatalog/subscription/http/mapping.go (2)

194-194: Implementation of the IsCustom flag.

The new IsCustom field is correctly added to the API subscription model, using the IsCustom() method from the subscription domain model. This fulfills the requirement to expose this information via the API.


523-523: Correctly propagates IsCustom to the expanded subscription view.

The IsCustom field is properly forwarded from the basic subscription API model to the expanded subscription API model, ensuring consistency across different API representations.

openmeter/subscription/service/workflowservice_test.go (1)

123-129: Updated test expectation to match new validation requirement.

The test case has been updated to expect an error when no patches are provided, rather than expecting no action to occur. This change correctly aligns with the new validation in the workflow service that requires at least one customization when editing a subscription.

This change in behavior makes sense for tracking custom subscriptions as described in the PR objectives - requiring explicit customizations helps identify which subscriptions have been edited.

openmeter/ent/db/subscription_update.go (4)

160-178: Added LastEditedAt field methods to SubscriptionUpdate.

These new methods properly implement the database operations for the last_edited_at field, which is essential for tracking when a subscription was last edited. This field is a key part of the PR's objectives to identify custom subscriptions.

The implementation follows the consistent pattern used for other time fields in this generated code.


362-367: Added LastEditedAt field handling in sqlSave method.

The sqlSave method is correctly updated to handle the new last_edited_at field, ensuring proper database persistence when updating subscriptions.


633-651: Added LastEditedAt field methods to SubscriptionUpdateOne.

These methods implement the necessary operations for the single-entity update variant, maintaining consistency with the batch update implementation.


865-870: Added LastEditedAt field handling in SubscriptionUpdateOne.sqlSave.

The single-entity sqlSave method is properly updated to handle the last_edited_at field, ensuring consistency with the batch update implementation.

openmeter/ent/db/migrate/schema.go (4)

1688-1688: Well-designed column addition for tracking subscription edits.

The addition of the last_edited_at column with nullable Time type is well-implemented and aligns perfectly with the PR objective of tracking when a subscription was last edited. This field will be essential for determining if a subscription is custom.


1700-1703: Properly updated foreign key reference for customer ID.

The column index has been correctly adjusted from 12 to 13 to account for the newly added last_edited_at field, maintaining proper foreign key relationships.


1705-1709: Properly updated foreign key reference for plan ID.

The column index has been correctly adjusted from 13 to 14 to account for the newly added last_edited_at field, maintaining proper foreign key relationships.


1728-1731: Properly updated index for namespace and customer ID.

The column index has been correctly adjusted to reference the new column positions after adding the last_edited_at field, ensuring database indexes remain valid.

openmeter/ent/db/mutation.go (10)

36869-36869: Field addition looks good.

The addition of last_edited_at field to the SubscriptionMutation struct aligns with the PR objective of tracking when a subscription was last edited.


37523-37570: Well-implemented field management methods.

The implementation includes all necessary methods for managing the last_edited_at field (set, get, get old value, clear, check if cleared, reset). The error handling in OldLastEditedAt correctly validates the operation type and ID presence before fetching the old value.


37768-37768: Capacity adjustment is correct.

Increasing the capacity of the fields slice from 13 to 14 accommodates the new last_edited_at field.


37808-37810: Field inclusion logic is properly implemented.

The code correctly appends the last_edited_at field to the fields list when it's set.


37845-37846: Field accessor method properly updated.

The Field method is correctly extended to return the value of the last_edited_at field.


37882-37883: OldField accessor method properly updated.

The OldField method is correctly extended to return the old value of the last_edited_at field.


37984-37990: SetField method properly updated.

The SetField method is correctly extended to handle setting the last_edited_at field with appropriate type checking.


38036-38038: ClearedFields method properly updated.

The method now correctly includes the last_edited_at field when it has been cleared.


38068-38070: ClearField method properly updated.

The ClearField method is correctly extended to handle clearing the last_edited_at field.


38118-38120: ResetField method properly updated.

The ResetField method is correctly extended to handle resetting the last_edited_at field.

openmeter/ent/db/subscription/where.go (2)

130-133: Methods for the new LastEditedAt field look well-implemented

This addition introduces the main equality predicate for the new last_edited_at field that will be used to track subscription edits, aligning with the PR objective of determining custom subscriptions.


804-852: Complete set of predicate functions for the last_edited_at field

These predicate functions follow the standard pattern used for other fields in the Subscription entity, providing a full range of comparison operators (EQ, NEQ, GT, LT, etc.) and nullability checks. The implementation is thorough and consistent with the codebase's patterns.

openmeter/ent/db/subscription_create.go (5)

173-185: Well-implemented creation methods for the new field

These methods correctly handle setting the last_edited_at field during subscription creation, with proper null-handling logic that follows the established pattern of the codebase.


427-430: Properly integrated into the creation spec

The last_edited_at field is correctly integrated into the createSpec method, ensuring that the value will be properly set in the database when a new subscription is created.


675-691: Proper upsert operations for the new field

These methods provide the necessary functionality for handling the last_edited_at field during upsert operations, allowing for setting, updating, and clearing the field value.


903-922: Single item upsert operations implemented correctly

These methods correctly implement the operations needed for the last_edited_at field in the context of upserting a single item, maintaining consistency with the codebase patterns.


1301-1320: Bulk upsert operations implemented correctly

These methods provide the necessary bulk upsert functionality for the last_edited_at field, completing the full set of CRUD operations required for the new field.

@@ -35,6 +35,7 @@ func (Subscription) Fields() []ent.Field {
field.String("plan_id").Optional().Nillable(),
field.String("customer_id").NotEmpty().Immutable(),
field.String("currency").GoType(currencyx.Code("")).MinLen(3).MaxLen(3).NotEmpty().Immutable(),
field.Time("last_edited_at").Optional().Nillable(),
Copy link
Contributor

@tothandras tothandras Mar 11, 2025

Choose a reason for hiding this comment

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

updated_at is not the same, simply edited_at? but I'm fine with last_edited_at

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, that's the resource's updated at. last_edited_at is for the whole subscription

@@ -29,6 +29,23 @@ func NewSubscriptionRepo(db *db.Client) *subscriptionRepo {
}
}

func (r *subscriptionRepo) MarkEdited(ctx context.Context, id models.NamespacedID, at time.Time) (subscription.Subscription, error) {
return entutils.TransactingRepo(ctx, r, func(ctx context.Context, repo *subscriptionRepo) (subscription.Subscription, error) {
ent, err := repo.db.Subscription.UpdateOneID(id.ID).SetLastEditedAt(at.UTC()).Where(dbsubscription.Namespace(id.Namespace)).Save(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

move where close to the beginning

Suggested change
ent, err := repo.db.Subscription.UpdateOneID(id.ID).SetLastEditedAt(at.UTC()).Where(dbsubscription.Namespace(id.Namespace)).Save(ctx)
ent, err := repo.db.Subscription.UpdateOneID(id.ID).Where(dbsubscription.Namespace(id.Namespace)).SetLastEditedAt(at.UTC()).Save(ctx)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the current order follow sql syntax order

@@ -519,6 +520,7 @@ func MapSubscriptionViewToAPI(view subscription.SubscriptionView) (api.Subscript
UpdatedAt: apiSub.UpdatedAt,
Status: apiSub.Status,
Alignment: &alg,
IsCustom: apiSub.IsCustom,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we expose EditedAt as well on the API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can, but then we commit to it in this form

@GAlexIHU GAlexIHU requested a review from tothandras March 11, 2025 14:17
@GAlexIHU GAlexIHU force-pushed the galexi/subs-edited-status branch from c95aa7e to b620294 Compare March 12, 2025 11:17
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

🔭 Outside diff range comments (1)
openmeter/ent/db/subscription.go (1)

1-347: ⚠️ Potential issue

Missing IsCustom method according to PR objectives.

According to the PR objectives, subscriptions should be classified as custom if they either lack a plan reference (no PlanID) or have an associated edit timestamp (LastEditedAt is set). However, the implementation of the IsCustom method that would determine this status is missing from the Subscription struct.

Suggest adding the following method to meet the requirements:

// IsCustom returns true if the subscription is classified as custom.
// A subscription is custom if it either lacks a plan reference or has been edited.
func (s Subscription) IsCustom() bool {
    return s.PlanID == nil || s.LastEditedAt != nil
}
🧹 Nitpick comments (6)
api/openapi.yaml (2)

15818-15829: Define 'isCustom' with Clear Documentation
The isCustom property is added with an appropriate boolean type and a detailed description outlining when a subscription is considered custom. One nitpick: in the description, please change "edited back to it's original form" to "edited back to its original form" for grammatical correctness.


15993-16004: Uniform Schema Definition for 'isCustom'
The specification for the isCustom property here mirrors the changes in the previous model with a clear boolean type and extended description. As with the previous hunk, consider correcting "edited back to it's original form" to "edited back to its original form" for clarity.

api/client/javascript/src/client/schemas.ts (2)

7110-7113: Fix typo in JSDoc comment.

There's a typographical error in the JSDoc comment on line 7112. It currently says "...edited back to it's original form" when it should say "...edited back to its original form". The word "its" is the possessive form, while "it's" is a contraction of "it is".

      /** @description Whether the subscription is custom. A subscription is custom if
       *     - it was customized at creation (not based on a plan, has no PlanReference)
-       *     - or if it has been edited (even if eventually edited back to it's original form) */
+       *     - or if it has been edited (even if eventually edited back to its original form) */
      isCustom: boolean

7232-7235: Fix the same typo in the second JSDoc comment.

The same typographical error exists in this JSDoc comment as well. Please change "it's" to "its" for grammatical correctness.

      /** @description Whether the subscription is custom. A subscription is custom if
       *     - it was customized at creation (not based on a plan, has no PlanReference)
-       *     - or if it has been edited (even if eventually edited back to it's original form) */
+       *     - or if it has been edited (even if eventually edited back to its original form) */
      isCustom: boolean
api/api.gen.go (2)

4654-4657: Fix typographical error in comment

There's a typographical error in the documentation comment. The comment uses "it's" (contraction of "it is") instead of "its" (possessive).

  // IsCustom Whether the subscription is custom. A subscription is custom if
  // - it was customized at creation (not based on a plan, has no PlanReference)
- // - or if it has been edited (even if eventually edited back to it's original form)
+ // - or if it has been edited (even if eventually edited back to its original form)
  IsCustom bool `json:"isCustom"`

4749-4752: Fix typographical error in comment

The same typographical error appears in this comment as well. The comment uses "it's" (contraction of "it is") instead of "its" (possessive).

  // IsCustom Whether the subscription is custom. A subscription is custom if
  // - it was customized at creation (not based on a plan, has no PlanReference)
- // - or if it has been edited (even if eventually edited back to it's original form)
+ // - or if it has been edited (even if eventually edited back to its original form)
  IsCustom bool `json:"isCustom"`
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c95aa7e and b620294.

⛔ Files ignored due to path filters (1)
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum
📒 Files selected for processing (25)
  • api/api.gen.go (5 hunks)
  • api/client/go/client.gen.go (3 hunks)
  • api/client/javascript/src/client/schemas.ts (2 hunks)
  • api/openapi.cloud.yaml (4 hunks)
  • api/openapi.yaml (4 hunks)
  • api/spec/src/productcatalog/subscription.tsp (1 hunks)
  • openmeter/ent/db/migrate/schema.go (3 hunks)
  • openmeter/ent/db/mutation.go (10 hunks)
  • openmeter/ent/db/setorclear.go (1 hunks)
  • openmeter/ent/db/subscription.go (4 hunks)
  • openmeter/ent/db/subscription/subscription.go (3 hunks)
  • openmeter/ent/db/subscription/where.go (2 hunks)
  • openmeter/ent/db/subscription_create.go (5 hunks)
  • openmeter/ent/db/subscription_update.go (4 hunks)
  • openmeter/ent/schema/subscription.go (1 hunks)
  • openmeter/productcatalog/subscription/http/mapping.go (2 hunks)
  • openmeter/subscription/repo/mapping.go (1 hunks)
  • openmeter/subscription/repo/subscriptionrepo.go (1 hunks)
  • openmeter/subscription/repository.go (1 hunks)
  • openmeter/subscription/service/service.go (1 hunks)
  • openmeter/subscription/service/workflowservice.go (1 hunks)
  • openmeter/subscription/service/workflowservice_test.go (1 hunks)
  • openmeter/subscription/subscription.go (2 hunks)
  • tools/migrate/migrations/20250312103404_subscription-editedat.down.sql (1 hunks)
  • tools/migrate/migrations/20250312103404_subscription-editedat.up.sql (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • tools/migrate/migrations/20250312103404_subscription-editedat.down.sql
  • tools/migrate/migrations/20250312103404_subscription-editedat.up.sql
🚧 Files skipped from review as they are similar to previous changes (13)
  • openmeter/subscription/service/workflowservice.go
  • openmeter/ent/schema/subscription.go
  • openmeter/subscription/repository.go
  • api/spec/src/productcatalog/subscription.tsp
  • openmeter/subscription/service/service.go
  • openmeter/subscription/subscription.go
  • openmeter/subscription/repo/mapping.go
  • openmeter/productcatalog/subscription/http/mapping.go
  • openmeter/ent/db/migrate/schema.go
  • openmeter/subscription/repo/subscriptionrepo.go
  • openmeter/ent/db/subscription/where.go
  • openmeter/ent/db/mutation.go
  • api/openapi.cloud.yaml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (go)
🔇 Additional comments (26)
api/openapi.yaml (2)

15741-15747: Ensure Consistent Field Inclusion
The new - isCustom field is correctly added to the list of schema fields. Please verify that the ordering is intentional and consistent with your field grouping conventions across models.


15919-15925: Consistent Update to Required Fields
The required fields update now includes - isCustom, alongside other properties such as activeFrom, status, customerId, etc. Ensure that this inclusion is aligned with your intended validation rules and that downstream consumers are updated accordingly.

api/client/javascript/src/client/schemas.ts (1)

7110-7113: Implementation aligns well with PR objectives.

The added isCustom field correctly implements the requirements stated in the PR objectives. The JSDoc comments clearly explain when a subscription is considered custom (either created without a plan reference or edited at some point). This implementation is consistent with similar changes in other files noted in the AI summary.

Also applies to: 7232-7235

openmeter/ent/db/subscription/subscription.go (3)

43-44: LGTM! New field definition follows established pattern.

The addition of the FieldLastEditedAt constant correctly follows the established pattern in the codebase for field definitions.


101-101: LGTM! Field properly added to Columns array.

The FieldLastEditedAt is correctly added to the Columns array, ensuring it will be included in SQL column aggregation.


205-208: LGTM! Ordering function implementation is consistent with existing pattern.

The ByLastEditedAt function follows the same pattern as other ordering functions in this file, using the sql.OrderByField method to enable ordering of results based on the new field.

openmeter/ent/db/setorclear.go (1)

2088-2100: LGTM! SetOrClear methods follow consistent pattern.

The SetOrClearLastEditedAt methods for both SubscriptionUpdate and SubscriptionUpdateOne are implemented correctly, following the established pattern for nullable fields. These methods will enable clients to set or clear the last_edited_at field in a consistent way.

openmeter/ent/db/subscription.go (4)

50-51: LGTM! Field addition to Subscription struct follows established pattern.

The LastEditedAt field is correctly added as a pointer to time.Time and marked as optional in JSON serialization, matching the pattern used for other nullable time fields in the struct.


124-125: LGTM! Field included in scanValues method.

The FieldLastEditedAt is correctly included in the scanValues method case statement for time fields, allowing it to be properly scanned from SQL rows.


231-237: LGTM! Field handling added to assignValues method.

The new field is properly handled in the assignValues method, with correct type checking and value assignment.


340-344: LGTM! Field included in String method.

The LastEditedAt field is correctly included in the string representation generated by the String method, following the same pattern as other time fields.

api/api.gen.go (2)

4654-4657: The implementation properly aligns with PR objectives

The addition of the IsCustom boolean field to both Subscription and SubscriptionExpanded structs correctly implements the custom subscription detection functionality as described in the PR objectives. The field is properly typed and tagged for JSON serialization.

Also applies to: 4749-4752


13949-13992: Changes to swagger specification align with API changes

The changes to the swaggerSpec variable are auto-generated from the OpenAPI/Swagger specification and reflect the addition of the IsCustom field to the subscription models.

Also applies to: 14007-14007, 14025-14346

api/client/go/client.gen.go (3)

4553-4556: New IsCustom field added to the Subscription struct

The implementation correctly adds a boolean field to track custom subscriptions. The documentation clearly explains the two conditions under which a subscription is considered custom.


4648-4651: New IsCustom field added to the SubscriptionExpanded struct

Similar to the previous change, this adds the same field with identical documentation to the SubscriptionExpanded struct. This ensures consistency between the different subscription representations.


30405-30721: Updated swagger specification with the new field

The swagger specification has been updated to include the new IsCustom field. This is an essential part of the change to ensure the API documentation and client code generation remain in sync.

openmeter/ent/db/subscription_update.go (4)

160-178: Well-implemented methods for last_edited_at field management

The implementation correctly adds the necessary methods to manage the last_edited_at field in the SubscriptionUpdate struct, following the same pattern as other fields in the codebase. This provides a complete API for setting, conditionally setting, and clearing the timestamp.


362-367: Properly integrated field handling in SQL save operation

The sqlSave method has been correctly updated to include the last_edited_at field in database operations, maintaining consistency with how other fields are handled.


633-651: Consistent implementation for SubscriptionUpdateOne methods

The implementation provides the same set of methods for the SubscriptionUpdateOne struct, ensuring consistency across the API. This follows the established pattern throughout the codebase.


865-870: SQL save operation properly handles the new field

The sqlSave method for SubscriptionUpdateOne correctly includes logic for the last_edited_at field, ensuring database operations will work as expected.

openmeter/ent/db/subscription_create.go (6)

173-185: Properly implemented creation methods for the timestamp field

The implementation adds the necessary methods to set the last_edited_at field during subscription creation, following the same patterns as other fields in the codebase.


427-430: Correctly updated create specification for the new field

The createSpec method has been properly extended to handle the last_edited_at field, ensuring it's correctly included when creating new subscription records.


675-691: Complete implementation of upsert operations for the timestamp field

The SubscriptionUpsert struct has been extended with all necessary methods for managing the last_edited_at field during upsert operations, providing a comprehensive API.


903-922: Consistent implementation for SubscriptionUpsertOne

The implementation provides the same set of methods for the SubscriptionUpsertOne struct, maintaining consistency across different operation types.


1301-1320: Consistent implementation for bulk operations

The implementation extends to bulk operations as well, ensuring the last_edited_at field can be properly managed in all contexts where subscriptions are created or updated.


1-1344: The implementation aligns perfectly with the PR objectives

The changes to add and manage the last_edited_at field directly support the PR's goal of "storing the timestamp of the last edit made to a subscription." This timestamp will be used to determine if a subscription is custom, as stated in the PR objectives: "A subscription will be marked as custom if it either lacks a plan reference or has an associated edit timestamp."

The implementation is thorough, covering all aspects of the entity lifecycle (create, update, upsert) and follows the established patterns of the codebase.

@tothandras
Copy link
Contributor

Please rebase

@GAlexIHU GAlexIHU force-pushed the galexi/subs-edited-status branch from b620294 to a208fb5 Compare March 14, 2025 13:05
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)
api/openapi.yaml (2)

16048-16059: Introduce isCustom with Detailed Documentation

The isCustom field is properly introduced with its type (boolean) and a descriptive multi-line explanation. However, in the description text, the phrase “edited back to it's original form” contains a minor grammatical error; it should be “edited back to its original form”.

Consider applying this small fix:

-            - or if it has been edited (even if eventually edited back to it's original form)
+            - or if it has been edited (even if eventually edited back to its original form)

16223-16234: Repeat isCustom Definition with Minor Grammar Note

Here again the isCustom field is introduced with the same description as in the previous hunk. The description is clear but repeats the grammatical error in “edited back to it's original form”, which should be corrected to “its original form”. A diff suggestion is provided below for consistency:

-            - or if it has been edited (even if eventually edited back to it's original form)
+            - or if it has been edited (even if eventually edited back to its original form)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b620294 and a208fb5.

⛔ Files ignored due to path filters (1)
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum
📒 Files selected for processing (25)
  • api/api.gen.go (3 hunks)
  • api/client/go/client.gen.go (3 hunks)
  • api/client/javascript/src/client/schemas.ts (2 hunks)
  • api/openapi.cloud.yaml (4 hunks)
  • api/openapi.yaml (4 hunks)
  • api/spec/src/productcatalog/subscription.tsp (1 hunks)
  • openmeter/ent/db/migrate/schema.go (3 hunks)
  • openmeter/ent/db/mutation.go (10 hunks)
  • openmeter/ent/db/setorclear.go (1 hunks)
  • openmeter/ent/db/subscription.go (4 hunks)
  • openmeter/ent/db/subscription/subscription.go (3 hunks)
  • openmeter/ent/db/subscription/where.go (2 hunks)
  • openmeter/ent/db/subscription_create.go (5 hunks)
  • openmeter/ent/db/subscription_update.go (4 hunks)
  • openmeter/ent/schema/subscription.go (1 hunks)
  • openmeter/productcatalog/subscription/http/mapping.go (2 hunks)
  • openmeter/subscription/repo/mapping.go (1 hunks)
  • openmeter/subscription/repo/subscriptionrepo.go (1 hunks)
  • openmeter/subscription/repository.go (1 hunks)
  • openmeter/subscription/service/service.go (1 hunks)
  • openmeter/subscription/service/workflowservice.go (1 hunks)
  • openmeter/subscription/service/workflowservice_test.go (1 hunks)
  • openmeter/subscription/subscription.go (2 hunks)
  • tools/migrate/migrations/20250312103404_subscription-editedat.down.sql (1 hunks)
  • tools/migrate/migrations/20250312103404_subscription-editedat.up.sql (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (18)
  • tools/migrate/migrations/20250312103404_subscription-editedat.down.sql
  • tools/migrate/migrations/20250312103404_subscription-editedat.up.sql
  • openmeter/ent/schema/subscription.go
  • api/spec/src/productcatalog/subscription.tsp
  • openmeter/subscription/service/workflowservice.go
  • openmeter/subscription/repo/subscriptionrepo.go
  • openmeter/subscription/service/service.go
  • openmeter/ent/db/subscription.go
  • openmeter/ent/db/subscription/subscription.go
  • openmeter/subscription/repo/mapping.go
  • openmeter/subscription/subscription.go
  • openmeter/productcatalog/subscription/http/mapping.go
  • openmeter/ent/db/subscription_update.go
  • openmeter/ent/db/migrate/schema.go
  • api/client/go/client.gen.go
  • openmeter/ent/db/mutation.go
  • openmeter/subscription/repository.go
  • api/openapi.cloud.yaml
🔇 Additional comments (32)
openmeter/subscription/service/workflowservice_test.go (1)

123-130: Behavior change test update aligns with implementation

The test case name and expectations have been updated to reflect the behavior change in EditRunning, now requiring at least one patch to be provided. This test case now properly validates that an empty customization set returns an error with the appropriate message.

openmeter/ent/db/setorclear.go (1)

2088-2100: Well-implemented utility methods for LastEditedAt field

These functions follow the established pattern in the codebase for setting or clearing optional fields. They correctly handle nil pointers by clearing the field or dereferencing and setting the value when non-nil, maintaining consistency with other similar methods in the file.

api/openapi.yaml (2)

15971-15977: Add isCustom in Field List

The new isCustom field has been added to the list of subscription fields. This is in line with the new functionality for flagging custom subscriptions. Please verify that clients using this schema are aware of the change and can handle an additional field in the list.


16149-16155: Consistent isCustom Inclusion for Expanded Schema

The isCustom field is consistently added in the subscription listing (likely representing an expanded view). Its placement among other fields such as activeFrom, status, and currency appears appropriate. Ensure that downstream processing or consumers that expect a fixed order (if any) are updated accordingly.

api/client/javascript/src/client/schemas.ts (2)

7166-7169: Well-documented implementation of the isCustom field in Subscription schema.

The newly added boolean field is properly documented with clear criteria for when a subscription is considered custom. The documentation aligns well with the PR objectives, explaining that a subscription is custom if it either lacks a plan reference or has been edited.


7288-7291: Consistent implementation of isCustom field in SubscriptionExpanded schema.

The same isCustom field and documentation are properly added to the SubscriptionExpanded schema, maintaining consistency across related schema definitions. This ensures the custom subscription status is available in both regular and expanded subscription representations.

api/api.gen.go (3)

4661-4667: LGTM! The new IsCustom field is well-documented.

The addition of this field with clear documentation accurately implements the described PR requirements for identifying custom subscriptions. The comment clearly explains the two conditions that make a subscription custom.


4756-4763: LGTM! Consistent implementation across subscription types.

Good job maintaining consistency by adding the same field with identical documentation to the SubscriptionExpanded struct. This ensures the IsCustom property is available in all relevant subscription representations.


14202-14517: LGTM! Updated swagger spec to reflect the schema changes.

The embedded swagger specification has been properly updated to include the new IsCustom field. This ensures that the API documentation accurately reflects the modified data models.

openmeter/ent/db/subscription/where.go (11)

130-133: Implementation is consistent
This addition follows the existing pattern of equality-based predicates for Ent fields.


804-807: Looks correct
The equality check for last_edited_at is implemented in line with Ent’s conventions.


809-812: No issues
The not-equal predicate is aligned with standard Ent usage.


814-817: No concerns
The In predicate logic is appropriate and mirrors typical patterns.


819-822: All good
The NotIn implementation cleanly complements the In predicate.


824-827: Standard approach
Greater-than predicate is correctly declared for time comparison.


829-832: Looks fine
Greater-than-or-equal predicate properly matches Ent’s syntax.


834-837: No issues
The less-than time comparison is standard.


839-842: Checks out
Less-than-or-equal predicate for last_edited_at is consistent with Ent.


844-847: All set
IsNil predicate provides a clear filter for null values.


849-852: No concerns
NotNil predicate completes the optional field handling thoroughly.

openmeter/ent/db/subscription_create.go (12)

173-177: Looks good
SetLastEditedAt adds a straightforward way to initialize the field.


179-185: No issues
SetNillableLastEditedAt is a clean approach to optional field handling.


427-430: Well-integrated
Including last_edited_at in the create spec ensures correct persistence.


675-679: Looks correct
SetLastEditedAt for upsert logic aligns with other fields’ patterns.


681-685: Good approach
UpdateLastEditedAt reflects the typical “set excluded” usage for upserts.


687-691: All good
ClearLastEditedAt properly nullifies the optional timestamp field.


903-908: Consistent
SetLastEditedAt in SubscriptionUpsertOne is implemented as expected.


910-915: No concerns
UpdateLastEditedAt for single upsert usage is in line with best practices.


917-922: Looks fine
ClearLastEditedAt ensures optional logic remains flexible for single upserts.


1301-1306: Checks out
SetLastEditedAt in bulk upsert handles the timestamp correctly.


1308-1313: No issues
UpdateLastEditedAt for bulk upsert parallels single upsert logic neatly.


1315-1320: All set
ClearLastEditedAt in bulk upsert properly nullifies the field.

@GAlexIHU GAlexIHU marked this pull request as draft April 4, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/feature Release note: Exciting New Features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants