-
Notifications
You must be signed in to change notification settings - Fork 68
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
Subscription Internals V2 #1851
base: main
Are you sure you want to change the base?
Conversation
func (SubscriptionItem) Fields() []ent.Field { | ||
return []ent.Field{ | ||
field.String("phase_id").NotEmpty().Immutable(), | ||
field.String("key").NotEmpty().Immutable(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a key for it, isn't ID enaough? Do we expect users to name subscription items manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid linking I'll copy from relevant docs
SubscriptionItem can be identified, it has a reference:
- If a Feature is associated with the SubscriptionItem, it is identified by the Feature
- It can be an ID reference, for an exact version of the Feature (Features can change across versions)
- It can be a Key reference, which always refers to the latest (active or inactive) version of a Feature
- If a Feature is not associated with the SubscriptionItem, it is referenced by the Price
- We say “referenced by the Price” regardless of how a price itself is referenced, it colloquially makes sense to say “paying the same price for the same thing”
In practice this will need an ID (key) being generated
- We say “referenced by the Price” regardless of how a price itself is referenced, it colloquially makes sense to say “paying the same price for the same thing”
Keys are used for identifying the "same thing" across different instances (with different IDs)
field.String("phase_id").NotEmpty().Immutable(), | ||
field.String("key").NotEmpty().Immutable(), | ||
// TODO: pending PR | ||
field.String("rate_card"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why isn't this a reference to plan_rate_card
table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a direct reference to an actual plan's actual ratecard, it will only hold the same contents as a ratecard does.
entutils.IDMixin{}, | ||
entutils.NamespaceMixin{}, | ||
entutils.TimeMixin{}, | ||
entutils.MetadataAnnotationsMixin{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need annotations instead of just adding a readonly or editable flag like: field.Bool("readonly").NotEmpty().Immutable().Default(false)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the question.
// pkg/models/model.go
type AnnotatedModel struct {
Metadata map[string]string `json:"metadata,omitempty"`
}
// pkg/framework/entutils/mixin.go
// MetadataAnnotationsMixin adds metadata to the schema
type MetadataAnnotationsMixin struct {
mixin.Schema
}
// Fields of the IDMixin.
func (MetadataAnnotationsMixin) Fields() []ent.Field {
return []ent.Field{
field.JSON("metadata", map[string]string{}).
Optional().
SchemaType(map[string]string{
dialect.Postgres: "jsonb",
}),
}
}
3a35fbb
to
f440a4e
Compare
feat: subscription creation wireframing refactor: move subscriptions out of productcatalog refactor: fresh start feat(subs): define interfaces and subpackages feat(subs): write individual patches feat: implement patch serialization feat: db structure for patches fix(subs): date use in patches fix: date use in subscription patches chore: uncomment methods fix: fix rebase issues feat(subs): subscription creation and patch saving feat: add entitlement annotations feat: write patch saving feat: subscriptionView feat: write db schema for patches feat(subs): write entity mappings for repository feat(subs): implement and test create and read feat: implement price test: write command and query builders test: subscription creation without customizations test(subs): test creation with customizations refactor(sub): marry command and query feat(subs): write syncing test: test entity syncing feat: test editing and fix rebase errors chore: generate migrations chore: remove dangling execs fix: use patch timestamp instead of operation timestamp for validations chore: remove dead code fix(lint): fix lint errors feat: incorporate new price types chore: undo me test(subs): service create and view tests feat(subs): define workflow service fix(subs): consolidate key and id use when linking things
1df72dc
to
0e7a9ea
Compare
…ts cadence relative to phase
Overview
Supersedes #1732
Includes internal service for subscription management.
Notes for reviewer
openmeter/subscriptions
is included in application startup.