mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-09 03:27:39 +08:00
feat: improve indexer setting
This commit is contained in:
@@ -21,6 +21,10 @@ const (
|
||||
FieldEnableRss = "enable_rss"
|
||||
// FieldPriority holds the string denoting the priority field in the database.
|
||||
FieldPriority = "priority"
|
||||
// FieldSeedRatio holds the string denoting the seed_ratio field in the database.
|
||||
FieldSeedRatio = "seed_ratio"
|
||||
// FieldDisabled holds the string denoting the disabled field in the database.
|
||||
FieldDisabled = "disabled"
|
||||
// Table holds the table name of the indexers in the database.
|
||||
Table = "indexers"
|
||||
)
|
||||
@@ -33,6 +37,8 @@ var Columns = []string{
|
||||
FieldSettings,
|
||||
FieldEnableRss,
|
||||
FieldPriority,
|
||||
FieldSeedRatio,
|
||||
FieldDisabled,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -48,6 +54,12 @@ func ValidColumn(column string) bool {
|
||||
var (
|
||||
// DefaultEnableRss holds the default value on creation for the "enable_rss" field.
|
||||
DefaultEnableRss bool
|
||||
// DefaultPriority holds the default value on creation for the "priority" field.
|
||||
DefaultPriority int
|
||||
// DefaultSeedRatio holds the default value on creation for the "seed_ratio" field.
|
||||
DefaultSeedRatio float32
|
||||
// DefaultDisabled holds the default value on creation for the "disabled" field.
|
||||
DefaultDisabled bool
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Indexers queries.
|
||||
@@ -82,3 +94,13 @@ func ByEnableRss(opts ...sql.OrderTermOption) OrderOption {
|
||||
func ByPriority(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPriority, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySeedRatio orders the results by the seed_ratio field.
|
||||
func BySeedRatio(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSeedRatio, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByDisabled orders the results by the disabled field.
|
||||
func ByDisabled(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldDisabled, opts...).ToFunc()
|
||||
}
|
||||
|
||||
@@ -78,6 +78,16 @@ func Priority(v int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldPriority, v))
|
||||
}
|
||||
|
||||
// SeedRatio applies equality check predicate on the "seed_ratio" field. It's identical to SeedRatioEQ.
|
||||
func SeedRatio(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// Disabled applies equality check predicate on the "disabled" field. It's identical to DisabledEQ.
|
||||
func Disabled(v bool) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldDisabled, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldName, v))
|
||||
@@ -323,6 +333,76 @@ func PriorityLTE(v int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLTE(FieldPriority, v))
|
||||
}
|
||||
|
||||
// SeedRatioEQ applies the EQ predicate on the "seed_ratio" field.
|
||||
func SeedRatioEQ(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// SeedRatioNEQ applies the NEQ predicate on the "seed_ratio" field.
|
||||
func SeedRatioNEQ(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNEQ(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// SeedRatioIn applies the In predicate on the "seed_ratio" field.
|
||||
func SeedRatioIn(vs ...float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldIn(FieldSeedRatio, vs...))
|
||||
}
|
||||
|
||||
// SeedRatioNotIn applies the NotIn predicate on the "seed_ratio" field.
|
||||
func SeedRatioNotIn(vs ...float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotIn(FieldSeedRatio, vs...))
|
||||
}
|
||||
|
||||
// SeedRatioGT applies the GT predicate on the "seed_ratio" field.
|
||||
func SeedRatioGT(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGT(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// SeedRatioGTE applies the GTE predicate on the "seed_ratio" field.
|
||||
func SeedRatioGTE(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGTE(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// SeedRatioLT applies the LT predicate on the "seed_ratio" field.
|
||||
func SeedRatioLT(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLT(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// SeedRatioLTE applies the LTE predicate on the "seed_ratio" field.
|
||||
func SeedRatioLTE(v float32) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLTE(FieldSeedRatio, v))
|
||||
}
|
||||
|
||||
// SeedRatioIsNil applies the IsNil predicate on the "seed_ratio" field.
|
||||
func SeedRatioIsNil() predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldIsNull(FieldSeedRatio))
|
||||
}
|
||||
|
||||
// SeedRatioNotNil applies the NotNil predicate on the "seed_ratio" field.
|
||||
func SeedRatioNotNil() predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotNull(FieldSeedRatio))
|
||||
}
|
||||
|
||||
// DisabledEQ applies the EQ predicate on the "disabled" field.
|
||||
func DisabledEQ(v bool) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldDisabled, v))
|
||||
}
|
||||
|
||||
// DisabledNEQ applies the NEQ predicate on the "disabled" field.
|
||||
func DisabledNEQ(v bool) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNEQ(FieldDisabled, v))
|
||||
}
|
||||
|
||||
// DisabledIsNil applies the IsNil predicate on the "disabled" field.
|
||||
func DisabledIsNil() predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldIsNull(FieldDisabled))
|
||||
}
|
||||
|
||||
// DisabledNotNil applies the NotNil predicate on the "disabled" field.
|
||||
func DisabledNotNil() predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotNull(FieldDisabled))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Indexers) predicate.Indexers {
|
||||
return predicate.Indexers(sql.AndPredicates(predicates...))
|
||||
|
||||
Reference in New Issue
Block a user