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: add db schema and types for Plan API #1788

Merged
merged 2 commits into from
Nov 5, 2024
Merged

Conversation

chrisgacsal
Copy link
Contributor

Overview

  • add database/ent schema for Plan API
  • add Go types for Plan API

GAlexIHU
GAlexIHU previously approved these changes Nov 5, 2024
Copy link
Contributor

@GAlexIHU GAlexIHU left a comment

Choose a reason for hiding this comment

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

Nice!

}
}

func JSONStringValueScanner[T any]() field.ValueScannerFunc[T, *sql.NullString] {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest to move this under pkg/framework

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 12 to 16
// Equal is a relaxed version of StrictEqual where it is allowed to return true in case a subset of the attributes are equal.
// Typically, you want to use Equal to compare two instances of T where one or both missing some metadata which are
// not required for comparison. Like comparing two instances of T before and after stored in data layer which assigns
// additional metadata like timestamps, unique identifiers, etc.
Equal(T) bool
Copy link
Contributor

Choose a reason for hiding this comment

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

just an opinion, but I'm not sure I'm sold on this... if this behaves differently case-by-case then IMO it should be a different thing altogether

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove it for now and we can discuss it separately. This is not required for this PR.

}

func (Plan) Mixin() []ent.Mixin {
return []ent.Mixin{
Copy link
Contributor

Choose a reason for hiding this comment

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

we have the UniqueResourceMixin to combine these:

type UniqueResourceMixin struct {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Default("USD").
NotEmpty().
Immutable(),
field.Time("effectiveFrom").
Copy link
Contributor

Choose a reason for hiding this comment

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

we usually use underscore to define ent schema

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Copy/paste error. Will fix it now.


func (PlanPhase) Mixin() []ent.Mixin {
return []ent.Mixin{
entutils.IDMixin{},
Copy link
Contributor

Choose a reason for hiding this comment

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

UniqueResource?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Optional().
Nillable(),
field.String("discounts").
GoType([]plan.Discount{}).
Copy link
Contributor

Choose a reason for hiding this comment

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

normalize please, separate PR is ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. Why do we need the discounts to be normalized here?

Copy link
Contributor

Choose a reason for hiding this comment

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

@hekike please discuss with @tothandras, the two of you are on a different stance regarding normalization so IMO lets come up with an agreement (came up on other PRs as well)


func (PlanRateCard) Mixin() []ent.Mixin {
return []ent.Mixin{
entutils.IDMixin{},
Copy link
Contributor

Choose a reason for hiding this comment

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

UniqueResource?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

field.String("description").
Optional().
Nillable(),
field.String("feature_key").
Copy link
Contributor

Choose a reason for hiding this comment

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

these are mutable because user can edit plan in draft, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, thats the idea.

GAlexIHU
GAlexIHU previously approved these changes Nov 5, 2024
@chrisgacsal chrisgacsal merged commit 5e07c8b into main Nov 5, 2024
18 checks passed
@chrisgacsal chrisgacsal deleted the feat/plan-api-types branch November 5, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api release-note/feature Release note: Exciting New Features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants