Merge branch 'feature/account-expires-at' into main: feat: add account expires-at field and auto-pause expired accounts
This commit is contained in:
@@ -1006,6 +1006,8 @@ type AccountMutation struct {
|
||||
status *string
|
||||
error_message *string
|
||||
last_used_at *time.Time
|
||||
expires_at *time.Time
|
||||
auto_pause_on_expired *bool
|
||||
schedulable *bool
|
||||
rate_limited_at *time.Time
|
||||
rate_limit_reset_at *time.Time
|
||||
@@ -1770,6 +1772,91 @@ func (m *AccountMutation) ResetLastUsedAt() {
|
||||
delete(m.clearedFields, account.FieldLastUsedAt)
|
||||
}
|
||||
|
||||
// SetExpiresAt sets the "expires_at" field.
|
||||
func (m *AccountMutation) SetExpiresAt(t time.Time) {
|
||||
m.expires_at = &t
|
||||
}
|
||||
|
||||
// ExpiresAt returns the value of the "expires_at" field in the mutation.
|
||||
func (m *AccountMutation) ExpiresAt() (r time.Time, exists bool) {
|
||||
v := m.expires_at
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldExpiresAt returns the old "expires_at" field's value of the Account entity.
|
||||
// If the Account object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *AccountMutation) OldExpiresAt(ctx context.Context) (v *time.Time, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldExpiresAt requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
|
||||
}
|
||||
return oldValue.ExpiresAt, nil
|
||||
}
|
||||
|
||||
// ClearExpiresAt clears the value of the "expires_at" field.
|
||||
func (m *AccountMutation) ClearExpiresAt() {
|
||||
m.expires_at = nil
|
||||
m.clearedFields[account.FieldExpiresAt] = struct{}{}
|
||||
}
|
||||
|
||||
// ExpiresAtCleared returns if the "expires_at" field was cleared in this mutation.
|
||||
func (m *AccountMutation) ExpiresAtCleared() bool {
|
||||
_, ok := m.clearedFields[account.FieldExpiresAt]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetExpiresAt resets all changes to the "expires_at" field.
|
||||
func (m *AccountMutation) ResetExpiresAt() {
|
||||
m.expires_at = nil
|
||||
delete(m.clearedFields, account.FieldExpiresAt)
|
||||
}
|
||||
|
||||
// SetAutoPauseOnExpired sets the "auto_pause_on_expired" field.
|
||||
func (m *AccountMutation) SetAutoPauseOnExpired(b bool) {
|
||||
m.auto_pause_on_expired = &b
|
||||
}
|
||||
|
||||
// AutoPauseOnExpired returns the value of the "auto_pause_on_expired" field in the mutation.
|
||||
func (m *AccountMutation) AutoPauseOnExpired() (r bool, exists bool) {
|
||||
v := m.auto_pause_on_expired
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldAutoPauseOnExpired returns the old "auto_pause_on_expired" field's value of the Account entity.
|
||||
// If the Account object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *AccountMutation) OldAutoPauseOnExpired(ctx context.Context) (v bool, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldAutoPauseOnExpired is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldAutoPauseOnExpired requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldAutoPauseOnExpired: %w", err)
|
||||
}
|
||||
return oldValue.AutoPauseOnExpired, nil
|
||||
}
|
||||
|
||||
// ResetAutoPauseOnExpired resets all changes to the "auto_pause_on_expired" field.
|
||||
func (m *AccountMutation) ResetAutoPauseOnExpired() {
|
||||
m.auto_pause_on_expired = nil
|
||||
}
|
||||
|
||||
// SetSchedulable sets the "schedulable" field.
|
||||
func (m *AccountMutation) SetSchedulable(b bool) {
|
||||
m.schedulable = &b
|
||||
@@ -2269,7 +2356,7 @@ func (m *AccountMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *AccountMutation) Fields() []string {
|
||||
fields := make([]string, 0, 22)
|
||||
fields := make([]string, 0, 24)
|
||||
if m.created_at != nil {
|
||||
fields = append(fields, account.FieldCreatedAt)
|
||||
}
|
||||
@@ -2315,6 +2402,12 @@ func (m *AccountMutation) Fields() []string {
|
||||
if m.last_used_at != nil {
|
||||
fields = append(fields, account.FieldLastUsedAt)
|
||||
}
|
||||
if m.expires_at != nil {
|
||||
fields = append(fields, account.FieldExpiresAt)
|
||||
}
|
||||
if m.auto_pause_on_expired != nil {
|
||||
fields = append(fields, account.FieldAutoPauseOnExpired)
|
||||
}
|
||||
if m.schedulable != nil {
|
||||
fields = append(fields, account.FieldSchedulable)
|
||||
}
|
||||
@@ -2374,6 +2467,10 @@ func (m *AccountMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.ErrorMessage()
|
||||
case account.FieldLastUsedAt:
|
||||
return m.LastUsedAt()
|
||||
case account.FieldExpiresAt:
|
||||
return m.ExpiresAt()
|
||||
case account.FieldAutoPauseOnExpired:
|
||||
return m.AutoPauseOnExpired()
|
||||
case account.FieldSchedulable:
|
||||
return m.Schedulable()
|
||||
case account.FieldRateLimitedAt:
|
||||
@@ -2427,6 +2524,10 @@ func (m *AccountMutation) OldField(ctx context.Context, name string) (ent.Value,
|
||||
return m.OldErrorMessage(ctx)
|
||||
case account.FieldLastUsedAt:
|
||||
return m.OldLastUsedAt(ctx)
|
||||
case account.FieldExpiresAt:
|
||||
return m.OldExpiresAt(ctx)
|
||||
case account.FieldAutoPauseOnExpired:
|
||||
return m.OldAutoPauseOnExpired(ctx)
|
||||
case account.FieldSchedulable:
|
||||
return m.OldSchedulable(ctx)
|
||||
case account.FieldRateLimitedAt:
|
||||
@@ -2555,6 +2656,20 @@ func (m *AccountMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetLastUsedAt(v)
|
||||
return nil
|
||||
case account.FieldExpiresAt:
|
||||
v, ok := value.(time.Time)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetExpiresAt(v)
|
||||
return nil
|
||||
case account.FieldAutoPauseOnExpired:
|
||||
v, ok := value.(bool)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetAutoPauseOnExpired(v)
|
||||
return nil
|
||||
case account.FieldSchedulable:
|
||||
v, ok := value.(bool)
|
||||
if !ok {
|
||||
@@ -2676,6 +2791,9 @@ func (m *AccountMutation) ClearedFields() []string {
|
||||
if m.FieldCleared(account.FieldLastUsedAt) {
|
||||
fields = append(fields, account.FieldLastUsedAt)
|
||||
}
|
||||
if m.FieldCleared(account.FieldExpiresAt) {
|
||||
fields = append(fields, account.FieldExpiresAt)
|
||||
}
|
||||
if m.FieldCleared(account.FieldRateLimitedAt) {
|
||||
fields = append(fields, account.FieldRateLimitedAt)
|
||||
}
|
||||
@@ -2723,6 +2841,9 @@ func (m *AccountMutation) ClearField(name string) error {
|
||||
case account.FieldLastUsedAt:
|
||||
m.ClearLastUsedAt()
|
||||
return nil
|
||||
case account.FieldExpiresAt:
|
||||
m.ClearExpiresAt()
|
||||
return nil
|
||||
case account.FieldRateLimitedAt:
|
||||
m.ClearRateLimitedAt()
|
||||
return nil
|
||||
@@ -2794,6 +2915,12 @@ func (m *AccountMutation) ResetField(name string) error {
|
||||
case account.FieldLastUsedAt:
|
||||
m.ResetLastUsedAt()
|
||||
return nil
|
||||
case account.FieldExpiresAt:
|
||||
m.ResetExpiresAt()
|
||||
return nil
|
||||
case account.FieldAutoPauseOnExpired:
|
||||
m.ResetAutoPauseOnExpired()
|
||||
return nil
|
||||
case account.FieldSchedulable:
|
||||
m.ResetSchedulable()
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user