feat: support download client priority

This commit is contained in:
Simon Ding
2024-10-04 11:12:06 +08:00
parent 7dfa4eafc4
commit 3af5f96cb0
13 changed files with 172 additions and 155 deletions

View File

@@ -30,8 +30,8 @@ type DownloadClients struct {
Password string `json:"password,omitempty"`
// Settings holds the value of the "settings" field.
Settings string `json:"settings,omitempty"`
// Ordering holds the value of the "ordering" field.
Ordering int `json:"ordering,omitempty"`
// Priority1 holds the value of the "priority1" field.
Priority1 int `json:"priority1,omitempty"`
// RemoveCompletedDownloads holds the value of the "remove_completed_downloads" field.
RemoveCompletedDownloads bool `json:"remove_completed_downloads,omitempty"`
// RemoveFailedDownloads holds the value of the "remove_failed_downloads" field.
@@ -48,7 +48,7 @@ func (*DownloadClients) scanValues(columns []string) ([]any, error) {
switch columns[i] {
case downloadclients.FieldEnable, downloadclients.FieldRemoveCompletedDownloads, downloadclients.FieldRemoveFailedDownloads:
values[i] = new(sql.NullBool)
case downloadclients.FieldID, downloadclients.FieldOrdering:
case downloadclients.FieldID, downloadclients.FieldPriority1:
values[i] = new(sql.NullInt64)
case downloadclients.FieldName, downloadclients.FieldImplementation, downloadclients.FieldURL, downloadclients.FieldUser, downloadclients.FieldPassword, downloadclients.FieldSettings, downloadclients.FieldTags:
values[i] = new(sql.NullString)
@@ -115,11 +115,11 @@ func (dc *DownloadClients) assignValues(columns []string, values []any) error {
} else if value.Valid {
dc.Settings = value.String
}
case downloadclients.FieldOrdering:
case downloadclients.FieldPriority1:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field ordering", values[i])
return fmt.Errorf("unexpected type %T for field priority1", values[i])
} else if value.Valid {
dc.Ordering = int(value.Int64)
dc.Priority1 = int(value.Int64)
}
case downloadclients.FieldRemoveCompletedDownloads:
if value, ok := values[i].(*sql.NullBool); !ok {
@@ -196,8 +196,8 @@ func (dc *DownloadClients) String() string {
builder.WriteString("settings=")
builder.WriteString(dc.Settings)
builder.WriteString(", ")
builder.WriteString("ordering=")
builder.WriteString(fmt.Sprintf("%v", dc.Ordering))
builder.WriteString("priority1=")
builder.WriteString(fmt.Sprintf("%v", dc.Priority1))
builder.WriteString(", ")
builder.WriteString("remove_completed_downloads=")
builder.WriteString(fmt.Sprintf("%v", dc.RemoveCompletedDownloads))

View File

@@ -27,8 +27,8 @@ const (
FieldPassword = "password"
// FieldSettings holds the string denoting the settings field in the database.
FieldSettings = "settings"
// FieldOrdering holds the string denoting the ordering field in the database.
FieldOrdering = "ordering"
// FieldPriority1 holds the string denoting the priority1 field in the database.
FieldPriority1 = "priority1"
// FieldRemoveCompletedDownloads holds the string denoting the remove_completed_downloads field in the database.
FieldRemoveCompletedDownloads = "remove_completed_downloads"
// FieldRemoveFailedDownloads holds the string denoting the remove_failed_downloads field in the database.
@@ -49,7 +49,7 @@ var Columns = []string{
FieldUser,
FieldPassword,
FieldSettings,
FieldOrdering,
FieldPriority1,
FieldRemoveCompletedDownloads,
FieldRemoveFailedDownloads,
FieldTags,
@@ -72,10 +72,10 @@ var (
DefaultPassword string
// DefaultSettings holds the default value on creation for the "settings" field.
DefaultSettings string
// DefaultOrdering holds the default value on creation for the "ordering" field.
DefaultOrdering int
// OrderingValidator is a validator for the "ordering" field. It is called by the builders before save.
OrderingValidator func(int) error
// DefaultPriority1 holds the default value on creation for the "priority1" field.
DefaultPriority1 int
// Priority1Validator is a validator for the "priority1" field. It is called by the builders before save.
Priority1Validator func(int) error
// DefaultRemoveCompletedDownloads holds the default value on creation for the "remove_completed_downloads" field.
DefaultRemoveCompletedDownloads bool
// DefaultRemoveFailedDownloads holds the default value on creation for the "remove_failed_downloads" field.
@@ -150,9 +150,9 @@ func BySettings(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSettings, opts...).ToFunc()
}
// ByOrdering orders the results by the ordering field.
func ByOrdering(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOrdering, opts...).ToFunc()
// ByPriority1 orders the results by the priority1 field.
func ByPriority1(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPriority1, opts...).ToFunc()
}
// ByRemoveCompletedDownloads orders the results by the remove_completed_downloads field.

View File

@@ -83,9 +83,9 @@ func Settings(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldSettings, v))
}
// Ordering applies equality check predicate on the "ordering" field. It's identical to OrderingEQ.
func Ordering(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldOrdering, v))
// Priority1 applies equality check predicate on the "priority1" field. It's identical to Priority1EQ.
func Priority1(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldPriority1, v))
}
// RemoveCompletedDownloads applies equality check predicate on the "remove_completed_downloads" field. It's identical to RemoveCompletedDownloadsEQ.
@@ -458,44 +458,44 @@ func SettingsContainsFold(v string) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldContainsFold(FieldSettings, v))
}
// OrderingEQ applies the EQ predicate on the "ordering" field.
func OrderingEQ(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldOrdering, v))
// Priority1EQ applies the EQ predicate on the "priority1" field.
func Priority1EQ(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldEQ(FieldPriority1, v))
}
// OrderingNEQ applies the NEQ predicate on the "ordering" field.
func OrderingNEQ(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNEQ(FieldOrdering, v))
// Priority1NEQ applies the NEQ predicate on the "priority1" field.
func Priority1NEQ(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNEQ(FieldPriority1, v))
}
// OrderingIn applies the In predicate on the "ordering" field.
func OrderingIn(vs ...int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldIn(FieldOrdering, vs...))
// Priority1In applies the In predicate on the "priority1" field.
func Priority1In(vs ...int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldIn(FieldPriority1, vs...))
}
// OrderingNotIn applies the NotIn predicate on the "ordering" field.
func OrderingNotIn(vs ...int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNotIn(FieldOrdering, vs...))
// Priority1NotIn applies the NotIn predicate on the "priority1" field.
func Priority1NotIn(vs ...int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldNotIn(FieldPriority1, vs...))
}
// OrderingGT applies the GT predicate on the "ordering" field.
func OrderingGT(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldGT(FieldOrdering, v))
// Priority1GT applies the GT predicate on the "priority1" field.
func Priority1GT(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldGT(FieldPriority1, v))
}
// OrderingGTE applies the GTE predicate on the "ordering" field.
func OrderingGTE(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldGTE(FieldOrdering, v))
// Priority1GTE applies the GTE predicate on the "priority1" field.
func Priority1GTE(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldGTE(FieldPriority1, v))
}
// OrderingLT applies the LT predicate on the "ordering" field.
func OrderingLT(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldLT(FieldOrdering, v))
// Priority1LT applies the LT predicate on the "priority1" field.
func Priority1LT(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldLT(FieldPriority1, v))
}
// OrderingLTE applies the LTE predicate on the "ordering" field.
func OrderingLTE(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldLTE(FieldOrdering, v))
// Priority1LTE applies the LTE predicate on the "priority1" field.
func Priority1LTE(v int) predicate.DownloadClients {
return predicate.DownloadClients(sql.FieldLTE(FieldPriority1, v))
}
// RemoveCompletedDownloadsEQ applies the EQ predicate on the "remove_completed_downloads" field.

View File

@@ -85,16 +85,16 @@ func (dcc *DownloadClientsCreate) SetNillableSettings(s *string) *DownloadClient
return dcc
}
// SetOrdering sets the "ordering" field.
func (dcc *DownloadClientsCreate) SetOrdering(i int) *DownloadClientsCreate {
dcc.mutation.SetOrdering(i)
// SetPriority1 sets the "priority1" field.
func (dcc *DownloadClientsCreate) SetPriority1(i int) *DownloadClientsCreate {
dcc.mutation.SetPriority1(i)
return dcc
}
// SetNillableOrdering sets the "ordering" field if the given value is not nil.
func (dcc *DownloadClientsCreate) SetNillableOrdering(i *int) *DownloadClientsCreate {
// SetNillablePriority1 sets the "priority1" field if the given value is not nil.
func (dcc *DownloadClientsCreate) SetNillablePriority1(i *int) *DownloadClientsCreate {
if i != nil {
dcc.SetOrdering(*i)
dcc.SetPriority1(*i)
}
return dcc
}
@@ -188,9 +188,9 @@ func (dcc *DownloadClientsCreate) defaults() {
v := downloadclients.DefaultSettings
dcc.mutation.SetSettings(v)
}
if _, ok := dcc.mutation.Ordering(); !ok {
v := downloadclients.DefaultOrdering
dcc.mutation.SetOrdering(v)
if _, ok := dcc.mutation.Priority1(); !ok {
v := downloadclients.DefaultPriority1
dcc.mutation.SetPriority1(v)
}
if _, ok := dcc.mutation.RemoveCompletedDownloads(); !ok {
v := downloadclients.DefaultRemoveCompletedDownloads
@@ -234,12 +234,12 @@ func (dcc *DownloadClientsCreate) check() error {
if _, ok := dcc.mutation.Settings(); !ok {
return &ValidationError{Name: "settings", err: errors.New(`ent: missing required field "DownloadClients.settings"`)}
}
if _, ok := dcc.mutation.Ordering(); !ok {
return &ValidationError{Name: "ordering", err: errors.New(`ent: missing required field "DownloadClients.ordering"`)}
if _, ok := dcc.mutation.Priority1(); !ok {
return &ValidationError{Name: "priority1", err: errors.New(`ent: missing required field "DownloadClients.priority1"`)}
}
if v, ok := dcc.mutation.Ordering(); ok {
if err := downloadclients.OrderingValidator(v); err != nil {
return &ValidationError{Name: "ordering", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.ordering": %w`, err)}
if v, ok := dcc.mutation.Priority1(); ok {
if err := downloadclients.Priority1Validator(v); err != nil {
return &ValidationError{Name: "priority1", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.priority1": %w`, err)}
}
}
if _, ok := dcc.mutation.RemoveCompletedDownloads(); !ok {
@@ -305,9 +305,9 @@ func (dcc *DownloadClientsCreate) createSpec() (*DownloadClients, *sqlgraph.Crea
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
_node.Settings = value
}
if value, ok := dcc.mutation.Ordering(); ok {
_spec.SetField(downloadclients.FieldOrdering, field.TypeInt, value)
_node.Ordering = value
if value, ok := dcc.mutation.Priority1(); ok {
_spec.SetField(downloadclients.FieldPriority1, field.TypeInt, value)
_node.Priority1 = value
}
if value, ok := dcc.mutation.RemoveCompletedDownloads(); ok {
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)

View File

@@ -125,24 +125,24 @@ func (dcu *DownloadClientsUpdate) SetNillableSettings(s *string) *DownloadClient
return dcu
}
// SetOrdering sets the "ordering" field.
func (dcu *DownloadClientsUpdate) SetOrdering(i int) *DownloadClientsUpdate {
dcu.mutation.ResetOrdering()
dcu.mutation.SetOrdering(i)
// SetPriority1 sets the "priority1" field.
func (dcu *DownloadClientsUpdate) SetPriority1(i int) *DownloadClientsUpdate {
dcu.mutation.ResetPriority1()
dcu.mutation.SetPriority1(i)
return dcu
}
// SetNillableOrdering sets the "ordering" field if the given value is not nil.
func (dcu *DownloadClientsUpdate) SetNillableOrdering(i *int) *DownloadClientsUpdate {
// SetNillablePriority1 sets the "priority1" field if the given value is not nil.
func (dcu *DownloadClientsUpdate) SetNillablePriority1(i *int) *DownloadClientsUpdate {
if i != nil {
dcu.SetOrdering(*i)
dcu.SetPriority1(*i)
}
return dcu
}
// AddOrdering adds i to the "ordering" field.
func (dcu *DownloadClientsUpdate) AddOrdering(i int) *DownloadClientsUpdate {
dcu.mutation.AddOrdering(i)
// AddPriority1 adds i to the "priority1" field.
func (dcu *DownloadClientsUpdate) AddPriority1(i int) *DownloadClientsUpdate {
dcu.mutation.AddPriority1(i)
return dcu
}
@@ -227,9 +227,9 @@ func (dcu *DownloadClientsUpdate) check() error {
return &ValidationError{Name: "implementation", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.implementation": %w`, err)}
}
}
if v, ok := dcu.mutation.Ordering(); ok {
if err := downloadclients.OrderingValidator(v); err != nil {
return &ValidationError{Name: "ordering", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.ordering": %w`, err)}
if v, ok := dcu.mutation.Priority1(); ok {
if err := downloadclients.Priority1Validator(v); err != nil {
return &ValidationError{Name: "priority1", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.priority1": %w`, err)}
}
}
return nil
@@ -268,11 +268,11 @@ func (dcu *DownloadClientsUpdate) sqlSave(ctx context.Context) (n int, err error
if value, ok := dcu.mutation.Settings(); ok {
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
}
if value, ok := dcu.mutation.Ordering(); ok {
_spec.SetField(downloadclients.FieldOrdering, field.TypeInt, value)
if value, ok := dcu.mutation.Priority1(); ok {
_spec.SetField(downloadclients.FieldPriority1, field.TypeInt, value)
}
if value, ok := dcu.mutation.AddedOrdering(); ok {
_spec.AddField(downloadclients.FieldOrdering, field.TypeInt, value)
if value, ok := dcu.mutation.AddedPriority1(); ok {
_spec.AddField(downloadclients.FieldPriority1, field.TypeInt, value)
}
if value, ok := dcu.mutation.RemoveCompletedDownloads(); ok {
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
@@ -401,24 +401,24 @@ func (dcuo *DownloadClientsUpdateOne) SetNillableSettings(s *string) *DownloadCl
return dcuo
}
// SetOrdering sets the "ordering" field.
func (dcuo *DownloadClientsUpdateOne) SetOrdering(i int) *DownloadClientsUpdateOne {
dcuo.mutation.ResetOrdering()
dcuo.mutation.SetOrdering(i)
// SetPriority1 sets the "priority1" field.
func (dcuo *DownloadClientsUpdateOne) SetPriority1(i int) *DownloadClientsUpdateOne {
dcuo.mutation.ResetPriority1()
dcuo.mutation.SetPriority1(i)
return dcuo
}
// SetNillableOrdering sets the "ordering" field if the given value is not nil.
func (dcuo *DownloadClientsUpdateOne) SetNillableOrdering(i *int) *DownloadClientsUpdateOne {
// SetNillablePriority1 sets the "priority1" field if the given value is not nil.
func (dcuo *DownloadClientsUpdateOne) SetNillablePriority1(i *int) *DownloadClientsUpdateOne {
if i != nil {
dcuo.SetOrdering(*i)
dcuo.SetPriority1(*i)
}
return dcuo
}
// AddOrdering adds i to the "ordering" field.
func (dcuo *DownloadClientsUpdateOne) AddOrdering(i int) *DownloadClientsUpdateOne {
dcuo.mutation.AddOrdering(i)
// AddPriority1 adds i to the "priority1" field.
func (dcuo *DownloadClientsUpdateOne) AddPriority1(i int) *DownloadClientsUpdateOne {
dcuo.mutation.AddPriority1(i)
return dcuo
}
@@ -516,9 +516,9 @@ func (dcuo *DownloadClientsUpdateOne) check() error {
return &ValidationError{Name: "implementation", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.implementation": %w`, err)}
}
}
if v, ok := dcuo.mutation.Ordering(); ok {
if err := downloadclients.OrderingValidator(v); err != nil {
return &ValidationError{Name: "ordering", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.ordering": %w`, err)}
if v, ok := dcuo.mutation.Priority1(); ok {
if err := downloadclients.Priority1Validator(v); err != nil {
return &ValidationError{Name: "priority1", err: fmt.Errorf(`ent: validator failed for field "DownloadClients.priority1": %w`, err)}
}
}
return nil
@@ -574,11 +574,11 @@ func (dcuo *DownloadClientsUpdateOne) sqlSave(ctx context.Context) (_node *Downl
if value, ok := dcuo.mutation.Settings(); ok {
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
}
if value, ok := dcuo.mutation.Ordering(); ok {
_spec.SetField(downloadclients.FieldOrdering, field.TypeInt, value)
if value, ok := dcuo.mutation.Priority1(); ok {
_spec.SetField(downloadclients.FieldPriority1, field.TypeInt, value)
}
if value, ok := dcuo.mutation.AddedOrdering(); ok {
_spec.AddField(downloadclients.FieldOrdering, field.TypeInt, value)
if value, ok := dcuo.mutation.AddedPriority1(); ok {
_spec.AddField(downloadclients.FieldPriority1, field.TypeInt, value)
}
if value, ok := dcuo.mutation.RemoveCompletedDownloads(); ok {
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)

View File

@@ -30,7 +30,7 @@ var (
{Name: "user", Type: field.TypeString, Default: ""},
{Name: "password", Type: field.TypeString, Default: ""},
{Name: "settings", Type: field.TypeString, Default: ""},
{Name: "ordering", Type: field.TypeInt, Default: 1},
{Name: "priority1", Type: field.TypeInt, Default: 1},
{Name: "remove_completed_downloads", Type: field.TypeBool, Default: true},
{Name: "remove_failed_downloads", Type: field.TypeBool, Default: true},
{Name: "tags", Type: field.TypeString, Default: ""},

View File

@@ -439,8 +439,8 @@ type DownloadClientsMutation struct {
user *string
password *string
settings *string
ordering *int
addordering *int
priority1 *int
addpriority1 *int
remove_completed_downloads *bool
remove_failed_downloads *bool
tags *string
@@ -800,60 +800,60 @@ func (m *DownloadClientsMutation) ResetSettings() {
m.settings = nil
}
// SetOrdering sets the "ordering" field.
func (m *DownloadClientsMutation) SetOrdering(i int) {
m.ordering = &i
m.addordering = nil
// SetPriority1 sets the "priority1" field.
func (m *DownloadClientsMutation) SetPriority1(i int) {
m.priority1 = &i
m.addpriority1 = nil
}
// Ordering returns the value of the "ordering" field in the mutation.
func (m *DownloadClientsMutation) Ordering() (r int, exists bool) {
v := m.ordering
// Priority1 returns the value of the "priority1" field in the mutation.
func (m *DownloadClientsMutation) Priority1() (r int, exists bool) {
v := m.priority1
if v == nil {
return
}
return *v, true
}
// OldOrdering returns the old "ordering" field's value of the DownloadClients entity.
// OldPriority1 returns the old "priority1" field's value of the DownloadClients entity.
// If the DownloadClients 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 *DownloadClientsMutation) OldOrdering(ctx context.Context) (v int, err error) {
func (m *DownloadClientsMutation) OldPriority1(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldOrdering is only allowed on UpdateOne operations")
return v, errors.New("OldPriority1 is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldOrdering requires an ID field in the mutation")
return v, errors.New("OldPriority1 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOrdering: %w", err)
return v, fmt.Errorf("querying old value for OldPriority1: %w", err)
}
return oldValue.Ordering, nil
return oldValue.Priority1, nil
}
// AddOrdering adds i to the "ordering" field.
func (m *DownloadClientsMutation) AddOrdering(i int) {
if m.addordering != nil {
*m.addordering += i
// AddPriority1 adds i to the "priority1" field.
func (m *DownloadClientsMutation) AddPriority1(i int) {
if m.addpriority1 != nil {
*m.addpriority1 += i
} else {
m.addordering = &i
m.addpriority1 = &i
}
}
// AddedOrdering returns the value that was added to the "ordering" field in this mutation.
func (m *DownloadClientsMutation) AddedOrdering() (r int, exists bool) {
v := m.addordering
// AddedPriority1 returns the value that was added to the "priority1" field in this mutation.
func (m *DownloadClientsMutation) AddedPriority1() (r int, exists bool) {
v := m.addpriority1
if v == nil {
return
}
return *v, true
}
// ResetOrdering resets all changes to the "ordering" field.
func (m *DownloadClientsMutation) ResetOrdering() {
m.ordering = nil
m.addordering = nil
// ResetPriority1 resets all changes to the "priority1" field.
func (m *DownloadClientsMutation) ResetPriority1() {
m.priority1 = nil
m.addpriority1 = nil
}
// SetRemoveCompletedDownloads sets the "remove_completed_downloads" field.
@@ -1020,8 +1020,8 @@ func (m *DownloadClientsMutation) Fields() []string {
if m.settings != nil {
fields = append(fields, downloadclients.FieldSettings)
}
if m.ordering != nil {
fields = append(fields, downloadclients.FieldOrdering)
if m.priority1 != nil {
fields = append(fields, downloadclients.FieldPriority1)
}
if m.remove_completed_downloads != nil {
fields = append(fields, downloadclients.FieldRemoveCompletedDownloads)
@@ -1054,8 +1054,8 @@ func (m *DownloadClientsMutation) Field(name string) (ent.Value, bool) {
return m.Password()
case downloadclients.FieldSettings:
return m.Settings()
case downloadclients.FieldOrdering:
return m.Ordering()
case downloadclients.FieldPriority1:
return m.Priority1()
case downloadclients.FieldRemoveCompletedDownloads:
return m.RemoveCompletedDownloads()
case downloadclients.FieldRemoveFailedDownloads:
@@ -1085,8 +1085,8 @@ func (m *DownloadClientsMutation) OldField(ctx context.Context, name string) (en
return m.OldPassword(ctx)
case downloadclients.FieldSettings:
return m.OldSettings(ctx)
case downloadclients.FieldOrdering:
return m.OldOrdering(ctx)
case downloadclients.FieldPriority1:
return m.OldPriority1(ctx)
case downloadclients.FieldRemoveCompletedDownloads:
return m.OldRemoveCompletedDownloads(ctx)
case downloadclients.FieldRemoveFailedDownloads:
@@ -1151,12 +1151,12 @@ func (m *DownloadClientsMutation) SetField(name string, value ent.Value) error {
}
m.SetSettings(v)
return nil
case downloadclients.FieldOrdering:
case downloadclients.FieldPriority1:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOrdering(v)
m.SetPriority1(v)
return nil
case downloadclients.FieldRemoveCompletedDownloads:
v, ok := value.(bool)
@@ -1187,8 +1187,8 @@ func (m *DownloadClientsMutation) SetField(name string, value ent.Value) error {
// this mutation.
func (m *DownloadClientsMutation) AddedFields() []string {
var fields []string
if m.addordering != nil {
fields = append(fields, downloadclients.FieldOrdering)
if m.addpriority1 != nil {
fields = append(fields, downloadclients.FieldPriority1)
}
return fields
}
@@ -1198,8 +1198,8 @@ func (m *DownloadClientsMutation) AddedFields() []string {
// was not set, or was not defined in the schema.
func (m *DownloadClientsMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case downloadclients.FieldOrdering:
return m.AddedOrdering()
case downloadclients.FieldPriority1:
return m.AddedPriority1()
}
return nil, false
}
@@ -1209,12 +1209,12 @@ func (m *DownloadClientsMutation) AddedField(name string) (ent.Value, bool) {
// type.
func (m *DownloadClientsMutation) AddField(name string, value ent.Value) error {
switch name {
case downloadclients.FieldOrdering:
case downloadclients.FieldPriority1:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddOrdering(v)
m.AddPriority1(v)
return nil
}
return fmt.Errorf("unknown DownloadClients numeric field %s", name)
@@ -1264,8 +1264,8 @@ func (m *DownloadClientsMutation) ResetField(name string) error {
case downloadclients.FieldSettings:
m.ResetSettings()
return nil
case downloadclients.FieldOrdering:
m.ResetOrdering()
case downloadclients.FieldPriority1:
m.ResetPriority1()
return nil
case downloadclients.FieldRemoveCompletedDownloads:
m.ResetRemoveCompletedDownloads()

View File

@@ -32,12 +32,12 @@ func init() {
downloadclientsDescSettings := downloadclientsFields[6].Descriptor()
// downloadclients.DefaultSettings holds the default value on creation for the settings field.
downloadclients.DefaultSettings = downloadclientsDescSettings.Default.(string)
// downloadclientsDescOrdering is the schema descriptor for ordering field.
downloadclientsDescOrdering := downloadclientsFields[7].Descriptor()
// downloadclients.DefaultOrdering holds the default value on creation for the ordering field.
downloadclients.DefaultOrdering = downloadclientsDescOrdering.Default.(int)
// downloadclients.OrderingValidator is a validator for the "ordering" field. It is called by the builders before save.
downloadclients.OrderingValidator = downloadclientsDescOrdering.Validators[0].(func(int) error)
// downloadclientsDescPriority1 is the schema descriptor for priority1 field.
downloadclientsDescPriority1 := downloadclientsFields[7].Descriptor()
// downloadclients.DefaultPriority1 holds the default value on creation for the priority1 field.
downloadclients.DefaultPriority1 = downloadclientsDescPriority1.Default.(int)
// downloadclients.Priority1Validator is a validator for the "priority1" field. It is called by the builders before save.
downloadclients.Priority1Validator = downloadclientsDescPriority1.Validators[0].(func(int) error)
// downloadclientsDescRemoveCompletedDownloads is the schema descriptor for remove_completed_downloads field.
downloadclientsDescRemoveCompletedDownloads := downloadclientsFields[8].Descriptor()
// downloadclients.DefaultRemoveCompletedDownloads holds the default value on creation for the remove_completed_downloads field.

View File

@@ -22,7 +22,7 @@ func (DownloadClients) Fields() []ent.Field {
field.String("user").Default(""),
field.String("password").Default(""),
field.String("settings").Default(""),
field.Int("ordering").Default(1).Validate(func(i int) error {
field.Int("priority1").Default(1).Validate(func(i int) error {
if i > 50 {
return errors.ErrUnsupported
}