diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml index a9cf349937..bb5cf692bc 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-ci.yml @@ -20,7 +20,7 @@ jobs: cache-dependency-path: backend/go.sum - name: Verify Go version run: | - go version | grep -q 'go1.26.4' + go version | grep -q 'go1.26.5' - name: Unit tests working-directory: backend run: make test-unit @@ -60,7 +60,7 @@ jobs: cache-dependency-path: backend/go.sum - name: Verify Go version run: | - go version | grep -q 'go1.26.4' + go version | grep -q 'go1.26.5' - name: golangci-lint uses: golangci/golangci-lint-action@v9 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8c5dcfbfa..2ba01833c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -115,7 +115,7 @@ jobs: - name: Verify Go version run: | - go version | grep -q 'go1.26.4' + go version | grep -q 'go1.26.5' # Docker setup for GoReleaser - name: Set up QEMU diff --git a/.github/workflows/security-scan.yml b/.github/workflows/security-scan.yml index ab3305ab6e..96a7ae4edd 100644 --- a/.github/workflows/security-scan.yml +++ b/.github/workflows/security-scan.yml @@ -23,7 +23,7 @@ jobs: cache-dependency-path: backend/go.sum - name: Verify Go version run: | - go version | grep -q 'go1.26.4' + go version | grep -q 'go1.26.5' - name: Run govulncheck working-directory: backend run: | diff --git a/Dockerfile b/Dockerfile index 13a6b8700d..17b631d5a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ # ============================================================================= ARG NODE_IMAGE=node:24-alpine -ARG GOLANG_IMAGE=golang:1.26.4-alpine +ARG GOLANG_IMAGE=golang:1.26.5-alpine ARG ALPINE_IMAGE=alpine:3.21 ARG POSTGRES_IMAGE=postgres:18-alpine ARG GOPROXY=https://goproxy.cn,direct diff --git a/backend/Dockerfile b/backend/Dockerfile index d4adb5564b..9976abe46b 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.26.4-alpine +FROM golang:1.26.5-alpine WORKDIR /app diff --git a/backend/ent/group.go b/backend/ent/group.go index 2a0eb4d3ac..5bec594977 100644 --- a/backend/ent/group.go +++ b/backend/ent/group.go @@ -73,6 +73,16 @@ type Group struct { BatchImageDiscountMultiplier float64 `json:"batch_image_discount_multiplier,omitempty"` // 批量图片生成冻结价格比例,按普通生图原价乘以该比例冻结,结算后释放差额 BatchImageHoldMultiplier float64 `json:"batch_image_hold_multiplier,omitempty"` + // 视频生成是否使用独立倍率;false 表示共享分组有效倍率 + VideoRateIndependent bool `json:"video_rate_independent,omitempty"` + // 视频生成独立倍率,仅 video_rate_independent=true 时生效 + VideoRateMultiplier float64 `json:"video_rate_multiplier,omitempty"` + // VideoPrice480p holds the value of the "video_price_480p" field. + VideoPrice480p *float64 `json:"video_price_480p,omitempty"` + // VideoPrice720p holds the value of the "video_price_720p" field. + VideoPrice720p *float64 `json:"video_price_720p,omitempty"` + // VideoPrice1080p holds the value of the "video_price_1080p" field. + VideoPrice1080p *float64 `json:"video_price_1080p,omitempty"` // 是否仅允许 Claude Code 客户端 ClaudeCodeOnly bool `json:"claude_code_only,omitempty"` // 非 Claude Code 请求降级使用的分组 ID @@ -211,9 +221,9 @@ func (*Group) scanValues(columns []string) ([]any, error) { switch columns[i] { case group.FieldModelRouting, group.FieldSupportedModelScopes, group.FieldMessagesDispatchModelConfig, group.FieldModelsListConfig: values[i] = new([]byte) - case group.FieldPeakRateEnabled, group.FieldIsExclusive, group.FieldAllowImageGeneration, group.FieldAllowBatchImageGeneration, group.FieldImageRateIndependent, group.FieldClaudeCodeOnly, group.FieldModelRoutingEnabled, group.FieldMcpXMLInject, group.FieldAllowMessagesDispatch, group.FieldRequireOauthOnly, group.FieldRequirePrivacySet: + case group.FieldPeakRateEnabled, group.FieldIsExclusive, group.FieldAllowImageGeneration, group.FieldAllowBatchImageGeneration, group.FieldImageRateIndependent, group.FieldVideoRateIndependent, group.FieldClaudeCodeOnly, group.FieldModelRoutingEnabled, group.FieldMcpXMLInject, group.FieldAllowMessagesDispatch, group.FieldRequireOauthOnly, group.FieldRequirePrivacySet: values[i] = new(sql.NullBool) - case group.FieldRateMultiplier, group.FieldPeakRateMultiplier, group.FieldDailyLimitUsd, group.FieldWeeklyLimitUsd, group.FieldMonthlyLimitUsd, group.FieldImageRateMultiplier, group.FieldImagePrice1k, group.FieldImagePrice2k, group.FieldImagePrice4k, group.FieldBatchImageDiscountMultiplier, group.FieldBatchImageHoldMultiplier: + case group.FieldRateMultiplier, group.FieldPeakRateMultiplier, group.FieldDailyLimitUsd, group.FieldWeeklyLimitUsd, group.FieldMonthlyLimitUsd, group.FieldImageRateMultiplier, group.FieldImagePrice1k, group.FieldImagePrice2k, group.FieldImagePrice4k, group.FieldBatchImageDiscountMultiplier, group.FieldBatchImageHoldMultiplier, group.FieldVideoRateMultiplier, group.FieldVideoPrice480p, group.FieldVideoPrice720p, group.FieldVideoPrice1080p: values[i] = new(sql.NullFloat64) case group.FieldID, group.FieldDefaultValidityDays, group.FieldFallbackGroupID, group.FieldFallbackGroupIDOnInvalidRequest, group.FieldSortOrder, group.FieldRpmLimit: values[i] = new(sql.NullInt64) @@ -412,6 +422,39 @@ func (_m *Group) assignValues(columns []string, values []any) error { } else if value.Valid { _m.BatchImageHoldMultiplier = value.Float64 } + case group.FieldVideoRateIndependent: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field video_rate_independent", values[i]) + } else if value.Valid { + _m.VideoRateIndependent = value.Bool + } + case group.FieldVideoRateMultiplier: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field video_rate_multiplier", values[i]) + } else if value.Valid { + _m.VideoRateMultiplier = value.Float64 + } + case group.FieldVideoPrice480p: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field video_price_480p", values[i]) + } else if value.Valid { + _m.VideoPrice480p = new(float64) + *_m.VideoPrice480p = value.Float64 + } + case group.FieldVideoPrice720p: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field video_price_720p", values[i]) + } else if value.Valid { + _m.VideoPrice720p = new(float64) + *_m.VideoPrice720p = value.Float64 + } + case group.FieldVideoPrice1080p: + if value, ok := values[i].(*sql.NullFloat64); !ok { + return fmt.Errorf("unexpected type %T for field video_price_1080p", values[i]) + } else if value.Valid { + _m.VideoPrice1080p = new(float64) + *_m.VideoPrice1080p = value.Float64 + } case group.FieldClaudeCodeOnly: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field claude_code_only", values[i]) @@ -685,6 +728,27 @@ func (_m *Group) String() string { builder.WriteString("batch_image_hold_multiplier=") builder.WriteString(fmt.Sprintf("%v", _m.BatchImageHoldMultiplier)) builder.WriteString(", ") + builder.WriteString("video_rate_independent=") + builder.WriteString(fmt.Sprintf("%v", _m.VideoRateIndependent)) + builder.WriteString(", ") + builder.WriteString("video_rate_multiplier=") + builder.WriteString(fmt.Sprintf("%v", _m.VideoRateMultiplier)) + builder.WriteString(", ") + if v := _m.VideoPrice480p; v != nil { + builder.WriteString("video_price_480p=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + if v := _m.VideoPrice720p; v != nil { + builder.WriteString("video_price_720p=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") + if v := _m.VideoPrice1080p; v != nil { + builder.WriteString("video_price_1080p=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") builder.WriteString("claude_code_only=") builder.WriteString(fmt.Sprintf("%v", _m.ClaudeCodeOnly)) builder.WriteString(", ") diff --git a/backend/ent/group/group.go b/backend/ent/group/group.go index 540ce8f9f5..769c63e6b1 100644 --- a/backend/ent/group/group.go +++ b/backend/ent/group/group.go @@ -70,6 +70,16 @@ const ( FieldBatchImageDiscountMultiplier = "batch_image_discount_multiplier" // FieldBatchImageHoldMultiplier holds the string denoting the batch_image_hold_multiplier field in the database. FieldBatchImageHoldMultiplier = "batch_image_hold_multiplier" + // FieldVideoRateIndependent holds the string denoting the video_rate_independent field in the database. + FieldVideoRateIndependent = "video_rate_independent" + // FieldVideoRateMultiplier holds the string denoting the video_rate_multiplier field in the database. + FieldVideoRateMultiplier = "video_rate_multiplier" + // FieldVideoPrice480p holds the string denoting the video_price_480p field in the database. + FieldVideoPrice480p = "video_price_480p" + // FieldVideoPrice720p holds the string denoting the video_price_720p field in the database. + FieldVideoPrice720p = "video_price_720p" + // FieldVideoPrice1080p holds the string denoting the video_price_1080p field in the database. + FieldVideoPrice1080p = "video_price_1080p" // FieldClaudeCodeOnly holds the string denoting the claude_code_only field in the database. FieldClaudeCodeOnly = "claude_code_only" // FieldFallbackGroupID holds the string denoting the fallback_group_id field in the database. @@ -202,6 +212,11 @@ var Columns = []string{ FieldImagePrice4k, FieldBatchImageDiscountMultiplier, FieldBatchImageHoldMultiplier, + FieldVideoRateIndependent, + FieldVideoRateMultiplier, + FieldVideoPrice480p, + FieldVideoPrice720p, + FieldVideoPrice1080p, FieldClaudeCodeOnly, FieldFallbackGroupID, FieldFallbackGroupIDOnInvalidRequest, @@ -296,6 +311,10 @@ var ( DefaultBatchImageDiscountMultiplier float64 // DefaultBatchImageHoldMultiplier holds the default value on creation for the "batch_image_hold_multiplier" field. DefaultBatchImageHoldMultiplier float64 + // DefaultVideoRateIndependent holds the default value on creation for the "video_rate_independent" field. + DefaultVideoRateIndependent bool + // DefaultVideoRateMultiplier holds the default value on creation for the "video_rate_multiplier" field. + DefaultVideoRateMultiplier float64 // DefaultClaudeCodeOnly holds the default value on creation for the "claude_code_only" field. DefaultClaudeCodeOnly bool // DefaultModelRoutingEnabled holds the default value on creation for the "model_routing_enabled" field. @@ -467,6 +486,31 @@ func ByBatchImageHoldMultiplier(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldBatchImageHoldMultiplier, opts...).ToFunc() } +// ByVideoRateIndependent orders the results by the video_rate_independent field. +func ByVideoRateIndependent(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVideoRateIndependent, opts...).ToFunc() +} + +// ByVideoRateMultiplier orders the results by the video_rate_multiplier field. +func ByVideoRateMultiplier(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVideoRateMultiplier, opts...).ToFunc() +} + +// ByVideoPrice480p orders the results by the video_price_480p field. +func ByVideoPrice480p(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVideoPrice480p, opts...).ToFunc() +} + +// ByVideoPrice720p orders the results by the video_price_720p field. +func ByVideoPrice720p(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVideoPrice720p, opts...).ToFunc() +} + +// ByVideoPrice1080p orders the results by the video_price_1080p field. +func ByVideoPrice1080p(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVideoPrice1080p, opts...).ToFunc() +} + // ByClaudeCodeOnly orders the results by the claude_code_only field. func ByClaudeCodeOnly(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldClaudeCodeOnly, opts...).ToFunc() diff --git a/backend/ent/group/where.go b/backend/ent/group/where.go index a76d3a8783..5a9d92d0f4 100644 --- a/backend/ent/group/where.go +++ b/backend/ent/group/where.go @@ -190,6 +190,31 @@ func BatchImageHoldMultiplier(v float64) predicate.Group { return predicate.Group(sql.FieldEQ(FieldBatchImageHoldMultiplier, v)) } +// VideoRateIndependent applies equality check predicate on the "video_rate_independent" field. It's identical to VideoRateIndependentEQ. +func VideoRateIndependent(v bool) predicate.Group { + return predicate.Group(sql.FieldEQ(FieldVideoRateIndependent, v)) +} + +// VideoRateMultiplier applies equality check predicate on the "video_rate_multiplier" field. It's identical to VideoRateMultiplierEQ. +func VideoRateMultiplier(v float64) predicate.Group { + return predicate.Group(sql.FieldEQ(FieldVideoRateMultiplier, v)) +} + +// VideoPrice480p applies equality check predicate on the "video_price_480p" field. It's identical to VideoPrice480pEQ. +func VideoPrice480p(v float64) predicate.Group { + return predicate.Group(sql.FieldEQ(FieldVideoPrice480p, v)) +} + +// VideoPrice720p applies equality check predicate on the "video_price_720p" field. It's identical to VideoPrice720pEQ. +func VideoPrice720p(v float64) predicate.Group { + return predicate.Group(sql.FieldEQ(FieldVideoPrice720p, v)) +} + +// VideoPrice1080p applies equality check predicate on the "video_price_1080p" field. It's identical to VideoPrice1080pEQ. +func VideoPrice1080p(v float64) predicate.Group { + return predicate.Group(sql.FieldEQ(FieldVideoPrice1080p, v)) +} + // ClaudeCodeOnly applies equality check predicate on the "claude_code_only" field. It's identical to ClaudeCodeOnlyEQ. func ClaudeCodeOnly(v bool) predicate.Group { return predicate.Group(sql.FieldEQ(FieldClaudeCodeOnly, v)) @@ -1430,6 +1455,206 @@ func BatchImageHoldMultiplierLTE(v float64) predicate.Group { return predicate.Group(sql.FieldLTE(FieldBatchImageHoldMultiplier, v)) } +// VideoRateIndependentEQ applies the EQ predicate on the "video_rate_independent" field. +func VideoRateIndependentEQ(v bool) predicate.Group { + return predicate.Group(sql.FieldEQ(FieldVideoRateIndependent, v)) +} + +// VideoRateIndependentNEQ applies the NEQ predicate on the "video_rate_independent" field. +func VideoRateIndependentNEQ(v bool) predicate.Group { + return predicate.Group(sql.FieldNEQ(FieldVideoRateIndependent, v)) +} + +// VideoRateMultiplierEQ applies the EQ predicate on the "video_rate_multiplier" field. +func VideoRateMultiplierEQ(v float64) predicate.Group { + return predicate.Group(sql.FieldEQ(FieldVideoRateMultiplier, v)) +} + +// VideoRateMultiplierNEQ applies the NEQ predicate on the "video_rate_multiplier" field. +func VideoRateMultiplierNEQ(v float64) predicate.Group { + return predicate.Group(sql.FieldNEQ(FieldVideoRateMultiplier, v)) +} + +// VideoRateMultiplierIn applies the In predicate on the "video_rate_multiplier" field. +func VideoRateMultiplierIn(vs ...float64) predicate.Group { + return predicate.Group(sql.FieldIn(FieldVideoRateMultiplier, vs...)) +} + +// VideoRateMultiplierNotIn applies the NotIn predicate on the "video_rate_multiplier" field. +func VideoRateMultiplierNotIn(vs ...float64) predicate.Group { + return predicate.Group(sql.FieldNotIn(FieldVideoRateMultiplier, vs...)) +} + +// VideoRateMultiplierGT applies the GT predicate on the "video_rate_multiplier" field. +func VideoRateMultiplierGT(v float64) predicate.Group { + return predicate.Group(sql.FieldGT(FieldVideoRateMultiplier, v)) +} + +// VideoRateMultiplierGTE applies the GTE predicate on the "video_rate_multiplier" field. +func VideoRateMultiplierGTE(v float64) predicate.Group { + return predicate.Group(sql.FieldGTE(FieldVideoRateMultiplier, v)) +} + +// VideoRateMultiplierLT applies the LT predicate on the "video_rate_multiplier" field. +func VideoRateMultiplierLT(v float64) predicate.Group { + return predicate.Group(sql.FieldLT(FieldVideoRateMultiplier, v)) +} + +// VideoRateMultiplierLTE applies the LTE predicate on the "video_rate_multiplier" field. +func VideoRateMultiplierLTE(v float64) predicate.Group { + return predicate.Group(sql.FieldLTE(FieldVideoRateMultiplier, v)) +} + +// VideoPrice480pEQ applies the EQ predicate on the "video_price_480p" field. +func VideoPrice480pEQ(v float64) predicate.Group { + return predicate.Group(sql.FieldEQ(FieldVideoPrice480p, v)) +} + +// VideoPrice480pNEQ applies the NEQ predicate on the "video_price_480p" field. +func VideoPrice480pNEQ(v float64) predicate.Group { + return predicate.Group(sql.FieldNEQ(FieldVideoPrice480p, v)) +} + +// VideoPrice480pIn applies the In predicate on the "video_price_480p" field. +func VideoPrice480pIn(vs ...float64) predicate.Group { + return predicate.Group(sql.FieldIn(FieldVideoPrice480p, vs...)) +} + +// VideoPrice480pNotIn applies the NotIn predicate on the "video_price_480p" field. +func VideoPrice480pNotIn(vs ...float64) predicate.Group { + return predicate.Group(sql.FieldNotIn(FieldVideoPrice480p, vs...)) +} + +// VideoPrice480pGT applies the GT predicate on the "video_price_480p" field. +func VideoPrice480pGT(v float64) predicate.Group { + return predicate.Group(sql.FieldGT(FieldVideoPrice480p, v)) +} + +// VideoPrice480pGTE applies the GTE predicate on the "video_price_480p" field. +func VideoPrice480pGTE(v float64) predicate.Group { + return predicate.Group(sql.FieldGTE(FieldVideoPrice480p, v)) +} + +// VideoPrice480pLT applies the LT predicate on the "video_price_480p" field. +func VideoPrice480pLT(v float64) predicate.Group { + return predicate.Group(sql.FieldLT(FieldVideoPrice480p, v)) +} + +// VideoPrice480pLTE applies the LTE predicate on the "video_price_480p" field. +func VideoPrice480pLTE(v float64) predicate.Group { + return predicate.Group(sql.FieldLTE(FieldVideoPrice480p, v)) +} + +// VideoPrice480pIsNil applies the IsNil predicate on the "video_price_480p" field. +func VideoPrice480pIsNil() predicate.Group { + return predicate.Group(sql.FieldIsNull(FieldVideoPrice480p)) +} + +// VideoPrice480pNotNil applies the NotNil predicate on the "video_price_480p" field. +func VideoPrice480pNotNil() predicate.Group { + return predicate.Group(sql.FieldNotNull(FieldVideoPrice480p)) +} + +// VideoPrice720pEQ applies the EQ predicate on the "video_price_720p" field. +func VideoPrice720pEQ(v float64) predicate.Group { + return predicate.Group(sql.FieldEQ(FieldVideoPrice720p, v)) +} + +// VideoPrice720pNEQ applies the NEQ predicate on the "video_price_720p" field. +func VideoPrice720pNEQ(v float64) predicate.Group { + return predicate.Group(sql.FieldNEQ(FieldVideoPrice720p, v)) +} + +// VideoPrice720pIn applies the In predicate on the "video_price_720p" field. +func VideoPrice720pIn(vs ...float64) predicate.Group { + return predicate.Group(sql.FieldIn(FieldVideoPrice720p, vs...)) +} + +// VideoPrice720pNotIn applies the NotIn predicate on the "video_price_720p" field. +func VideoPrice720pNotIn(vs ...float64) predicate.Group { + return predicate.Group(sql.FieldNotIn(FieldVideoPrice720p, vs...)) +} + +// VideoPrice720pGT applies the GT predicate on the "video_price_720p" field. +func VideoPrice720pGT(v float64) predicate.Group { + return predicate.Group(sql.FieldGT(FieldVideoPrice720p, v)) +} + +// VideoPrice720pGTE applies the GTE predicate on the "video_price_720p" field. +func VideoPrice720pGTE(v float64) predicate.Group { + return predicate.Group(sql.FieldGTE(FieldVideoPrice720p, v)) +} + +// VideoPrice720pLT applies the LT predicate on the "video_price_720p" field. +func VideoPrice720pLT(v float64) predicate.Group { + return predicate.Group(sql.FieldLT(FieldVideoPrice720p, v)) +} + +// VideoPrice720pLTE applies the LTE predicate on the "video_price_720p" field. +func VideoPrice720pLTE(v float64) predicate.Group { + return predicate.Group(sql.FieldLTE(FieldVideoPrice720p, v)) +} + +// VideoPrice720pIsNil applies the IsNil predicate on the "video_price_720p" field. +func VideoPrice720pIsNil() predicate.Group { + return predicate.Group(sql.FieldIsNull(FieldVideoPrice720p)) +} + +// VideoPrice720pNotNil applies the NotNil predicate on the "video_price_720p" field. +func VideoPrice720pNotNil() predicate.Group { + return predicate.Group(sql.FieldNotNull(FieldVideoPrice720p)) +} + +// VideoPrice1080pEQ applies the EQ predicate on the "video_price_1080p" field. +func VideoPrice1080pEQ(v float64) predicate.Group { + return predicate.Group(sql.FieldEQ(FieldVideoPrice1080p, v)) +} + +// VideoPrice1080pNEQ applies the NEQ predicate on the "video_price_1080p" field. +func VideoPrice1080pNEQ(v float64) predicate.Group { + return predicate.Group(sql.FieldNEQ(FieldVideoPrice1080p, v)) +} + +// VideoPrice1080pIn applies the In predicate on the "video_price_1080p" field. +func VideoPrice1080pIn(vs ...float64) predicate.Group { + return predicate.Group(sql.FieldIn(FieldVideoPrice1080p, vs...)) +} + +// VideoPrice1080pNotIn applies the NotIn predicate on the "video_price_1080p" field. +func VideoPrice1080pNotIn(vs ...float64) predicate.Group { + return predicate.Group(sql.FieldNotIn(FieldVideoPrice1080p, vs...)) +} + +// VideoPrice1080pGT applies the GT predicate on the "video_price_1080p" field. +func VideoPrice1080pGT(v float64) predicate.Group { + return predicate.Group(sql.FieldGT(FieldVideoPrice1080p, v)) +} + +// VideoPrice1080pGTE applies the GTE predicate on the "video_price_1080p" field. +func VideoPrice1080pGTE(v float64) predicate.Group { + return predicate.Group(sql.FieldGTE(FieldVideoPrice1080p, v)) +} + +// VideoPrice1080pLT applies the LT predicate on the "video_price_1080p" field. +func VideoPrice1080pLT(v float64) predicate.Group { + return predicate.Group(sql.FieldLT(FieldVideoPrice1080p, v)) +} + +// VideoPrice1080pLTE applies the LTE predicate on the "video_price_1080p" field. +func VideoPrice1080pLTE(v float64) predicate.Group { + return predicate.Group(sql.FieldLTE(FieldVideoPrice1080p, v)) +} + +// VideoPrice1080pIsNil applies the IsNil predicate on the "video_price_1080p" field. +func VideoPrice1080pIsNil() predicate.Group { + return predicate.Group(sql.FieldIsNull(FieldVideoPrice1080p)) +} + +// VideoPrice1080pNotNil applies the NotNil predicate on the "video_price_1080p" field. +func VideoPrice1080pNotNil() predicate.Group { + return predicate.Group(sql.FieldNotNull(FieldVideoPrice1080p)) +} + // ClaudeCodeOnlyEQ applies the EQ predicate on the "claude_code_only" field. func ClaudeCodeOnlyEQ(v bool) predicate.Group { return predicate.Group(sql.FieldEQ(FieldClaudeCodeOnly, v)) diff --git a/backend/ent/group_create.go b/backend/ent/group_create.go index 9c635847d0..2a6c18e67d 100644 --- a/backend/ent/group_create.go +++ b/backend/ent/group_create.go @@ -399,6 +399,76 @@ func (_c *GroupCreate) SetNillableBatchImageHoldMultiplier(v *float64) *GroupCre return _c } +// SetVideoRateIndependent sets the "video_rate_independent" field. +func (_c *GroupCreate) SetVideoRateIndependent(v bool) *GroupCreate { + _c.mutation.SetVideoRateIndependent(v) + return _c +} + +// SetNillableVideoRateIndependent sets the "video_rate_independent" field if the given value is not nil. +func (_c *GroupCreate) SetNillableVideoRateIndependent(v *bool) *GroupCreate { + if v != nil { + _c.SetVideoRateIndependent(*v) + } + return _c +} + +// SetVideoRateMultiplier sets the "video_rate_multiplier" field. +func (_c *GroupCreate) SetVideoRateMultiplier(v float64) *GroupCreate { + _c.mutation.SetVideoRateMultiplier(v) + return _c +} + +// SetNillableVideoRateMultiplier sets the "video_rate_multiplier" field if the given value is not nil. +func (_c *GroupCreate) SetNillableVideoRateMultiplier(v *float64) *GroupCreate { + if v != nil { + _c.SetVideoRateMultiplier(*v) + } + return _c +} + +// SetVideoPrice480p sets the "video_price_480p" field. +func (_c *GroupCreate) SetVideoPrice480p(v float64) *GroupCreate { + _c.mutation.SetVideoPrice480p(v) + return _c +} + +// SetNillableVideoPrice480p sets the "video_price_480p" field if the given value is not nil. +func (_c *GroupCreate) SetNillableVideoPrice480p(v *float64) *GroupCreate { + if v != nil { + _c.SetVideoPrice480p(*v) + } + return _c +} + +// SetVideoPrice720p sets the "video_price_720p" field. +func (_c *GroupCreate) SetVideoPrice720p(v float64) *GroupCreate { + _c.mutation.SetVideoPrice720p(v) + return _c +} + +// SetNillableVideoPrice720p sets the "video_price_720p" field if the given value is not nil. +func (_c *GroupCreate) SetNillableVideoPrice720p(v *float64) *GroupCreate { + if v != nil { + _c.SetVideoPrice720p(*v) + } + return _c +} + +// SetVideoPrice1080p sets the "video_price_1080p" field. +func (_c *GroupCreate) SetVideoPrice1080p(v float64) *GroupCreate { + _c.mutation.SetVideoPrice1080p(v) + return _c +} + +// SetNillableVideoPrice1080p sets the "video_price_1080p" field if the given value is not nil. +func (_c *GroupCreate) SetNillableVideoPrice1080p(v *float64) *GroupCreate { + if v != nil { + _c.SetVideoPrice1080p(*v) + } + return _c +} + // SetClaudeCodeOnly sets the "claude_code_only" field. func (_c *GroupCreate) SetClaudeCodeOnly(v bool) *GroupCreate { _c.mutation.SetClaudeCodeOnly(v) @@ -798,6 +868,14 @@ func (_c *GroupCreate) defaults() error { v := group.DefaultBatchImageHoldMultiplier _c.mutation.SetBatchImageHoldMultiplier(v) } + if _, ok := _c.mutation.VideoRateIndependent(); !ok { + v := group.DefaultVideoRateIndependent + _c.mutation.SetVideoRateIndependent(v) + } + if _, ok := _c.mutation.VideoRateMultiplier(); !ok { + v := group.DefaultVideoRateMultiplier + _c.mutation.SetVideoRateMultiplier(v) + } if _, ok := _c.mutation.ClaudeCodeOnly(); !ok { v := group.DefaultClaudeCodeOnly _c.mutation.SetClaudeCodeOnly(v) @@ -938,6 +1016,12 @@ func (_c *GroupCreate) check() error { if _, ok := _c.mutation.BatchImageHoldMultiplier(); !ok { return &ValidationError{Name: "batch_image_hold_multiplier", err: errors.New(`ent: missing required field "Group.batch_image_hold_multiplier"`)} } + if _, ok := _c.mutation.VideoRateIndependent(); !ok { + return &ValidationError{Name: "video_rate_independent", err: errors.New(`ent: missing required field "Group.video_rate_independent"`)} + } + if _, ok := _c.mutation.VideoRateMultiplier(); !ok { + return &ValidationError{Name: "video_rate_multiplier", err: errors.New(`ent: missing required field "Group.video_rate_multiplier"`)} + } if _, ok := _c.mutation.ClaudeCodeOnly(); !ok { return &ValidationError{Name: "claude_code_only", err: errors.New(`ent: missing required field "Group.claude_code_only"`)} } @@ -1114,6 +1198,26 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) { _spec.SetField(group.FieldBatchImageHoldMultiplier, field.TypeFloat64, value) _node.BatchImageHoldMultiplier = value } + if value, ok := _c.mutation.VideoRateIndependent(); ok { + _spec.SetField(group.FieldVideoRateIndependent, field.TypeBool, value) + _node.VideoRateIndependent = value + } + if value, ok := _c.mutation.VideoRateMultiplier(); ok { + _spec.SetField(group.FieldVideoRateMultiplier, field.TypeFloat64, value) + _node.VideoRateMultiplier = value + } + if value, ok := _c.mutation.VideoPrice480p(); ok { + _spec.SetField(group.FieldVideoPrice480p, field.TypeFloat64, value) + _node.VideoPrice480p = &value + } + if value, ok := _c.mutation.VideoPrice720p(); ok { + _spec.SetField(group.FieldVideoPrice720p, field.TypeFloat64, value) + _node.VideoPrice720p = &value + } + if value, ok := _c.mutation.VideoPrice1080p(); ok { + _spec.SetField(group.FieldVideoPrice1080p, field.TypeFloat64, value) + _node.VideoPrice1080p = &value + } if value, ok := _c.mutation.ClaudeCodeOnly(); ok { _spec.SetField(group.FieldClaudeCodeOnly, field.TypeBool, value) _node.ClaudeCodeOnly = value @@ -1762,6 +1866,108 @@ func (u *GroupUpsert) AddBatchImageHoldMultiplier(v float64) *GroupUpsert { return u } +// SetVideoRateIndependent sets the "video_rate_independent" field. +func (u *GroupUpsert) SetVideoRateIndependent(v bool) *GroupUpsert { + u.Set(group.FieldVideoRateIndependent, v) + return u +} + +// UpdateVideoRateIndependent sets the "video_rate_independent" field to the value that was provided on create. +func (u *GroupUpsert) UpdateVideoRateIndependent() *GroupUpsert { + u.SetExcluded(group.FieldVideoRateIndependent) + return u +} + +// SetVideoRateMultiplier sets the "video_rate_multiplier" field. +func (u *GroupUpsert) SetVideoRateMultiplier(v float64) *GroupUpsert { + u.Set(group.FieldVideoRateMultiplier, v) + return u +} + +// UpdateVideoRateMultiplier sets the "video_rate_multiplier" field to the value that was provided on create. +func (u *GroupUpsert) UpdateVideoRateMultiplier() *GroupUpsert { + u.SetExcluded(group.FieldVideoRateMultiplier) + return u +} + +// AddVideoRateMultiplier adds v to the "video_rate_multiplier" field. +func (u *GroupUpsert) AddVideoRateMultiplier(v float64) *GroupUpsert { + u.Add(group.FieldVideoRateMultiplier, v) + return u +} + +// SetVideoPrice480p sets the "video_price_480p" field. +func (u *GroupUpsert) SetVideoPrice480p(v float64) *GroupUpsert { + u.Set(group.FieldVideoPrice480p, v) + return u +} + +// UpdateVideoPrice480p sets the "video_price_480p" field to the value that was provided on create. +func (u *GroupUpsert) UpdateVideoPrice480p() *GroupUpsert { + u.SetExcluded(group.FieldVideoPrice480p) + return u +} + +// AddVideoPrice480p adds v to the "video_price_480p" field. +func (u *GroupUpsert) AddVideoPrice480p(v float64) *GroupUpsert { + u.Add(group.FieldVideoPrice480p, v) + return u +} + +// ClearVideoPrice480p clears the value of the "video_price_480p" field. +func (u *GroupUpsert) ClearVideoPrice480p() *GroupUpsert { + u.SetNull(group.FieldVideoPrice480p) + return u +} + +// SetVideoPrice720p sets the "video_price_720p" field. +func (u *GroupUpsert) SetVideoPrice720p(v float64) *GroupUpsert { + u.Set(group.FieldVideoPrice720p, v) + return u +} + +// UpdateVideoPrice720p sets the "video_price_720p" field to the value that was provided on create. +func (u *GroupUpsert) UpdateVideoPrice720p() *GroupUpsert { + u.SetExcluded(group.FieldVideoPrice720p) + return u +} + +// AddVideoPrice720p adds v to the "video_price_720p" field. +func (u *GroupUpsert) AddVideoPrice720p(v float64) *GroupUpsert { + u.Add(group.FieldVideoPrice720p, v) + return u +} + +// ClearVideoPrice720p clears the value of the "video_price_720p" field. +func (u *GroupUpsert) ClearVideoPrice720p() *GroupUpsert { + u.SetNull(group.FieldVideoPrice720p) + return u +} + +// SetVideoPrice1080p sets the "video_price_1080p" field. +func (u *GroupUpsert) SetVideoPrice1080p(v float64) *GroupUpsert { + u.Set(group.FieldVideoPrice1080p, v) + return u +} + +// UpdateVideoPrice1080p sets the "video_price_1080p" field to the value that was provided on create. +func (u *GroupUpsert) UpdateVideoPrice1080p() *GroupUpsert { + u.SetExcluded(group.FieldVideoPrice1080p) + return u +} + +// AddVideoPrice1080p adds v to the "video_price_1080p" field. +func (u *GroupUpsert) AddVideoPrice1080p(v float64) *GroupUpsert { + u.Add(group.FieldVideoPrice1080p, v) + return u +} + +// ClearVideoPrice1080p clears the value of the "video_price_1080p" field. +func (u *GroupUpsert) ClearVideoPrice1080p() *GroupUpsert { + u.SetNull(group.FieldVideoPrice1080p) + return u +} + // SetClaudeCodeOnly sets the "claude_code_only" field. func (u *GroupUpsert) SetClaudeCodeOnly(v bool) *GroupUpsert { u.Set(group.FieldClaudeCodeOnly, v) @@ -2533,6 +2739,125 @@ func (u *GroupUpsertOne) UpdateBatchImageHoldMultiplier() *GroupUpsertOne { }) } +// SetVideoRateIndependent sets the "video_rate_independent" field. +func (u *GroupUpsertOne) SetVideoRateIndependent(v bool) *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.SetVideoRateIndependent(v) + }) +} + +// UpdateVideoRateIndependent sets the "video_rate_independent" field to the value that was provided on create. +func (u *GroupUpsertOne) UpdateVideoRateIndependent() *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.UpdateVideoRateIndependent() + }) +} + +// SetVideoRateMultiplier sets the "video_rate_multiplier" field. +func (u *GroupUpsertOne) SetVideoRateMultiplier(v float64) *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.SetVideoRateMultiplier(v) + }) +} + +// AddVideoRateMultiplier adds v to the "video_rate_multiplier" field. +func (u *GroupUpsertOne) AddVideoRateMultiplier(v float64) *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.AddVideoRateMultiplier(v) + }) +} + +// UpdateVideoRateMultiplier sets the "video_rate_multiplier" field to the value that was provided on create. +func (u *GroupUpsertOne) UpdateVideoRateMultiplier() *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.UpdateVideoRateMultiplier() + }) +} + +// SetVideoPrice480p sets the "video_price_480p" field. +func (u *GroupUpsertOne) SetVideoPrice480p(v float64) *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.SetVideoPrice480p(v) + }) +} + +// AddVideoPrice480p adds v to the "video_price_480p" field. +func (u *GroupUpsertOne) AddVideoPrice480p(v float64) *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.AddVideoPrice480p(v) + }) +} + +// UpdateVideoPrice480p sets the "video_price_480p" field to the value that was provided on create. +func (u *GroupUpsertOne) UpdateVideoPrice480p() *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.UpdateVideoPrice480p() + }) +} + +// ClearVideoPrice480p clears the value of the "video_price_480p" field. +func (u *GroupUpsertOne) ClearVideoPrice480p() *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.ClearVideoPrice480p() + }) +} + +// SetVideoPrice720p sets the "video_price_720p" field. +func (u *GroupUpsertOne) SetVideoPrice720p(v float64) *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.SetVideoPrice720p(v) + }) +} + +// AddVideoPrice720p adds v to the "video_price_720p" field. +func (u *GroupUpsertOne) AddVideoPrice720p(v float64) *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.AddVideoPrice720p(v) + }) +} + +// UpdateVideoPrice720p sets the "video_price_720p" field to the value that was provided on create. +func (u *GroupUpsertOne) UpdateVideoPrice720p() *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.UpdateVideoPrice720p() + }) +} + +// ClearVideoPrice720p clears the value of the "video_price_720p" field. +func (u *GroupUpsertOne) ClearVideoPrice720p() *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.ClearVideoPrice720p() + }) +} + +// SetVideoPrice1080p sets the "video_price_1080p" field. +func (u *GroupUpsertOne) SetVideoPrice1080p(v float64) *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.SetVideoPrice1080p(v) + }) +} + +// AddVideoPrice1080p adds v to the "video_price_1080p" field. +func (u *GroupUpsertOne) AddVideoPrice1080p(v float64) *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.AddVideoPrice1080p(v) + }) +} + +// UpdateVideoPrice1080p sets the "video_price_1080p" field to the value that was provided on create. +func (u *GroupUpsertOne) UpdateVideoPrice1080p() *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.UpdateVideoPrice1080p() + }) +} + +// ClearVideoPrice1080p clears the value of the "video_price_1080p" field. +func (u *GroupUpsertOne) ClearVideoPrice1080p() *GroupUpsertOne { + return u.Update(func(s *GroupUpsert) { + s.ClearVideoPrice1080p() + }) +} + // SetClaudeCodeOnly sets the "claude_code_only" field. func (u *GroupUpsertOne) SetClaudeCodeOnly(v bool) *GroupUpsertOne { return u.Update(func(s *GroupUpsert) { @@ -3507,6 +3832,125 @@ func (u *GroupUpsertBulk) UpdateBatchImageHoldMultiplier() *GroupUpsertBulk { }) } +// SetVideoRateIndependent sets the "video_rate_independent" field. +func (u *GroupUpsertBulk) SetVideoRateIndependent(v bool) *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.SetVideoRateIndependent(v) + }) +} + +// UpdateVideoRateIndependent sets the "video_rate_independent" field to the value that was provided on create. +func (u *GroupUpsertBulk) UpdateVideoRateIndependent() *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.UpdateVideoRateIndependent() + }) +} + +// SetVideoRateMultiplier sets the "video_rate_multiplier" field. +func (u *GroupUpsertBulk) SetVideoRateMultiplier(v float64) *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.SetVideoRateMultiplier(v) + }) +} + +// AddVideoRateMultiplier adds v to the "video_rate_multiplier" field. +func (u *GroupUpsertBulk) AddVideoRateMultiplier(v float64) *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.AddVideoRateMultiplier(v) + }) +} + +// UpdateVideoRateMultiplier sets the "video_rate_multiplier" field to the value that was provided on create. +func (u *GroupUpsertBulk) UpdateVideoRateMultiplier() *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.UpdateVideoRateMultiplier() + }) +} + +// SetVideoPrice480p sets the "video_price_480p" field. +func (u *GroupUpsertBulk) SetVideoPrice480p(v float64) *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.SetVideoPrice480p(v) + }) +} + +// AddVideoPrice480p adds v to the "video_price_480p" field. +func (u *GroupUpsertBulk) AddVideoPrice480p(v float64) *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.AddVideoPrice480p(v) + }) +} + +// UpdateVideoPrice480p sets the "video_price_480p" field to the value that was provided on create. +func (u *GroupUpsertBulk) UpdateVideoPrice480p() *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.UpdateVideoPrice480p() + }) +} + +// ClearVideoPrice480p clears the value of the "video_price_480p" field. +func (u *GroupUpsertBulk) ClearVideoPrice480p() *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.ClearVideoPrice480p() + }) +} + +// SetVideoPrice720p sets the "video_price_720p" field. +func (u *GroupUpsertBulk) SetVideoPrice720p(v float64) *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.SetVideoPrice720p(v) + }) +} + +// AddVideoPrice720p adds v to the "video_price_720p" field. +func (u *GroupUpsertBulk) AddVideoPrice720p(v float64) *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.AddVideoPrice720p(v) + }) +} + +// UpdateVideoPrice720p sets the "video_price_720p" field to the value that was provided on create. +func (u *GroupUpsertBulk) UpdateVideoPrice720p() *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.UpdateVideoPrice720p() + }) +} + +// ClearVideoPrice720p clears the value of the "video_price_720p" field. +func (u *GroupUpsertBulk) ClearVideoPrice720p() *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.ClearVideoPrice720p() + }) +} + +// SetVideoPrice1080p sets the "video_price_1080p" field. +func (u *GroupUpsertBulk) SetVideoPrice1080p(v float64) *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.SetVideoPrice1080p(v) + }) +} + +// AddVideoPrice1080p adds v to the "video_price_1080p" field. +func (u *GroupUpsertBulk) AddVideoPrice1080p(v float64) *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.AddVideoPrice1080p(v) + }) +} + +// UpdateVideoPrice1080p sets the "video_price_1080p" field to the value that was provided on create. +func (u *GroupUpsertBulk) UpdateVideoPrice1080p() *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.UpdateVideoPrice1080p() + }) +} + +// ClearVideoPrice1080p clears the value of the "video_price_1080p" field. +func (u *GroupUpsertBulk) ClearVideoPrice1080p() *GroupUpsertBulk { + return u.Update(func(s *GroupUpsert) { + s.ClearVideoPrice1080p() + }) +} + // SetClaudeCodeOnly sets the "claude_code_only" field. func (u *GroupUpsertBulk) SetClaudeCodeOnly(v bool) *GroupUpsertBulk { return u.Update(func(s *GroupUpsert) { diff --git a/backend/ent/group_update.go b/backend/ent/group_update.go index 6f1831b1ea..3bb18d3e1a 100644 --- a/backend/ent/group_update.go +++ b/backend/ent/group_update.go @@ -524,6 +524,122 @@ func (_u *GroupUpdate) AddBatchImageHoldMultiplier(v float64) *GroupUpdate { return _u } +// SetVideoRateIndependent sets the "video_rate_independent" field. +func (_u *GroupUpdate) SetVideoRateIndependent(v bool) *GroupUpdate { + _u.mutation.SetVideoRateIndependent(v) + return _u +} + +// SetNillableVideoRateIndependent sets the "video_rate_independent" field if the given value is not nil. +func (_u *GroupUpdate) SetNillableVideoRateIndependent(v *bool) *GroupUpdate { + if v != nil { + _u.SetVideoRateIndependent(*v) + } + return _u +} + +// SetVideoRateMultiplier sets the "video_rate_multiplier" field. +func (_u *GroupUpdate) SetVideoRateMultiplier(v float64) *GroupUpdate { + _u.mutation.ResetVideoRateMultiplier() + _u.mutation.SetVideoRateMultiplier(v) + return _u +} + +// SetNillableVideoRateMultiplier sets the "video_rate_multiplier" field if the given value is not nil. +func (_u *GroupUpdate) SetNillableVideoRateMultiplier(v *float64) *GroupUpdate { + if v != nil { + _u.SetVideoRateMultiplier(*v) + } + return _u +} + +// AddVideoRateMultiplier adds value to the "video_rate_multiplier" field. +func (_u *GroupUpdate) AddVideoRateMultiplier(v float64) *GroupUpdate { + _u.mutation.AddVideoRateMultiplier(v) + return _u +} + +// SetVideoPrice480p sets the "video_price_480p" field. +func (_u *GroupUpdate) SetVideoPrice480p(v float64) *GroupUpdate { + _u.mutation.ResetVideoPrice480p() + _u.mutation.SetVideoPrice480p(v) + return _u +} + +// SetNillableVideoPrice480p sets the "video_price_480p" field if the given value is not nil. +func (_u *GroupUpdate) SetNillableVideoPrice480p(v *float64) *GroupUpdate { + if v != nil { + _u.SetVideoPrice480p(*v) + } + return _u +} + +// AddVideoPrice480p adds value to the "video_price_480p" field. +func (_u *GroupUpdate) AddVideoPrice480p(v float64) *GroupUpdate { + _u.mutation.AddVideoPrice480p(v) + return _u +} + +// ClearVideoPrice480p clears the value of the "video_price_480p" field. +func (_u *GroupUpdate) ClearVideoPrice480p() *GroupUpdate { + _u.mutation.ClearVideoPrice480p() + return _u +} + +// SetVideoPrice720p sets the "video_price_720p" field. +func (_u *GroupUpdate) SetVideoPrice720p(v float64) *GroupUpdate { + _u.mutation.ResetVideoPrice720p() + _u.mutation.SetVideoPrice720p(v) + return _u +} + +// SetNillableVideoPrice720p sets the "video_price_720p" field if the given value is not nil. +func (_u *GroupUpdate) SetNillableVideoPrice720p(v *float64) *GroupUpdate { + if v != nil { + _u.SetVideoPrice720p(*v) + } + return _u +} + +// AddVideoPrice720p adds value to the "video_price_720p" field. +func (_u *GroupUpdate) AddVideoPrice720p(v float64) *GroupUpdate { + _u.mutation.AddVideoPrice720p(v) + return _u +} + +// ClearVideoPrice720p clears the value of the "video_price_720p" field. +func (_u *GroupUpdate) ClearVideoPrice720p() *GroupUpdate { + _u.mutation.ClearVideoPrice720p() + return _u +} + +// SetVideoPrice1080p sets the "video_price_1080p" field. +func (_u *GroupUpdate) SetVideoPrice1080p(v float64) *GroupUpdate { + _u.mutation.ResetVideoPrice1080p() + _u.mutation.SetVideoPrice1080p(v) + return _u +} + +// SetNillableVideoPrice1080p sets the "video_price_1080p" field if the given value is not nil. +func (_u *GroupUpdate) SetNillableVideoPrice1080p(v *float64) *GroupUpdate { + if v != nil { + _u.SetVideoPrice1080p(*v) + } + return _u +} + +// AddVideoPrice1080p adds value to the "video_price_1080p" field. +func (_u *GroupUpdate) AddVideoPrice1080p(v float64) *GroupUpdate { + _u.mutation.AddVideoPrice1080p(v) + return _u +} + +// ClearVideoPrice1080p clears the value of the "video_price_1080p" field. +func (_u *GroupUpdate) ClearVideoPrice1080p() *GroupUpdate { + _u.mutation.ClearVideoPrice1080p() + return _u +} + // SetClaudeCodeOnly sets the "claude_code_only" field. func (_u *GroupUpdate) SetClaudeCodeOnly(v bool) *GroupUpdate { _u.mutation.SetClaudeCodeOnly(v) @@ -1223,6 +1339,42 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.AddedBatchImageHoldMultiplier(); ok { _spec.AddField(group.FieldBatchImageHoldMultiplier, field.TypeFloat64, value) } + if value, ok := _u.mutation.VideoRateIndependent(); ok { + _spec.SetField(group.FieldVideoRateIndependent, field.TypeBool, value) + } + if value, ok := _u.mutation.VideoRateMultiplier(); ok { + _spec.SetField(group.FieldVideoRateMultiplier, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedVideoRateMultiplier(); ok { + _spec.AddField(group.FieldVideoRateMultiplier, field.TypeFloat64, value) + } + if value, ok := _u.mutation.VideoPrice480p(); ok { + _spec.SetField(group.FieldVideoPrice480p, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedVideoPrice480p(); ok { + _spec.AddField(group.FieldVideoPrice480p, field.TypeFloat64, value) + } + if _u.mutation.VideoPrice480pCleared() { + _spec.ClearField(group.FieldVideoPrice480p, field.TypeFloat64) + } + if value, ok := _u.mutation.VideoPrice720p(); ok { + _spec.SetField(group.FieldVideoPrice720p, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedVideoPrice720p(); ok { + _spec.AddField(group.FieldVideoPrice720p, field.TypeFloat64, value) + } + if _u.mutation.VideoPrice720pCleared() { + _spec.ClearField(group.FieldVideoPrice720p, field.TypeFloat64) + } + if value, ok := _u.mutation.VideoPrice1080p(); ok { + _spec.SetField(group.FieldVideoPrice1080p, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedVideoPrice1080p(); ok { + _spec.AddField(group.FieldVideoPrice1080p, field.TypeFloat64, value) + } + if _u.mutation.VideoPrice1080pCleared() { + _spec.ClearField(group.FieldVideoPrice1080p, field.TypeFloat64) + } if value, ok := _u.mutation.ClaudeCodeOnly(); ok { _spec.SetField(group.FieldClaudeCodeOnly, field.TypeBool, value) } @@ -2096,6 +2248,122 @@ func (_u *GroupUpdateOne) AddBatchImageHoldMultiplier(v float64) *GroupUpdateOne return _u } +// SetVideoRateIndependent sets the "video_rate_independent" field. +func (_u *GroupUpdateOne) SetVideoRateIndependent(v bool) *GroupUpdateOne { + _u.mutation.SetVideoRateIndependent(v) + return _u +} + +// SetNillableVideoRateIndependent sets the "video_rate_independent" field if the given value is not nil. +func (_u *GroupUpdateOne) SetNillableVideoRateIndependent(v *bool) *GroupUpdateOne { + if v != nil { + _u.SetVideoRateIndependent(*v) + } + return _u +} + +// SetVideoRateMultiplier sets the "video_rate_multiplier" field. +func (_u *GroupUpdateOne) SetVideoRateMultiplier(v float64) *GroupUpdateOne { + _u.mutation.ResetVideoRateMultiplier() + _u.mutation.SetVideoRateMultiplier(v) + return _u +} + +// SetNillableVideoRateMultiplier sets the "video_rate_multiplier" field if the given value is not nil. +func (_u *GroupUpdateOne) SetNillableVideoRateMultiplier(v *float64) *GroupUpdateOne { + if v != nil { + _u.SetVideoRateMultiplier(*v) + } + return _u +} + +// AddVideoRateMultiplier adds value to the "video_rate_multiplier" field. +func (_u *GroupUpdateOne) AddVideoRateMultiplier(v float64) *GroupUpdateOne { + _u.mutation.AddVideoRateMultiplier(v) + return _u +} + +// SetVideoPrice480p sets the "video_price_480p" field. +func (_u *GroupUpdateOne) SetVideoPrice480p(v float64) *GroupUpdateOne { + _u.mutation.ResetVideoPrice480p() + _u.mutation.SetVideoPrice480p(v) + return _u +} + +// SetNillableVideoPrice480p sets the "video_price_480p" field if the given value is not nil. +func (_u *GroupUpdateOne) SetNillableVideoPrice480p(v *float64) *GroupUpdateOne { + if v != nil { + _u.SetVideoPrice480p(*v) + } + return _u +} + +// AddVideoPrice480p adds value to the "video_price_480p" field. +func (_u *GroupUpdateOne) AddVideoPrice480p(v float64) *GroupUpdateOne { + _u.mutation.AddVideoPrice480p(v) + return _u +} + +// ClearVideoPrice480p clears the value of the "video_price_480p" field. +func (_u *GroupUpdateOne) ClearVideoPrice480p() *GroupUpdateOne { + _u.mutation.ClearVideoPrice480p() + return _u +} + +// SetVideoPrice720p sets the "video_price_720p" field. +func (_u *GroupUpdateOne) SetVideoPrice720p(v float64) *GroupUpdateOne { + _u.mutation.ResetVideoPrice720p() + _u.mutation.SetVideoPrice720p(v) + return _u +} + +// SetNillableVideoPrice720p sets the "video_price_720p" field if the given value is not nil. +func (_u *GroupUpdateOne) SetNillableVideoPrice720p(v *float64) *GroupUpdateOne { + if v != nil { + _u.SetVideoPrice720p(*v) + } + return _u +} + +// AddVideoPrice720p adds value to the "video_price_720p" field. +func (_u *GroupUpdateOne) AddVideoPrice720p(v float64) *GroupUpdateOne { + _u.mutation.AddVideoPrice720p(v) + return _u +} + +// ClearVideoPrice720p clears the value of the "video_price_720p" field. +func (_u *GroupUpdateOne) ClearVideoPrice720p() *GroupUpdateOne { + _u.mutation.ClearVideoPrice720p() + return _u +} + +// SetVideoPrice1080p sets the "video_price_1080p" field. +func (_u *GroupUpdateOne) SetVideoPrice1080p(v float64) *GroupUpdateOne { + _u.mutation.ResetVideoPrice1080p() + _u.mutation.SetVideoPrice1080p(v) + return _u +} + +// SetNillableVideoPrice1080p sets the "video_price_1080p" field if the given value is not nil. +func (_u *GroupUpdateOne) SetNillableVideoPrice1080p(v *float64) *GroupUpdateOne { + if v != nil { + _u.SetVideoPrice1080p(*v) + } + return _u +} + +// AddVideoPrice1080p adds value to the "video_price_1080p" field. +func (_u *GroupUpdateOne) AddVideoPrice1080p(v float64) *GroupUpdateOne { + _u.mutation.AddVideoPrice1080p(v) + return _u +} + +// ClearVideoPrice1080p clears the value of the "video_price_1080p" field. +func (_u *GroupUpdateOne) ClearVideoPrice1080p() *GroupUpdateOne { + _u.mutation.ClearVideoPrice1080p() + return _u +} + // SetClaudeCodeOnly sets the "claude_code_only" field. func (_u *GroupUpdateOne) SetClaudeCodeOnly(v bool) *GroupUpdateOne { _u.mutation.SetClaudeCodeOnly(v) @@ -2825,6 +3093,42 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error) if value, ok := _u.mutation.AddedBatchImageHoldMultiplier(); ok { _spec.AddField(group.FieldBatchImageHoldMultiplier, field.TypeFloat64, value) } + if value, ok := _u.mutation.VideoRateIndependent(); ok { + _spec.SetField(group.FieldVideoRateIndependent, field.TypeBool, value) + } + if value, ok := _u.mutation.VideoRateMultiplier(); ok { + _spec.SetField(group.FieldVideoRateMultiplier, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedVideoRateMultiplier(); ok { + _spec.AddField(group.FieldVideoRateMultiplier, field.TypeFloat64, value) + } + if value, ok := _u.mutation.VideoPrice480p(); ok { + _spec.SetField(group.FieldVideoPrice480p, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedVideoPrice480p(); ok { + _spec.AddField(group.FieldVideoPrice480p, field.TypeFloat64, value) + } + if _u.mutation.VideoPrice480pCleared() { + _spec.ClearField(group.FieldVideoPrice480p, field.TypeFloat64) + } + if value, ok := _u.mutation.VideoPrice720p(); ok { + _spec.SetField(group.FieldVideoPrice720p, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedVideoPrice720p(); ok { + _spec.AddField(group.FieldVideoPrice720p, field.TypeFloat64, value) + } + if _u.mutation.VideoPrice720pCleared() { + _spec.ClearField(group.FieldVideoPrice720p, field.TypeFloat64) + } + if value, ok := _u.mutation.VideoPrice1080p(); ok { + _spec.SetField(group.FieldVideoPrice1080p, field.TypeFloat64, value) + } + if value, ok := _u.mutation.AddedVideoPrice1080p(); ok { + _spec.AddField(group.FieldVideoPrice1080p, field.TypeFloat64, value) + } + if _u.mutation.VideoPrice1080pCleared() { + _spec.ClearField(group.FieldVideoPrice1080p, field.TypeFloat64) + } if value, ok := _u.mutation.ClaudeCodeOnly(); ok { _spec.SetField(group.FieldClaudeCodeOnly, field.TypeBool, value) } diff --git a/backend/ent/migrate/schema.go b/backend/ent/migrate/schema.go index a584cbe39d..d3e8bc5448 100644 --- a/backend/ent/migrate/schema.go +++ b/backend/ent/migrate/schema.go @@ -860,6 +860,11 @@ var ( {Name: "image_price_4k", Type: field.TypeFloat64, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(20,8)"}}, {Name: "batch_image_discount_multiplier", Type: field.TypeFloat64, Default: 0.5, SchemaType: map[string]string{"postgres": "decimal(10,4)"}}, {Name: "batch_image_hold_multiplier", Type: field.TypeFloat64, Default: 0.6, SchemaType: map[string]string{"postgres": "decimal(10,4)"}}, + {Name: "video_rate_independent", Type: field.TypeBool, Default: false}, + {Name: "video_rate_multiplier", Type: field.TypeFloat64, Default: 1, SchemaType: map[string]string{"postgres": "decimal(10,4)"}}, + {Name: "video_price_480p", Type: field.TypeFloat64, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(20,8)"}}, + {Name: "video_price_720p", Type: field.TypeFloat64, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(20,8)"}}, + {Name: "video_price_1080p", Type: field.TypeFloat64, Nullable: true, SchemaType: map[string]string{"postgres": "decimal(20,8)"}}, {Name: "claude_code_only", Type: field.TypeBool, Default: false}, {Name: "fallback_group_id", Type: field.TypeInt64, Nullable: true}, {Name: "fallback_group_id_on_invalid_request", Type: field.TypeInt64, Nullable: true}, @@ -910,7 +915,7 @@ var ( { Name: "group_sort_order", Unique: false, - Columns: []*schema.Column{GroupsColumns[35]}, + Columns: []*schema.Column{GroupsColumns[40]}, }, }, } @@ -1567,6 +1572,9 @@ var ( {Name: "image_output_size", Type: field.TypeString, Nullable: true, Size: 32}, {Name: "image_size_source", Type: field.TypeString, Nullable: true, Size: 16}, {Name: "image_size_breakdown", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, + {Name: "video_count", Type: field.TypeInt, Default: 0}, + {Name: "video_resolution", Type: field.TypeString, Nullable: true, Size: 10}, + {Name: "video_duration_seconds", Type: field.TypeInt, Nullable: true}, {Name: "cache_ttl_overridden", Type: field.TypeBool, Default: false}, {Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}}, {Name: "api_key_id", Type: field.TypeInt64}, @@ -1583,31 +1591,31 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "usage_logs_api_keys_usage_logs", - Columns: []*schema.Column{UsageLogsColumns[37]}, + Columns: []*schema.Column{UsageLogsColumns[40]}, RefColumns: []*schema.Column{APIKeysColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "usage_logs_accounts_usage_logs", - Columns: []*schema.Column{UsageLogsColumns[38]}, + Columns: []*schema.Column{UsageLogsColumns[41]}, RefColumns: []*schema.Column{AccountsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "usage_logs_groups_usage_logs", - Columns: []*schema.Column{UsageLogsColumns[39]}, + Columns: []*schema.Column{UsageLogsColumns[42]}, RefColumns: []*schema.Column{GroupsColumns[0]}, OnDelete: schema.SetNull, }, { Symbol: "usage_logs_users_usage_logs", - Columns: []*schema.Column{UsageLogsColumns[40]}, + Columns: []*schema.Column{UsageLogsColumns[43]}, RefColumns: []*schema.Column{UsersColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "usage_logs_user_subscriptions_usage_logs", - Columns: []*schema.Column{UsageLogsColumns[41]}, + Columns: []*schema.Column{UsageLogsColumns[44]}, RefColumns: []*schema.Column{UserSubscriptionsColumns[0]}, OnDelete: schema.SetNull, }, @@ -1616,32 +1624,32 @@ var ( { Name: "usagelog_user_id", Unique: false, - Columns: []*schema.Column{UsageLogsColumns[40]}, + Columns: []*schema.Column{UsageLogsColumns[43]}, }, { Name: "usagelog_api_key_id", Unique: false, - Columns: []*schema.Column{UsageLogsColumns[37]}, + Columns: []*schema.Column{UsageLogsColumns[40]}, }, { Name: "usagelog_account_id", Unique: false, - Columns: []*schema.Column{UsageLogsColumns[38]}, + Columns: []*schema.Column{UsageLogsColumns[41]}, }, { Name: "usagelog_group_id", Unique: false, - Columns: []*schema.Column{UsageLogsColumns[39]}, + Columns: []*schema.Column{UsageLogsColumns[42]}, }, { Name: "usagelog_subscription_id", Unique: false, - Columns: []*schema.Column{UsageLogsColumns[41]}, + Columns: []*schema.Column{UsageLogsColumns[44]}, }, { Name: "usagelog_created_at", Unique: false, - Columns: []*schema.Column{UsageLogsColumns[36]}, + Columns: []*schema.Column{UsageLogsColumns[39]}, }, { Name: "usagelog_model", @@ -1661,17 +1669,17 @@ var ( { Name: "usagelog_user_id_created_at", Unique: false, - Columns: []*schema.Column{UsageLogsColumns[40], UsageLogsColumns[36]}, + Columns: []*schema.Column{UsageLogsColumns[43], UsageLogsColumns[39]}, }, { Name: "usagelog_api_key_id_created_at", Unique: false, - Columns: []*schema.Column{UsageLogsColumns[37], UsageLogsColumns[36]}, + Columns: []*schema.Column{UsageLogsColumns[40], UsageLogsColumns[39]}, }, { Name: "usagelog_group_id_created_at", Unique: false, - Columns: []*schema.Column{UsageLogsColumns[39], UsageLogsColumns[36]}, + Columns: []*schema.Column{UsageLogsColumns[42], UsageLogsColumns[39]}, }, }, } diff --git a/backend/ent/mutation.go b/backend/ent/mutation.go index 987ec4146b..8d32773050 100644 --- a/backend/ent/mutation.go +++ b/backend/ent/mutation.go @@ -20833,6 +20833,15 @@ type GroupMutation struct { addbatch_image_discount_multiplier *float64 batch_image_hold_multiplier *float64 addbatch_image_hold_multiplier *float64 + video_rate_independent *bool + video_rate_multiplier *float64 + addvideo_rate_multiplier *float64 + video_price_480p *float64 + addvideo_price_480p *float64 + video_price_720p *float64 + addvideo_price_720p *float64 + video_price_1080p *float64 + addvideo_price_1080p *float64 claude_code_only *bool fallback_group_id *int64 addfallback_group_id *int64 @@ -22297,6 +22306,308 @@ func (m *GroupMutation) ResetBatchImageHoldMultiplier() { m.addbatch_image_hold_multiplier = nil } +// SetVideoRateIndependent sets the "video_rate_independent" field. +func (m *GroupMutation) SetVideoRateIndependent(b bool) { + m.video_rate_independent = &b +} + +// VideoRateIndependent returns the value of the "video_rate_independent" field in the mutation. +func (m *GroupMutation) VideoRateIndependent() (r bool, exists bool) { + v := m.video_rate_independent + if v == nil { + return + } + return *v, true +} + +// OldVideoRateIndependent returns the old "video_rate_independent" field's value of the Group entity. +// If the Group 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 *GroupMutation) OldVideoRateIndependent(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVideoRateIndependent is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVideoRateIndependent requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVideoRateIndependent: %w", err) + } + return oldValue.VideoRateIndependent, nil +} + +// ResetVideoRateIndependent resets all changes to the "video_rate_independent" field. +func (m *GroupMutation) ResetVideoRateIndependent() { + m.video_rate_independent = nil +} + +// SetVideoRateMultiplier sets the "video_rate_multiplier" field. +func (m *GroupMutation) SetVideoRateMultiplier(f float64) { + m.video_rate_multiplier = &f + m.addvideo_rate_multiplier = nil +} + +// VideoRateMultiplier returns the value of the "video_rate_multiplier" field in the mutation. +func (m *GroupMutation) VideoRateMultiplier() (r float64, exists bool) { + v := m.video_rate_multiplier + if v == nil { + return + } + return *v, true +} + +// OldVideoRateMultiplier returns the old "video_rate_multiplier" field's value of the Group entity. +// If the Group 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 *GroupMutation) OldVideoRateMultiplier(ctx context.Context) (v float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVideoRateMultiplier is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVideoRateMultiplier requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVideoRateMultiplier: %w", err) + } + return oldValue.VideoRateMultiplier, nil +} + +// AddVideoRateMultiplier adds f to the "video_rate_multiplier" field. +func (m *GroupMutation) AddVideoRateMultiplier(f float64) { + if m.addvideo_rate_multiplier != nil { + *m.addvideo_rate_multiplier += f + } else { + m.addvideo_rate_multiplier = &f + } +} + +// AddedVideoRateMultiplier returns the value that was added to the "video_rate_multiplier" field in this mutation. +func (m *GroupMutation) AddedVideoRateMultiplier() (r float64, exists bool) { + v := m.addvideo_rate_multiplier + if v == nil { + return + } + return *v, true +} + +// ResetVideoRateMultiplier resets all changes to the "video_rate_multiplier" field. +func (m *GroupMutation) ResetVideoRateMultiplier() { + m.video_rate_multiplier = nil + m.addvideo_rate_multiplier = nil +} + +// SetVideoPrice480p sets the "video_price_480p" field. +func (m *GroupMutation) SetVideoPrice480p(f float64) { + m.video_price_480p = &f + m.addvideo_price_480p = nil +} + +// VideoPrice480p returns the value of the "video_price_480p" field in the mutation. +func (m *GroupMutation) VideoPrice480p() (r float64, exists bool) { + v := m.video_price_480p + if v == nil { + return + } + return *v, true +} + +// OldVideoPrice480p returns the old "video_price_480p" field's value of the Group entity. +// If the Group 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 *GroupMutation) OldVideoPrice480p(ctx context.Context) (v *float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVideoPrice480p is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVideoPrice480p requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVideoPrice480p: %w", err) + } + return oldValue.VideoPrice480p, nil +} + +// AddVideoPrice480p adds f to the "video_price_480p" field. +func (m *GroupMutation) AddVideoPrice480p(f float64) { + if m.addvideo_price_480p != nil { + *m.addvideo_price_480p += f + } else { + m.addvideo_price_480p = &f + } +} + +// AddedVideoPrice480p returns the value that was added to the "video_price_480p" field in this mutation. +func (m *GroupMutation) AddedVideoPrice480p() (r float64, exists bool) { + v := m.addvideo_price_480p + if v == nil { + return + } + return *v, true +} + +// ClearVideoPrice480p clears the value of the "video_price_480p" field. +func (m *GroupMutation) ClearVideoPrice480p() { + m.video_price_480p = nil + m.addvideo_price_480p = nil + m.clearedFields[group.FieldVideoPrice480p] = struct{}{} +} + +// VideoPrice480pCleared returns if the "video_price_480p" field was cleared in this mutation. +func (m *GroupMutation) VideoPrice480pCleared() bool { + _, ok := m.clearedFields[group.FieldVideoPrice480p] + return ok +} + +// ResetVideoPrice480p resets all changes to the "video_price_480p" field. +func (m *GroupMutation) ResetVideoPrice480p() { + m.video_price_480p = nil + m.addvideo_price_480p = nil + delete(m.clearedFields, group.FieldVideoPrice480p) +} + +// SetVideoPrice720p sets the "video_price_720p" field. +func (m *GroupMutation) SetVideoPrice720p(f float64) { + m.video_price_720p = &f + m.addvideo_price_720p = nil +} + +// VideoPrice720p returns the value of the "video_price_720p" field in the mutation. +func (m *GroupMutation) VideoPrice720p() (r float64, exists bool) { + v := m.video_price_720p + if v == nil { + return + } + return *v, true +} + +// OldVideoPrice720p returns the old "video_price_720p" field's value of the Group entity. +// If the Group 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 *GroupMutation) OldVideoPrice720p(ctx context.Context) (v *float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVideoPrice720p is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVideoPrice720p requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVideoPrice720p: %w", err) + } + return oldValue.VideoPrice720p, nil +} + +// AddVideoPrice720p adds f to the "video_price_720p" field. +func (m *GroupMutation) AddVideoPrice720p(f float64) { + if m.addvideo_price_720p != nil { + *m.addvideo_price_720p += f + } else { + m.addvideo_price_720p = &f + } +} + +// AddedVideoPrice720p returns the value that was added to the "video_price_720p" field in this mutation. +func (m *GroupMutation) AddedVideoPrice720p() (r float64, exists bool) { + v := m.addvideo_price_720p + if v == nil { + return + } + return *v, true +} + +// ClearVideoPrice720p clears the value of the "video_price_720p" field. +func (m *GroupMutation) ClearVideoPrice720p() { + m.video_price_720p = nil + m.addvideo_price_720p = nil + m.clearedFields[group.FieldVideoPrice720p] = struct{}{} +} + +// VideoPrice720pCleared returns if the "video_price_720p" field was cleared in this mutation. +func (m *GroupMutation) VideoPrice720pCleared() bool { + _, ok := m.clearedFields[group.FieldVideoPrice720p] + return ok +} + +// ResetVideoPrice720p resets all changes to the "video_price_720p" field. +func (m *GroupMutation) ResetVideoPrice720p() { + m.video_price_720p = nil + m.addvideo_price_720p = nil + delete(m.clearedFields, group.FieldVideoPrice720p) +} + +// SetVideoPrice1080p sets the "video_price_1080p" field. +func (m *GroupMutation) SetVideoPrice1080p(f float64) { + m.video_price_1080p = &f + m.addvideo_price_1080p = nil +} + +// VideoPrice1080p returns the value of the "video_price_1080p" field in the mutation. +func (m *GroupMutation) VideoPrice1080p() (r float64, exists bool) { + v := m.video_price_1080p + if v == nil { + return + } + return *v, true +} + +// OldVideoPrice1080p returns the old "video_price_1080p" field's value of the Group entity. +// If the Group 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 *GroupMutation) OldVideoPrice1080p(ctx context.Context) (v *float64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVideoPrice1080p is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVideoPrice1080p requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVideoPrice1080p: %w", err) + } + return oldValue.VideoPrice1080p, nil +} + +// AddVideoPrice1080p adds f to the "video_price_1080p" field. +func (m *GroupMutation) AddVideoPrice1080p(f float64) { + if m.addvideo_price_1080p != nil { + *m.addvideo_price_1080p += f + } else { + m.addvideo_price_1080p = &f + } +} + +// AddedVideoPrice1080p returns the value that was added to the "video_price_1080p" field in this mutation. +func (m *GroupMutation) AddedVideoPrice1080p() (r float64, exists bool) { + v := m.addvideo_price_1080p + if v == nil { + return + } + return *v, true +} + +// ClearVideoPrice1080p clears the value of the "video_price_1080p" field. +func (m *GroupMutation) ClearVideoPrice1080p() { + m.video_price_1080p = nil + m.addvideo_price_1080p = nil + m.clearedFields[group.FieldVideoPrice1080p] = struct{}{} +} + +// VideoPrice1080pCleared returns if the "video_price_1080p" field was cleared in this mutation. +func (m *GroupMutation) VideoPrice1080pCleared() bool { + _, ok := m.clearedFields[group.FieldVideoPrice1080p] + return ok +} + +// ResetVideoPrice1080p resets all changes to the "video_price_1080p" field. +func (m *GroupMutation) ResetVideoPrice1080p() { + m.video_price_1080p = nil + m.addvideo_price_1080p = nil + delete(m.clearedFields, group.FieldVideoPrice1080p) +} + // SetClaudeCodeOnly sets the "claude_code_only" field. func (m *GroupMutation) SetClaudeCodeOnly(b bool) { m.claude_code_only = &b @@ -23331,7 +23642,7 @@ func (m *GroupMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *GroupMutation) Fields() []string { - fields := make([]string, 0, 42) + fields := make([]string, 0, 47) if m.created_at != nil { fields = append(fields, group.FieldCreatedAt) } @@ -23413,6 +23724,21 @@ func (m *GroupMutation) Fields() []string { if m.batch_image_hold_multiplier != nil { fields = append(fields, group.FieldBatchImageHoldMultiplier) } + if m.video_rate_independent != nil { + fields = append(fields, group.FieldVideoRateIndependent) + } + if m.video_rate_multiplier != nil { + fields = append(fields, group.FieldVideoRateMultiplier) + } + if m.video_price_480p != nil { + fields = append(fields, group.FieldVideoPrice480p) + } + if m.video_price_720p != nil { + fields = append(fields, group.FieldVideoPrice720p) + } + if m.video_price_1080p != nil { + fields = append(fields, group.FieldVideoPrice1080p) + } if m.claude_code_only != nil { fields = append(fields, group.FieldClaudeCodeOnly) } @@ -23520,6 +23846,16 @@ func (m *GroupMutation) Field(name string) (ent.Value, bool) { return m.BatchImageDiscountMultiplier() case group.FieldBatchImageHoldMultiplier: return m.BatchImageHoldMultiplier() + case group.FieldVideoRateIndependent: + return m.VideoRateIndependent() + case group.FieldVideoRateMultiplier: + return m.VideoRateMultiplier() + case group.FieldVideoPrice480p: + return m.VideoPrice480p() + case group.FieldVideoPrice720p: + return m.VideoPrice720p() + case group.FieldVideoPrice1080p: + return m.VideoPrice1080p() case group.FieldClaudeCodeOnly: return m.ClaudeCodeOnly() case group.FieldFallbackGroupID: @@ -23613,6 +23949,16 @@ func (m *GroupMutation) OldField(ctx context.Context, name string) (ent.Value, e return m.OldBatchImageDiscountMultiplier(ctx) case group.FieldBatchImageHoldMultiplier: return m.OldBatchImageHoldMultiplier(ctx) + case group.FieldVideoRateIndependent: + return m.OldVideoRateIndependent(ctx) + case group.FieldVideoRateMultiplier: + return m.OldVideoRateMultiplier(ctx) + case group.FieldVideoPrice480p: + return m.OldVideoPrice480p(ctx) + case group.FieldVideoPrice720p: + return m.OldVideoPrice720p(ctx) + case group.FieldVideoPrice1080p: + return m.OldVideoPrice1080p(ctx) case group.FieldClaudeCodeOnly: return m.OldClaudeCodeOnly(ctx) case group.FieldFallbackGroupID: @@ -23841,6 +24187,41 @@ func (m *GroupMutation) SetField(name string, value ent.Value) error { } m.SetBatchImageHoldMultiplier(v) return nil + case group.FieldVideoRateIndependent: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVideoRateIndependent(v) + return nil + case group.FieldVideoRateMultiplier: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVideoRateMultiplier(v) + return nil + case group.FieldVideoPrice480p: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVideoPrice480p(v) + return nil + case group.FieldVideoPrice720p: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVideoPrice720p(v) + return nil + case group.FieldVideoPrice1080p: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVideoPrice1080p(v) + return nil case group.FieldClaudeCodeOnly: v, ok := value.(bool) if !ok { @@ -23990,6 +24371,18 @@ func (m *GroupMutation) AddedFields() []string { if m.addbatch_image_hold_multiplier != nil { fields = append(fields, group.FieldBatchImageHoldMultiplier) } + if m.addvideo_rate_multiplier != nil { + fields = append(fields, group.FieldVideoRateMultiplier) + } + if m.addvideo_price_480p != nil { + fields = append(fields, group.FieldVideoPrice480p) + } + if m.addvideo_price_720p != nil { + fields = append(fields, group.FieldVideoPrice720p) + } + if m.addvideo_price_1080p != nil { + fields = append(fields, group.FieldVideoPrice1080p) + } if m.addfallback_group_id != nil { fields = append(fields, group.FieldFallbackGroupID) } @@ -24034,6 +24427,14 @@ func (m *GroupMutation) AddedField(name string) (ent.Value, bool) { return m.AddedBatchImageDiscountMultiplier() case group.FieldBatchImageHoldMultiplier: return m.AddedBatchImageHoldMultiplier() + case group.FieldVideoRateMultiplier: + return m.AddedVideoRateMultiplier() + case group.FieldVideoPrice480p: + return m.AddedVideoPrice480p() + case group.FieldVideoPrice720p: + return m.AddedVideoPrice720p() + case group.FieldVideoPrice1080p: + return m.AddedVideoPrice1080p() case group.FieldFallbackGroupID: return m.AddedFallbackGroupID() case group.FieldFallbackGroupIDOnInvalidRequest: @@ -24135,6 +24536,34 @@ func (m *GroupMutation) AddField(name string, value ent.Value) error { } m.AddBatchImageHoldMultiplier(v) return nil + case group.FieldVideoRateMultiplier: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddVideoRateMultiplier(v) + return nil + case group.FieldVideoPrice480p: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddVideoPrice480p(v) + return nil + case group.FieldVideoPrice720p: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddVideoPrice720p(v) + return nil + case group.FieldVideoPrice1080p: + v, ok := value.(float64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddVideoPrice1080p(v) + return nil case group.FieldFallbackGroupID: v, ok := value.(int64) if !ok { @@ -24195,6 +24624,15 @@ func (m *GroupMutation) ClearedFields() []string { if m.FieldCleared(group.FieldImagePrice4k) { fields = append(fields, group.FieldImagePrice4k) } + if m.FieldCleared(group.FieldVideoPrice480p) { + fields = append(fields, group.FieldVideoPrice480p) + } + if m.FieldCleared(group.FieldVideoPrice720p) { + fields = append(fields, group.FieldVideoPrice720p) + } + if m.FieldCleared(group.FieldVideoPrice1080p) { + fields = append(fields, group.FieldVideoPrice1080p) + } if m.FieldCleared(group.FieldFallbackGroupID) { fields = append(fields, group.FieldFallbackGroupID) } @@ -24242,6 +24680,15 @@ func (m *GroupMutation) ClearField(name string) error { case group.FieldImagePrice4k: m.ClearImagePrice4k() return nil + case group.FieldVideoPrice480p: + m.ClearVideoPrice480p() + return nil + case group.FieldVideoPrice720p: + m.ClearVideoPrice720p() + return nil + case group.FieldVideoPrice1080p: + m.ClearVideoPrice1080p() + return nil case group.FieldFallbackGroupID: m.ClearFallbackGroupID() return nil @@ -24340,6 +24787,21 @@ func (m *GroupMutation) ResetField(name string) error { case group.FieldBatchImageHoldMultiplier: m.ResetBatchImageHoldMultiplier() return nil + case group.FieldVideoRateIndependent: + m.ResetVideoRateIndependent() + return nil + case group.FieldVideoRateMultiplier: + m.ResetVideoRateMultiplier() + return nil + case group.FieldVideoPrice480p: + m.ResetVideoPrice480p() + return nil + case group.FieldVideoPrice720p: + m.ResetVideoPrice720p() + return nil + case group.FieldVideoPrice1080p: + m.ResetVideoPrice1080p() + return nil case group.FieldClaudeCodeOnly: m.ResetClaudeCodeOnly() return nil @@ -41250,6 +41712,11 @@ type UsageLogMutation struct { image_output_size *string image_size_source *string image_size_breakdown *map[string]int + video_count *int + addvideo_count *int + video_resolution *string + video_duration_seconds *int + addvideo_duration_seconds *int cache_ttl_overridden *bool created_at *time.Time clearedFields map[string]struct{} @@ -43388,6 +43855,181 @@ func (m *UsageLogMutation) ResetImageSizeBreakdown() { delete(m.clearedFields, usagelog.FieldImageSizeBreakdown) } +// SetVideoCount sets the "video_count" field. +func (m *UsageLogMutation) SetVideoCount(i int) { + m.video_count = &i + m.addvideo_count = nil +} + +// VideoCount returns the value of the "video_count" field in the mutation. +func (m *UsageLogMutation) VideoCount() (r int, exists bool) { + v := m.video_count + if v == nil { + return + } + return *v, true +} + +// OldVideoCount returns the old "video_count" field's value of the UsageLog entity. +// If the UsageLog 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 *UsageLogMutation) OldVideoCount(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVideoCount is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVideoCount requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVideoCount: %w", err) + } + return oldValue.VideoCount, nil +} + +// AddVideoCount adds i to the "video_count" field. +func (m *UsageLogMutation) AddVideoCount(i int) { + if m.addvideo_count != nil { + *m.addvideo_count += i + } else { + m.addvideo_count = &i + } +} + +// AddedVideoCount returns the value that was added to the "video_count" field in this mutation. +func (m *UsageLogMutation) AddedVideoCount() (r int, exists bool) { + v := m.addvideo_count + if v == nil { + return + } + return *v, true +} + +// ResetVideoCount resets all changes to the "video_count" field. +func (m *UsageLogMutation) ResetVideoCount() { + m.video_count = nil + m.addvideo_count = nil +} + +// SetVideoResolution sets the "video_resolution" field. +func (m *UsageLogMutation) SetVideoResolution(s string) { + m.video_resolution = &s +} + +// VideoResolution returns the value of the "video_resolution" field in the mutation. +func (m *UsageLogMutation) VideoResolution() (r string, exists bool) { + v := m.video_resolution + if v == nil { + return + } + return *v, true +} + +// OldVideoResolution returns the old "video_resolution" field's value of the UsageLog entity. +// If the UsageLog 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 *UsageLogMutation) OldVideoResolution(ctx context.Context) (v *string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVideoResolution is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVideoResolution requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVideoResolution: %w", err) + } + return oldValue.VideoResolution, nil +} + +// ClearVideoResolution clears the value of the "video_resolution" field. +func (m *UsageLogMutation) ClearVideoResolution() { + m.video_resolution = nil + m.clearedFields[usagelog.FieldVideoResolution] = struct{}{} +} + +// VideoResolutionCleared returns if the "video_resolution" field was cleared in this mutation. +func (m *UsageLogMutation) VideoResolutionCleared() bool { + _, ok := m.clearedFields[usagelog.FieldVideoResolution] + return ok +} + +// ResetVideoResolution resets all changes to the "video_resolution" field. +func (m *UsageLogMutation) ResetVideoResolution() { + m.video_resolution = nil + delete(m.clearedFields, usagelog.FieldVideoResolution) +} + +// SetVideoDurationSeconds sets the "video_duration_seconds" field. +func (m *UsageLogMutation) SetVideoDurationSeconds(i int) { + m.video_duration_seconds = &i + m.addvideo_duration_seconds = nil +} + +// VideoDurationSeconds returns the value of the "video_duration_seconds" field in the mutation. +func (m *UsageLogMutation) VideoDurationSeconds() (r int, exists bool) { + v := m.video_duration_seconds + if v == nil { + return + } + return *v, true +} + +// OldVideoDurationSeconds returns the old "video_duration_seconds" field's value of the UsageLog entity. +// If the UsageLog 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 *UsageLogMutation) OldVideoDurationSeconds(ctx context.Context) (v *int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVideoDurationSeconds is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVideoDurationSeconds requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVideoDurationSeconds: %w", err) + } + return oldValue.VideoDurationSeconds, nil +} + +// AddVideoDurationSeconds adds i to the "video_duration_seconds" field. +func (m *UsageLogMutation) AddVideoDurationSeconds(i int) { + if m.addvideo_duration_seconds != nil { + *m.addvideo_duration_seconds += i + } else { + m.addvideo_duration_seconds = &i + } +} + +// AddedVideoDurationSeconds returns the value that was added to the "video_duration_seconds" field in this mutation. +func (m *UsageLogMutation) AddedVideoDurationSeconds() (r int, exists bool) { + v := m.addvideo_duration_seconds + if v == nil { + return + } + return *v, true +} + +// ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field. +func (m *UsageLogMutation) ClearVideoDurationSeconds() { + m.video_duration_seconds = nil + m.addvideo_duration_seconds = nil + m.clearedFields[usagelog.FieldVideoDurationSeconds] = struct{}{} +} + +// VideoDurationSecondsCleared returns if the "video_duration_seconds" field was cleared in this mutation. +func (m *UsageLogMutation) VideoDurationSecondsCleared() bool { + _, ok := m.clearedFields[usagelog.FieldVideoDurationSeconds] + return ok +} + +// ResetVideoDurationSeconds resets all changes to the "video_duration_seconds" field. +func (m *UsageLogMutation) ResetVideoDurationSeconds() { + m.video_duration_seconds = nil + m.addvideo_duration_seconds = nil + delete(m.clearedFields, usagelog.FieldVideoDurationSeconds) +} + // SetCacheTTLOverridden sets the "cache_ttl_overridden" field. func (m *UsageLogMutation) SetCacheTTLOverridden(b bool) { m.cache_ttl_overridden = &b @@ -43629,7 +44271,7 @@ func (m *UsageLogMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UsageLogMutation) Fields() []string { - fields := make([]string, 0, 41) + fields := make([]string, 0, 44) if m.user != nil { fields = append(fields, usagelog.FieldUserID) } @@ -43747,6 +44389,15 @@ func (m *UsageLogMutation) Fields() []string { if m.image_size_breakdown != nil { fields = append(fields, usagelog.FieldImageSizeBreakdown) } + if m.video_count != nil { + fields = append(fields, usagelog.FieldVideoCount) + } + if m.video_resolution != nil { + fields = append(fields, usagelog.FieldVideoResolution) + } + if m.video_duration_seconds != nil { + fields = append(fields, usagelog.FieldVideoDurationSeconds) + } if m.cache_ttl_overridden != nil { fields = append(fields, usagelog.FieldCacheTTLOverridden) } @@ -43839,6 +44490,12 @@ func (m *UsageLogMutation) Field(name string) (ent.Value, bool) { return m.ImageSizeSource() case usagelog.FieldImageSizeBreakdown: return m.ImageSizeBreakdown() + case usagelog.FieldVideoCount: + return m.VideoCount() + case usagelog.FieldVideoResolution: + return m.VideoResolution() + case usagelog.FieldVideoDurationSeconds: + return m.VideoDurationSeconds() case usagelog.FieldCacheTTLOverridden: return m.CacheTTLOverridden() case usagelog.FieldCreatedAt: @@ -43930,6 +44587,12 @@ func (m *UsageLogMutation) OldField(ctx context.Context, name string) (ent.Value return m.OldImageSizeSource(ctx) case usagelog.FieldImageSizeBreakdown: return m.OldImageSizeBreakdown(ctx) + case usagelog.FieldVideoCount: + return m.OldVideoCount(ctx) + case usagelog.FieldVideoResolution: + return m.OldVideoResolution(ctx) + case usagelog.FieldVideoDurationSeconds: + return m.OldVideoDurationSeconds(ctx) case usagelog.FieldCacheTTLOverridden: return m.OldCacheTTLOverridden(ctx) case usagelog.FieldCreatedAt: @@ -44216,6 +44879,27 @@ func (m *UsageLogMutation) SetField(name string, value ent.Value) error { } m.SetImageSizeBreakdown(v) return nil + case usagelog.FieldVideoCount: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVideoCount(v) + return nil + case usagelog.FieldVideoResolution: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVideoResolution(v) + return nil + case usagelog.FieldVideoDurationSeconds: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVideoDurationSeconds(v) + return nil case usagelog.FieldCacheTTLOverridden: v, ok := value.(bool) if !ok { @@ -44295,6 +44979,12 @@ func (m *UsageLogMutation) AddedFields() []string { if m.addimage_count != nil { fields = append(fields, usagelog.FieldImageCount) } + if m.addvideo_count != nil { + fields = append(fields, usagelog.FieldVideoCount) + } + if m.addvideo_duration_seconds != nil { + fields = append(fields, usagelog.FieldVideoDurationSeconds) + } return fields } @@ -44341,6 +45031,10 @@ func (m *UsageLogMutation) AddedField(name string) (ent.Value, bool) { return m.AddedFirstTokenMs() case usagelog.FieldImageCount: return m.AddedImageCount() + case usagelog.FieldVideoCount: + return m.AddedVideoCount() + case usagelog.FieldVideoDurationSeconds: + return m.AddedVideoDurationSeconds() } return nil, false } @@ -44483,6 +45177,20 @@ func (m *UsageLogMutation) AddField(name string, value ent.Value) error { } m.AddImageCount(v) return nil + case usagelog.FieldVideoCount: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddVideoCount(v) + return nil + case usagelog.FieldVideoDurationSeconds: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddVideoDurationSeconds(v) + return nil } return fmt.Errorf("unknown UsageLog numeric field %s", name) } @@ -44545,6 +45253,12 @@ func (m *UsageLogMutation) ClearedFields() []string { if m.FieldCleared(usagelog.FieldImageSizeBreakdown) { fields = append(fields, usagelog.FieldImageSizeBreakdown) } + if m.FieldCleared(usagelog.FieldVideoResolution) { + fields = append(fields, usagelog.FieldVideoResolution) + } + if m.FieldCleared(usagelog.FieldVideoDurationSeconds) { + fields = append(fields, usagelog.FieldVideoDurationSeconds) + } return fields } @@ -44613,6 +45327,12 @@ func (m *UsageLogMutation) ClearField(name string) error { case usagelog.FieldImageSizeBreakdown: m.ClearImageSizeBreakdown() return nil + case usagelog.FieldVideoResolution: + m.ClearVideoResolution() + return nil + case usagelog.FieldVideoDurationSeconds: + m.ClearVideoDurationSeconds() + return nil } return fmt.Errorf("unknown UsageLog nullable field %s", name) } @@ -44738,6 +45458,15 @@ func (m *UsageLogMutation) ResetField(name string) error { case usagelog.FieldImageSizeBreakdown: m.ResetImageSizeBreakdown() return nil + case usagelog.FieldVideoCount: + m.ResetVideoCount() + return nil + case usagelog.FieldVideoResolution: + m.ResetVideoResolution() + return nil + case usagelog.FieldVideoDurationSeconds: + m.ResetVideoDurationSeconds() + return nil case usagelog.FieldCacheTTLOverridden: m.ResetCacheTTLOverridden() return nil diff --git a/backend/ent/runtime/runtime.go b/backend/ent/runtime/runtime.go index 2c05c01c52..d47e7d143b 100644 --- a/backend/ent/runtime/runtime.go +++ b/backend/ent/runtime/runtime.go @@ -1035,54 +1035,62 @@ func init() { groupDescBatchImageHoldMultiplier := groupFields[23].Descriptor() // group.DefaultBatchImageHoldMultiplier holds the default value on creation for the batch_image_hold_multiplier field. group.DefaultBatchImageHoldMultiplier = groupDescBatchImageHoldMultiplier.Default.(float64) + // groupDescVideoRateIndependent is the schema descriptor for video_rate_independent field. + groupDescVideoRateIndependent := groupFields[24].Descriptor() + // group.DefaultVideoRateIndependent holds the default value on creation for the video_rate_independent field. + group.DefaultVideoRateIndependent = groupDescVideoRateIndependent.Default.(bool) + // groupDescVideoRateMultiplier is the schema descriptor for video_rate_multiplier field. + groupDescVideoRateMultiplier := groupFields[25].Descriptor() + // group.DefaultVideoRateMultiplier holds the default value on creation for the video_rate_multiplier field. + group.DefaultVideoRateMultiplier = groupDescVideoRateMultiplier.Default.(float64) // groupDescClaudeCodeOnly is the schema descriptor for claude_code_only field. - groupDescClaudeCodeOnly := groupFields[24].Descriptor() + groupDescClaudeCodeOnly := groupFields[29].Descriptor() // group.DefaultClaudeCodeOnly holds the default value on creation for the claude_code_only field. group.DefaultClaudeCodeOnly = groupDescClaudeCodeOnly.Default.(bool) // groupDescModelRoutingEnabled is the schema descriptor for model_routing_enabled field. - groupDescModelRoutingEnabled := groupFields[28].Descriptor() + groupDescModelRoutingEnabled := groupFields[33].Descriptor() // group.DefaultModelRoutingEnabled holds the default value on creation for the model_routing_enabled field. group.DefaultModelRoutingEnabled = groupDescModelRoutingEnabled.Default.(bool) // groupDescMcpXMLInject is the schema descriptor for mcp_xml_inject field. - groupDescMcpXMLInject := groupFields[29].Descriptor() + groupDescMcpXMLInject := groupFields[34].Descriptor() // group.DefaultMcpXMLInject holds the default value on creation for the mcp_xml_inject field. group.DefaultMcpXMLInject = groupDescMcpXMLInject.Default.(bool) // groupDescSupportedModelScopes is the schema descriptor for supported_model_scopes field. - groupDescSupportedModelScopes := groupFields[30].Descriptor() + groupDescSupportedModelScopes := groupFields[35].Descriptor() // group.DefaultSupportedModelScopes holds the default value on creation for the supported_model_scopes field. group.DefaultSupportedModelScopes = groupDescSupportedModelScopes.Default.([]string) // groupDescSortOrder is the schema descriptor for sort_order field. - groupDescSortOrder := groupFields[31].Descriptor() + groupDescSortOrder := groupFields[36].Descriptor() // group.DefaultSortOrder holds the default value on creation for the sort_order field. group.DefaultSortOrder = groupDescSortOrder.Default.(int) // groupDescAllowMessagesDispatch is the schema descriptor for allow_messages_dispatch field. - groupDescAllowMessagesDispatch := groupFields[32].Descriptor() + groupDescAllowMessagesDispatch := groupFields[37].Descriptor() // group.DefaultAllowMessagesDispatch holds the default value on creation for the allow_messages_dispatch field. group.DefaultAllowMessagesDispatch = groupDescAllowMessagesDispatch.Default.(bool) // groupDescRequireOauthOnly is the schema descriptor for require_oauth_only field. - groupDescRequireOauthOnly := groupFields[33].Descriptor() + groupDescRequireOauthOnly := groupFields[38].Descriptor() // group.DefaultRequireOauthOnly holds the default value on creation for the require_oauth_only field. group.DefaultRequireOauthOnly = groupDescRequireOauthOnly.Default.(bool) // groupDescRequirePrivacySet is the schema descriptor for require_privacy_set field. - groupDescRequirePrivacySet := groupFields[34].Descriptor() + groupDescRequirePrivacySet := groupFields[39].Descriptor() // group.DefaultRequirePrivacySet holds the default value on creation for the require_privacy_set field. group.DefaultRequirePrivacySet = groupDescRequirePrivacySet.Default.(bool) // groupDescDefaultMappedModel is the schema descriptor for default_mapped_model field. - groupDescDefaultMappedModel := groupFields[35].Descriptor() + groupDescDefaultMappedModel := groupFields[40].Descriptor() // group.DefaultDefaultMappedModel holds the default value on creation for the default_mapped_model field. group.DefaultDefaultMappedModel = groupDescDefaultMappedModel.Default.(string) // group.DefaultMappedModelValidator is a validator for the "default_mapped_model" field. It is called by the builders before save. group.DefaultMappedModelValidator = groupDescDefaultMappedModel.Validators[0].(func(string) error) // groupDescMessagesDispatchModelConfig is the schema descriptor for messages_dispatch_model_config field. - groupDescMessagesDispatchModelConfig := groupFields[36].Descriptor() + groupDescMessagesDispatchModelConfig := groupFields[41].Descriptor() // group.DefaultMessagesDispatchModelConfig holds the default value on creation for the messages_dispatch_model_config field. group.DefaultMessagesDispatchModelConfig = groupDescMessagesDispatchModelConfig.Default.(domain.OpenAIMessagesDispatchModelConfig) // groupDescModelsListConfig is the schema descriptor for models_list_config field. - groupDescModelsListConfig := groupFields[37].Descriptor() + groupDescModelsListConfig := groupFields[42].Descriptor() // group.DefaultModelsListConfig holds the default value on creation for the models_list_config field. group.DefaultModelsListConfig = groupDescModelsListConfig.Default.(domain.GroupModelsListConfig) // groupDescRpmLimit is the schema descriptor for rpm_limit field. - groupDescRpmLimit := groupFields[38].Descriptor() + groupDescRpmLimit := groupFields[43].Descriptor() // group.DefaultRpmLimit holds the default value on creation for the rpm_limit field. group.DefaultRpmLimit = groupDescRpmLimit.Default.(int) idempotencyrecordMixin := schema.IdempotencyRecord{}.Mixin() @@ -1968,12 +1976,20 @@ func init() { usagelogDescImageSizeSource := usagelogFields[37].Descriptor() // usagelog.ImageSizeSourceValidator is a validator for the "image_size_source" field. It is called by the builders before save. usagelog.ImageSizeSourceValidator = usagelogDescImageSizeSource.Validators[0].(func(string) error) + // usagelogDescVideoCount is the schema descriptor for video_count field. + usagelogDescVideoCount := usagelogFields[39].Descriptor() + // usagelog.DefaultVideoCount holds the default value on creation for the video_count field. + usagelog.DefaultVideoCount = usagelogDescVideoCount.Default.(int) + // usagelogDescVideoResolution is the schema descriptor for video_resolution field. + usagelogDescVideoResolution := usagelogFields[40].Descriptor() + // usagelog.VideoResolutionValidator is a validator for the "video_resolution" field. It is called by the builders before save. + usagelog.VideoResolutionValidator = usagelogDescVideoResolution.Validators[0].(func(string) error) // usagelogDescCacheTTLOverridden is the schema descriptor for cache_ttl_overridden field. - usagelogDescCacheTTLOverridden := usagelogFields[39].Descriptor() + usagelogDescCacheTTLOverridden := usagelogFields[42].Descriptor() // usagelog.DefaultCacheTTLOverridden holds the default value on creation for the cache_ttl_overridden field. usagelog.DefaultCacheTTLOverridden = usagelogDescCacheTTLOverridden.Default.(bool) // usagelogDescCreatedAt is the schema descriptor for created_at field. - usagelogDescCreatedAt := usagelogFields[40].Descriptor() + usagelogDescCreatedAt := usagelogFields[43].Descriptor() // usagelog.DefaultCreatedAt holds the default value on creation for the created_at field. usagelog.DefaultCreatedAt = usagelogDescCreatedAt.Default.(func() time.Time) userMixin := schema.User{}.Mixin() diff --git a/backend/ent/schema/group.go b/backend/ent/schema/group.go index d675ca52f1..b104609a1b 100644 --- a/backend/ent/schema/group.go +++ b/backend/ent/schema/group.go @@ -123,6 +123,25 @@ func (Group) Fields() []ent.Field { SchemaType(map[string]string{dialect.Postgres: "decimal(10,4)"}). Default(0.6). Comment("批量图片生成冻结价格比例,按普通生图原价乘以该比例冻结,结算后释放差额"), + field.Bool("video_rate_independent"). + Default(false). + Comment("视频生成是否使用独立倍率;false 表示共享分组有效倍率"), + field.Float("video_rate_multiplier"). + SchemaType(map[string]string{dialect.Postgres: "decimal(10,4)"}). + Default(1.0). + Comment("视频生成独立倍率,仅 video_rate_independent=true 时生效"), + field.Float("video_price_480p"). + Optional(). + Nillable(). + SchemaType(map[string]string{dialect.Postgres: "decimal(20,8)"}), + field.Float("video_price_720p"). + Optional(). + Nillable(). + SchemaType(map[string]string{dialect.Postgres: "decimal(20,8)"}), + field.Float("video_price_1080p"). + Optional(). + Nillable(). + SchemaType(map[string]string{dialect.Postgres: "decimal(20,8)"}), // Claude Code 客户端限制 (added by migration 029) field.Bool("claude_code_only"). diff --git a/backend/ent/schema/usage_log.go b/backend/ent/schema/usage_log.go index db9e517892..e84cc1c140 100644 --- a/backend/ent/schema/usage_log.go +++ b/backend/ent/schema/usage_log.go @@ -149,6 +149,20 @@ func (UsageLog) Fields() []ent.Field { field.JSON("image_size_breakdown", map[string]int{}). Optional(). SchemaType(map[string]string{dialect.Postgres: "jsonb"}), + + // 视频生成字段(Grok 视频按秒计费;billing_mode 走 token/其他模式时这些列仍标记视频用量) + field.Int("video_count"). + Default(0). + Comment("视频生成数量;>0 表示本行是视频生成用量"), + field.String("video_resolution"). + MaxLen(10). + Optional(). + Nillable(). + Comment("计费用视频分辨率 480p/720p/1080p"), + field.Int("video_duration_seconds"). + Optional(). + Nillable(). + Comment("提交时请求的视频时长(秒),按秒计费的乘数"), // Cache TTL Override 标记(管理员强制替换了缓存 TTL 计费) field.Bool("cache_ttl_overridden"). Default(false), diff --git a/backend/ent/usagelog.go b/backend/ent/usagelog.go index 283fe828a9..4d374a8495 100644 --- a/backend/ent/usagelog.go +++ b/backend/ent/usagelog.go @@ -101,6 +101,12 @@ type UsageLog struct { ImageSizeSource *string `json:"image_size_source,omitempty"` // ImageSizeBreakdown holds the value of the "image_size_breakdown" field. ImageSizeBreakdown map[string]int `json:"image_size_breakdown,omitempty"` + // 视频生成数量;>0 表示本行是视频生成用量 + VideoCount int `json:"video_count,omitempty"` + // 计费用视频分辨率 480p/720p/1080p + VideoResolution *string `json:"video_resolution,omitempty"` + // 提交时请求的视频时长(秒),按秒计费的乘数 + VideoDurationSeconds *int `json:"video_duration_seconds,omitempty"` // CacheTTLOverridden holds the value of the "cache_ttl_overridden" field. CacheTTLOverridden bool `json:"cache_ttl_overridden,omitempty"` // CreatedAt holds the value of the "created_at" field. @@ -194,9 +200,9 @@ func (*UsageLog) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullBool) case usagelog.FieldInputCost, usagelog.FieldOutputCost, usagelog.FieldCacheCreationCost, usagelog.FieldCacheReadCost, usagelog.FieldTotalCost, usagelog.FieldActualCost, usagelog.FieldRateMultiplier, usagelog.FieldAccountRateMultiplier: values[i] = new(sql.NullFloat64) - case usagelog.FieldID, usagelog.FieldUserID, usagelog.FieldAPIKeyID, usagelog.FieldAccountID, usagelog.FieldChannelID, usagelog.FieldGroupID, usagelog.FieldSubscriptionID, usagelog.FieldInputTokens, usagelog.FieldOutputTokens, usagelog.FieldCacheCreationTokens, usagelog.FieldCacheReadTokens, usagelog.FieldCacheCreation5mTokens, usagelog.FieldCacheCreation1hTokens, usagelog.FieldBillingType, usagelog.FieldDurationMs, usagelog.FieldFirstTokenMs, usagelog.FieldImageCount: + case usagelog.FieldID, usagelog.FieldUserID, usagelog.FieldAPIKeyID, usagelog.FieldAccountID, usagelog.FieldChannelID, usagelog.FieldGroupID, usagelog.FieldSubscriptionID, usagelog.FieldInputTokens, usagelog.FieldOutputTokens, usagelog.FieldCacheCreationTokens, usagelog.FieldCacheReadTokens, usagelog.FieldCacheCreation5mTokens, usagelog.FieldCacheCreation1hTokens, usagelog.FieldBillingType, usagelog.FieldDurationMs, usagelog.FieldFirstTokenMs, usagelog.FieldImageCount, usagelog.FieldVideoCount, usagelog.FieldVideoDurationSeconds: values[i] = new(sql.NullInt64) - case usagelog.FieldRequestID, usagelog.FieldModel, usagelog.FieldRequestedModel, usagelog.FieldUpstreamModel, usagelog.FieldModelMappingChain, usagelog.FieldBillingTier, usagelog.FieldBillingMode, usagelog.FieldUserAgent, usagelog.FieldIPAddress, usagelog.FieldImageSize, usagelog.FieldImageInputSize, usagelog.FieldImageOutputSize, usagelog.FieldImageSizeSource: + case usagelog.FieldRequestID, usagelog.FieldModel, usagelog.FieldRequestedModel, usagelog.FieldUpstreamModel, usagelog.FieldModelMappingChain, usagelog.FieldBillingTier, usagelog.FieldBillingMode, usagelog.FieldUserAgent, usagelog.FieldIPAddress, usagelog.FieldImageSize, usagelog.FieldImageInputSize, usagelog.FieldImageOutputSize, usagelog.FieldImageSizeSource, usagelog.FieldVideoResolution: values[i] = new(sql.NullString) case usagelog.FieldCreatedAt: values[i] = new(sql.NullTime) @@ -474,6 +480,26 @@ func (_m *UsageLog) assignValues(columns []string, values []any) error { return fmt.Errorf("unmarshal field image_size_breakdown: %w", err) } } + case usagelog.FieldVideoCount: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field video_count", values[i]) + } else if value.Valid { + _m.VideoCount = int(value.Int64) + } + case usagelog.FieldVideoResolution: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field video_resolution", values[i]) + } else if value.Valid { + _m.VideoResolution = new(string) + *_m.VideoResolution = value.String + } + case usagelog.FieldVideoDurationSeconds: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field video_duration_seconds", values[i]) + } else if value.Valid { + _m.VideoDurationSeconds = new(int) + *_m.VideoDurationSeconds = int(value.Int64) + } case usagelog.FieldCacheTTLOverridden: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field cache_ttl_overridden", values[i]) @@ -698,6 +724,19 @@ func (_m *UsageLog) String() string { builder.WriteString("image_size_breakdown=") builder.WriteString(fmt.Sprintf("%v", _m.ImageSizeBreakdown)) builder.WriteString(", ") + builder.WriteString("video_count=") + builder.WriteString(fmt.Sprintf("%v", _m.VideoCount)) + builder.WriteString(", ") + if v := _m.VideoResolution; v != nil { + builder.WriteString("video_resolution=") + builder.WriteString(*v) + } + builder.WriteString(", ") + if v := _m.VideoDurationSeconds; v != nil { + builder.WriteString("video_duration_seconds=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") builder.WriteString("cache_ttl_overridden=") builder.WriteString(fmt.Sprintf("%v", _m.CacheTTLOverridden)) builder.WriteString(", ") diff --git a/backend/ent/usagelog/usagelog.go b/backend/ent/usagelog/usagelog.go index 297e0b41ad..a74a92c40f 100644 --- a/backend/ent/usagelog/usagelog.go +++ b/backend/ent/usagelog/usagelog.go @@ -92,6 +92,12 @@ const ( FieldImageSizeSource = "image_size_source" // FieldImageSizeBreakdown holds the string denoting the image_size_breakdown field in the database. FieldImageSizeBreakdown = "image_size_breakdown" + // FieldVideoCount holds the string denoting the video_count field in the database. + FieldVideoCount = "video_count" + // FieldVideoResolution holds the string denoting the video_resolution field in the database. + FieldVideoResolution = "video_resolution" + // FieldVideoDurationSeconds holds the string denoting the video_duration_seconds field in the database. + FieldVideoDurationSeconds = "video_duration_seconds" // FieldCacheTTLOverridden holds the string denoting the cache_ttl_overridden field in the database. FieldCacheTTLOverridden = "cache_ttl_overridden" // FieldCreatedAt holds the string denoting the created_at field in the database. @@ -187,6 +193,9 @@ var Columns = []string{ FieldImageOutputSize, FieldImageSizeSource, FieldImageSizeBreakdown, + FieldVideoCount, + FieldVideoResolution, + FieldVideoDurationSeconds, FieldCacheTTLOverridden, FieldCreatedAt, } @@ -260,6 +269,10 @@ var ( ImageOutputSizeValidator func(string) error // ImageSizeSourceValidator is a validator for the "image_size_source" field. It is called by the builders before save. ImageSizeSourceValidator func(string) error + // DefaultVideoCount holds the default value on creation for the "video_count" field. + DefaultVideoCount int + // VideoResolutionValidator is a validator for the "video_resolution" field. It is called by the builders before save. + VideoResolutionValidator func(string) error // DefaultCacheTTLOverridden holds the default value on creation for the "cache_ttl_overridden" field. DefaultCacheTTLOverridden bool // DefaultCreatedAt holds the default value on creation for the "created_at" field. @@ -464,6 +477,21 @@ func ByImageSizeSource(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldImageSizeSource, opts...).ToFunc() } +// ByVideoCount orders the results by the video_count field. +func ByVideoCount(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVideoCount, opts...).ToFunc() +} + +// ByVideoResolution orders the results by the video_resolution field. +func ByVideoResolution(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVideoResolution, opts...).ToFunc() +} + +// ByVideoDurationSeconds orders the results by the video_duration_seconds field. +func ByVideoDurationSeconds(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVideoDurationSeconds, opts...).ToFunc() +} + // ByCacheTTLOverridden orders the results by the cache_ttl_overridden field. func ByCacheTTLOverridden(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCacheTTLOverridden, opts...).ToFunc() diff --git a/backend/ent/usagelog/where.go b/backend/ent/usagelog/where.go index 2987f17930..4b08cc3425 100644 --- a/backend/ent/usagelog/where.go +++ b/backend/ent/usagelog/where.go @@ -245,6 +245,21 @@ func ImageSizeSource(v string) predicate.UsageLog { return predicate.UsageLog(sql.FieldEQ(FieldImageSizeSource, v)) } +// VideoCount applies equality check predicate on the "video_count" field. It's identical to VideoCountEQ. +func VideoCount(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldEQ(FieldVideoCount, v)) +} + +// VideoResolution applies equality check predicate on the "video_resolution" field. It's identical to VideoResolutionEQ. +func VideoResolution(v string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldEQ(FieldVideoResolution, v)) +} + +// VideoDurationSeconds applies equality check predicate on the "video_duration_seconds" field. It's identical to VideoDurationSecondsEQ. +func VideoDurationSeconds(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldEQ(FieldVideoDurationSeconds, v)) +} + // CacheTTLOverridden applies equality check predicate on the "cache_ttl_overridden" field. It's identical to CacheTTLOverriddenEQ. func CacheTTLOverridden(v bool) predicate.UsageLog { return predicate.UsageLog(sql.FieldEQ(FieldCacheTTLOverridden, v)) @@ -2150,6 +2165,171 @@ func ImageSizeBreakdownNotNil() predicate.UsageLog { return predicate.UsageLog(sql.FieldNotNull(FieldImageSizeBreakdown)) } +// VideoCountEQ applies the EQ predicate on the "video_count" field. +func VideoCountEQ(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldEQ(FieldVideoCount, v)) +} + +// VideoCountNEQ applies the NEQ predicate on the "video_count" field. +func VideoCountNEQ(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldNEQ(FieldVideoCount, v)) +} + +// VideoCountIn applies the In predicate on the "video_count" field. +func VideoCountIn(vs ...int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldIn(FieldVideoCount, vs...)) +} + +// VideoCountNotIn applies the NotIn predicate on the "video_count" field. +func VideoCountNotIn(vs ...int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldNotIn(FieldVideoCount, vs...)) +} + +// VideoCountGT applies the GT predicate on the "video_count" field. +func VideoCountGT(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldGT(FieldVideoCount, v)) +} + +// VideoCountGTE applies the GTE predicate on the "video_count" field. +func VideoCountGTE(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldGTE(FieldVideoCount, v)) +} + +// VideoCountLT applies the LT predicate on the "video_count" field. +func VideoCountLT(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldLT(FieldVideoCount, v)) +} + +// VideoCountLTE applies the LTE predicate on the "video_count" field. +func VideoCountLTE(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldLTE(FieldVideoCount, v)) +} + +// VideoResolutionEQ applies the EQ predicate on the "video_resolution" field. +func VideoResolutionEQ(v string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldEQ(FieldVideoResolution, v)) +} + +// VideoResolutionNEQ applies the NEQ predicate on the "video_resolution" field. +func VideoResolutionNEQ(v string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldNEQ(FieldVideoResolution, v)) +} + +// VideoResolutionIn applies the In predicate on the "video_resolution" field. +func VideoResolutionIn(vs ...string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldIn(FieldVideoResolution, vs...)) +} + +// VideoResolutionNotIn applies the NotIn predicate on the "video_resolution" field. +func VideoResolutionNotIn(vs ...string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldNotIn(FieldVideoResolution, vs...)) +} + +// VideoResolutionGT applies the GT predicate on the "video_resolution" field. +func VideoResolutionGT(v string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldGT(FieldVideoResolution, v)) +} + +// VideoResolutionGTE applies the GTE predicate on the "video_resolution" field. +func VideoResolutionGTE(v string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldGTE(FieldVideoResolution, v)) +} + +// VideoResolutionLT applies the LT predicate on the "video_resolution" field. +func VideoResolutionLT(v string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldLT(FieldVideoResolution, v)) +} + +// VideoResolutionLTE applies the LTE predicate on the "video_resolution" field. +func VideoResolutionLTE(v string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldLTE(FieldVideoResolution, v)) +} + +// VideoResolutionContains applies the Contains predicate on the "video_resolution" field. +func VideoResolutionContains(v string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldContains(FieldVideoResolution, v)) +} + +// VideoResolutionHasPrefix applies the HasPrefix predicate on the "video_resolution" field. +func VideoResolutionHasPrefix(v string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldHasPrefix(FieldVideoResolution, v)) +} + +// VideoResolutionHasSuffix applies the HasSuffix predicate on the "video_resolution" field. +func VideoResolutionHasSuffix(v string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldHasSuffix(FieldVideoResolution, v)) +} + +// VideoResolutionIsNil applies the IsNil predicate on the "video_resolution" field. +func VideoResolutionIsNil() predicate.UsageLog { + return predicate.UsageLog(sql.FieldIsNull(FieldVideoResolution)) +} + +// VideoResolutionNotNil applies the NotNil predicate on the "video_resolution" field. +func VideoResolutionNotNil() predicate.UsageLog { + return predicate.UsageLog(sql.FieldNotNull(FieldVideoResolution)) +} + +// VideoResolutionEqualFold applies the EqualFold predicate on the "video_resolution" field. +func VideoResolutionEqualFold(v string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldEqualFold(FieldVideoResolution, v)) +} + +// VideoResolutionContainsFold applies the ContainsFold predicate on the "video_resolution" field. +func VideoResolutionContainsFold(v string) predicate.UsageLog { + return predicate.UsageLog(sql.FieldContainsFold(FieldVideoResolution, v)) +} + +// VideoDurationSecondsEQ applies the EQ predicate on the "video_duration_seconds" field. +func VideoDurationSecondsEQ(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldEQ(FieldVideoDurationSeconds, v)) +} + +// VideoDurationSecondsNEQ applies the NEQ predicate on the "video_duration_seconds" field. +func VideoDurationSecondsNEQ(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldNEQ(FieldVideoDurationSeconds, v)) +} + +// VideoDurationSecondsIn applies the In predicate on the "video_duration_seconds" field. +func VideoDurationSecondsIn(vs ...int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldIn(FieldVideoDurationSeconds, vs...)) +} + +// VideoDurationSecondsNotIn applies the NotIn predicate on the "video_duration_seconds" field. +func VideoDurationSecondsNotIn(vs ...int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldNotIn(FieldVideoDurationSeconds, vs...)) +} + +// VideoDurationSecondsGT applies the GT predicate on the "video_duration_seconds" field. +func VideoDurationSecondsGT(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldGT(FieldVideoDurationSeconds, v)) +} + +// VideoDurationSecondsGTE applies the GTE predicate on the "video_duration_seconds" field. +func VideoDurationSecondsGTE(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldGTE(FieldVideoDurationSeconds, v)) +} + +// VideoDurationSecondsLT applies the LT predicate on the "video_duration_seconds" field. +func VideoDurationSecondsLT(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldLT(FieldVideoDurationSeconds, v)) +} + +// VideoDurationSecondsLTE applies the LTE predicate on the "video_duration_seconds" field. +func VideoDurationSecondsLTE(v int) predicate.UsageLog { + return predicate.UsageLog(sql.FieldLTE(FieldVideoDurationSeconds, v)) +} + +// VideoDurationSecondsIsNil applies the IsNil predicate on the "video_duration_seconds" field. +func VideoDurationSecondsIsNil() predicate.UsageLog { + return predicate.UsageLog(sql.FieldIsNull(FieldVideoDurationSeconds)) +} + +// VideoDurationSecondsNotNil applies the NotNil predicate on the "video_duration_seconds" field. +func VideoDurationSecondsNotNil() predicate.UsageLog { + return predicate.UsageLog(sql.FieldNotNull(FieldVideoDurationSeconds)) +} + // CacheTTLOverriddenEQ applies the EQ predicate on the "cache_ttl_overridden" field. func CacheTTLOverriddenEQ(v bool) predicate.UsageLog { return predicate.UsageLog(sql.FieldEQ(FieldCacheTTLOverridden, v)) diff --git a/backend/ent/usagelog_create.go b/backend/ent/usagelog_create.go index 17e800f9ca..3326f72fc0 100644 --- a/backend/ent/usagelog_create.go +++ b/backend/ent/usagelog_create.go @@ -525,6 +525,48 @@ func (_c *UsageLogCreate) SetImageSizeBreakdown(v map[string]int) *UsageLogCreat return _c } +// SetVideoCount sets the "video_count" field. +func (_c *UsageLogCreate) SetVideoCount(v int) *UsageLogCreate { + _c.mutation.SetVideoCount(v) + return _c +} + +// SetNillableVideoCount sets the "video_count" field if the given value is not nil. +func (_c *UsageLogCreate) SetNillableVideoCount(v *int) *UsageLogCreate { + if v != nil { + _c.SetVideoCount(*v) + } + return _c +} + +// SetVideoResolution sets the "video_resolution" field. +func (_c *UsageLogCreate) SetVideoResolution(v string) *UsageLogCreate { + _c.mutation.SetVideoResolution(v) + return _c +} + +// SetNillableVideoResolution sets the "video_resolution" field if the given value is not nil. +func (_c *UsageLogCreate) SetNillableVideoResolution(v *string) *UsageLogCreate { + if v != nil { + _c.SetVideoResolution(*v) + } + return _c +} + +// SetVideoDurationSeconds sets the "video_duration_seconds" field. +func (_c *UsageLogCreate) SetVideoDurationSeconds(v int) *UsageLogCreate { + _c.mutation.SetVideoDurationSeconds(v) + return _c +} + +// SetNillableVideoDurationSeconds sets the "video_duration_seconds" field if the given value is not nil. +func (_c *UsageLogCreate) SetNillableVideoDurationSeconds(v *int) *UsageLogCreate { + if v != nil { + _c.SetVideoDurationSeconds(*v) + } + return _c +} + // SetCacheTTLOverridden sets the "cache_ttl_overridden" field. func (_c *UsageLogCreate) SetCacheTTLOverridden(v bool) *UsageLogCreate { _c.mutation.SetCacheTTLOverridden(v) @@ -677,6 +719,10 @@ func (_c *UsageLogCreate) defaults() { v := usagelog.DefaultImageCount _c.mutation.SetImageCount(v) } + if _, ok := _c.mutation.VideoCount(); !ok { + v := usagelog.DefaultVideoCount + _c.mutation.SetVideoCount(v) + } if _, ok := _c.mutation.CacheTTLOverridden(); !ok { v := usagelog.DefaultCacheTTLOverridden _c.mutation.SetCacheTTLOverridden(v) @@ -817,6 +863,14 @@ func (_c *UsageLogCreate) check() error { return &ValidationError{Name: "image_size_source", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size_source": %w`, err)} } } + if _, ok := _c.mutation.VideoCount(); !ok { + return &ValidationError{Name: "video_count", err: errors.New(`ent: missing required field "UsageLog.video_count"`)} + } + if v, ok := _c.mutation.VideoResolution(); ok { + if err := usagelog.VideoResolutionValidator(v); err != nil { + return &ValidationError{Name: "video_resolution", err: fmt.Errorf(`ent: validator failed for field "UsageLog.video_resolution": %w`, err)} + } + } if _, ok := _c.mutation.CacheTTLOverridden(); !ok { return &ValidationError{Name: "cache_ttl_overridden", err: errors.New(`ent: missing required field "UsageLog.cache_ttl_overridden"`)} } @@ -995,6 +1049,18 @@ func (_c *UsageLogCreate) createSpec() (*UsageLog, *sqlgraph.CreateSpec) { _spec.SetField(usagelog.FieldImageSizeBreakdown, field.TypeJSON, value) _node.ImageSizeBreakdown = value } + if value, ok := _c.mutation.VideoCount(); ok { + _spec.SetField(usagelog.FieldVideoCount, field.TypeInt, value) + _node.VideoCount = value + } + if value, ok := _c.mutation.VideoResolution(); ok { + _spec.SetField(usagelog.FieldVideoResolution, field.TypeString, value) + _node.VideoResolution = &value + } + if value, ok := _c.mutation.VideoDurationSeconds(); ok { + _spec.SetField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value) + _node.VideoDurationSeconds = &value + } if value, ok := _c.mutation.CacheTTLOverridden(); ok { _spec.SetField(usagelog.FieldCacheTTLOverridden, field.TypeBool, value) _node.CacheTTLOverridden = value @@ -1830,6 +1896,66 @@ func (u *UsageLogUpsert) ClearImageSizeBreakdown() *UsageLogUpsert { return u } +// SetVideoCount sets the "video_count" field. +func (u *UsageLogUpsert) SetVideoCount(v int) *UsageLogUpsert { + u.Set(usagelog.FieldVideoCount, v) + return u +} + +// UpdateVideoCount sets the "video_count" field to the value that was provided on create. +func (u *UsageLogUpsert) UpdateVideoCount() *UsageLogUpsert { + u.SetExcluded(usagelog.FieldVideoCount) + return u +} + +// AddVideoCount adds v to the "video_count" field. +func (u *UsageLogUpsert) AddVideoCount(v int) *UsageLogUpsert { + u.Add(usagelog.FieldVideoCount, v) + return u +} + +// SetVideoResolution sets the "video_resolution" field. +func (u *UsageLogUpsert) SetVideoResolution(v string) *UsageLogUpsert { + u.Set(usagelog.FieldVideoResolution, v) + return u +} + +// UpdateVideoResolution sets the "video_resolution" field to the value that was provided on create. +func (u *UsageLogUpsert) UpdateVideoResolution() *UsageLogUpsert { + u.SetExcluded(usagelog.FieldVideoResolution) + return u +} + +// ClearVideoResolution clears the value of the "video_resolution" field. +func (u *UsageLogUpsert) ClearVideoResolution() *UsageLogUpsert { + u.SetNull(usagelog.FieldVideoResolution) + return u +} + +// SetVideoDurationSeconds sets the "video_duration_seconds" field. +func (u *UsageLogUpsert) SetVideoDurationSeconds(v int) *UsageLogUpsert { + u.Set(usagelog.FieldVideoDurationSeconds, v) + return u +} + +// UpdateVideoDurationSeconds sets the "video_duration_seconds" field to the value that was provided on create. +func (u *UsageLogUpsert) UpdateVideoDurationSeconds() *UsageLogUpsert { + u.SetExcluded(usagelog.FieldVideoDurationSeconds) + return u +} + +// AddVideoDurationSeconds adds v to the "video_duration_seconds" field. +func (u *UsageLogUpsert) AddVideoDurationSeconds(v int) *UsageLogUpsert { + u.Add(usagelog.FieldVideoDurationSeconds, v) + return u +} + +// ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field. +func (u *UsageLogUpsert) ClearVideoDurationSeconds() *UsageLogUpsert { + u.SetNull(usagelog.FieldVideoDurationSeconds) + return u +} + // SetCacheTTLOverridden sets the "cache_ttl_overridden" field. func (u *UsageLogUpsert) SetCacheTTLOverridden(v bool) *UsageLogUpsert { u.Set(usagelog.FieldCacheTTLOverridden, v) @@ -2692,6 +2818,76 @@ func (u *UsageLogUpsertOne) ClearImageSizeBreakdown() *UsageLogUpsertOne { }) } +// SetVideoCount sets the "video_count" field. +func (u *UsageLogUpsertOne) SetVideoCount(v int) *UsageLogUpsertOne { + return u.Update(func(s *UsageLogUpsert) { + s.SetVideoCount(v) + }) +} + +// AddVideoCount adds v to the "video_count" field. +func (u *UsageLogUpsertOne) AddVideoCount(v int) *UsageLogUpsertOne { + return u.Update(func(s *UsageLogUpsert) { + s.AddVideoCount(v) + }) +} + +// UpdateVideoCount sets the "video_count" field to the value that was provided on create. +func (u *UsageLogUpsertOne) UpdateVideoCount() *UsageLogUpsertOne { + return u.Update(func(s *UsageLogUpsert) { + s.UpdateVideoCount() + }) +} + +// SetVideoResolution sets the "video_resolution" field. +func (u *UsageLogUpsertOne) SetVideoResolution(v string) *UsageLogUpsertOne { + return u.Update(func(s *UsageLogUpsert) { + s.SetVideoResolution(v) + }) +} + +// UpdateVideoResolution sets the "video_resolution" field to the value that was provided on create. +func (u *UsageLogUpsertOne) UpdateVideoResolution() *UsageLogUpsertOne { + return u.Update(func(s *UsageLogUpsert) { + s.UpdateVideoResolution() + }) +} + +// ClearVideoResolution clears the value of the "video_resolution" field. +func (u *UsageLogUpsertOne) ClearVideoResolution() *UsageLogUpsertOne { + return u.Update(func(s *UsageLogUpsert) { + s.ClearVideoResolution() + }) +} + +// SetVideoDurationSeconds sets the "video_duration_seconds" field. +func (u *UsageLogUpsertOne) SetVideoDurationSeconds(v int) *UsageLogUpsertOne { + return u.Update(func(s *UsageLogUpsert) { + s.SetVideoDurationSeconds(v) + }) +} + +// AddVideoDurationSeconds adds v to the "video_duration_seconds" field. +func (u *UsageLogUpsertOne) AddVideoDurationSeconds(v int) *UsageLogUpsertOne { + return u.Update(func(s *UsageLogUpsert) { + s.AddVideoDurationSeconds(v) + }) +} + +// UpdateVideoDurationSeconds sets the "video_duration_seconds" field to the value that was provided on create. +func (u *UsageLogUpsertOne) UpdateVideoDurationSeconds() *UsageLogUpsertOne { + return u.Update(func(s *UsageLogUpsert) { + s.UpdateVideoDurationSeconds() + }) +} + +// ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field. +func (u *UsageLogUpsertOne) ClearVideoDurationSeconds() *UsageLogUpsertOne { + return u.Update(func(s *UsageLogUpsert) { + s.ClearVideoDurationSeconds() + }) +} + // SetCacheTTLOverridden sets the "cache_ttl_overridden" field. func (u *UsageLogUpsertOne) SetCacheTTLOverridden(v bool) *UsageLogUpsertOne { return u.Update(func(s *UsageLogUpsert) { @@ -3722,6 +3918,76 @@ func (u *UsageLogUpsertBulk) ClearImageSizeBreakdown() *UsageLogUpsertBulk { }) } +// SetVideoCount sets the "video_count" field. +func (u *UsageLogUpsertBulk) SetVideoCount(v int) *UsageLogUpsertBulk { + return u.Update(func(s *UsageLogUpsert) { + s.SetVideoCount(v) + }) +} + +// AddVideoCount adds v to the "video_count" field. +func (u *UsageLogUpsertBulk) AddVideoCount(v int) *UsageLogUpsertBulk { + return u.Update(func(s *UsageLogUpsert) { + s.AddVideoCount(v) + }) +} + +// UpdateVideoCount sets the "video_count" field to the value that was provided on create. +func (u *UsageLogUpsertBulk) UpdateVideoCount() *UsageLogUpsertBulk { + return u.Update(func(s *UsageLogUpsert) { + s.UpdateVideoCount() + }) +} + +// SetVideoResolution sets the "video_resolution" field. +func (u *UsageLogUpsertBulk) SetVideoResolution(v string) *UsageLogUpsertBulk { + return u.Update(func(s *UsageLogUpsert) { + s.SetVideoResolution(v) + }) +} + +// UpdateVideoResolution sets the "video_resolution" field to the value that was provided on create. +func (u *UsageLogUpsertBulk) UpdateVideoResolution() *UsageLogUpsertBulk { + return u.Update(func(s *UsageLogUpsert) { + s.UpdateVideoResolution() + }) +} + +// ClearVideoResolution clears the value of the "video_resolution" field. +func (u *UsageLogUpsertBulk) ClearVideoResolution() *UsageLogUpsertBulk { + return u.Update(func(s *UsageLogUpsert) { + s.ClearVideoResolution() + }) +} + +// SetVideoDurationSeconds sets the "video_duration_seconds" field. +func (u *UsageLogUpsertBulk) SetVideoDurationSeconds(v int) *UsageLogUpsertBulk { + return u.Update(func(s *UsageLogUpsert) { + s.SetVideoDurationSeconds(v) + }) +} + +// AddVideoDurationSeconds adds v to the "video_duration_seconds" field. +func (u *UsageLogUpsertBulk) AddVideoDurationSeconds(v int) *UsageLogUpsertBulk { + return u.Update(func(s *UsageLogUpsert) { + s.AddVideoDurationSeconds(v) + }) +} + +// UpdateVideoDurationSeconds sets the "video_duration_seconds" field to the value that was provided on create. +func (u *UsageLogUpsertBulk) UpdateVideoDurationSeconds() *UsageLogUpsertBulk { + return u.Update(func(s *UsageLogUpsert) { + s.UpdateVideoDurationSeconds() + }) +} + +// ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field. +func (u *UsageLogUpsertBulk) ClearVideoDurationSeconds() *UsageLogUpsertBulk { + return u.Update(func(s *UsageLogUpsert) { + s.ClearVideoDurationSeconds() + }) +} + // SetCacheTTLOverridden sets the "cache_ttl_overridden" field. func (u *UsageLogUpsertBulk) SetCacheTTLOverridden(v bool) *UsageLogUpsertBulk { return u.Update(func(s *UsageLogUpsert) { diff --git a/backend/ent/usagelog_update.go b/backend/ent/usagelog_update.go index e8fa003c63..00a65ccff1 100644 --- a/backend/ent/usagelog_update.go +++ b/backend/ent/usagelog_update.go @@ -811,6 +811,74 @@ func (_u *UsageLogUpdate) ClearImageSizeBreakdown() *UsageLogUpdate { return _u } +// SetVideoCount sets the "video_count" field. +func (_u *UsageLogUpdate) SetVideoCount(v int) *UsageLogUpdate { + _u.mutation.ResetVideoCount() + _u.mutation.SetVideoCount(v) + return _u +} + +// SetNillableVideoCount sets the "video_count" field if the given value is not nil. +func (_u *UsageLogUpdate) SetNillableVideoCount(v *int) *UsageLogUpdate { + if v != nil { + _u.SetVideoCount(*v) + } + return _u +} + +// AddVideoCount adds value to the "video_count" field. +func (_u *UsageLogUpdate) AddVideoCount(v int) *UsageLogUpdate { + _u.mutation.AddVideoCount(v) + return _u +} + +// SetVideoResolution sets the "video_resolution" field. +func (_u *UsageLogUpdate) SetVideoResolution(v string) *UsageLogUpdate { + _u.mutation.SetVideoResolution(v) + return _u +} + +// SetNillableVideoResolution sets the "video_resolution" field if the given value is not nil. +func (_u *UsageLogUpdate) SetNillableVideoResolution(v *string) *UsageLogUpdate { + if v != nil { + _u.SetVideoResolution(*v) + } + return _u +} + +// ClearVideoResolution clears the value of the "video_resolution" field. +func (_u *UsageLogUpdate) ClearVideoResolution() *UsageLogUpdate { + _u.mutation.ClearVideoResolution() + return _u +} + +// SetVideoDurationSeconds sets the "video_duration_seconds" field. +func (_u *UsageLogUpdate) SetVideoDurationSeconds(v int) *UsageLogUpdate { + _u.mutation.ResetVideoDurationSeconds() + _u.mutation.SetVideoDurationSeconds(v) + return _u +} + +// SetNillableVideoDurationSeconds sets the "video_duration_seconds" field if the given value is not nil. +func (_u *UsageLogUpdate) SetNillableVideoDurationSeconds(v *int) *UsageLogUpdate { + if v != nil { + _u.SetVideoDurationSeconds(*v) + } + return _u +} + +// AddVideoDurationSeconds adds value to the "video_duration_seconds" field. +func (_u *UsageLogUpdate) AddVideoDurationSeconds(v int) *UsageLogUpdate { + _u.mutation.AddVideoDurationSeconds(v) + return _u +} + +// ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field. +func (_u *UsageLogUpdate) ClearVideoDurationSeconds() *UsageLogUpdate { + _u.mutation.ClearVideoDurationSeconds() + return _u +} + // SetCacheTTLOverridden sets the "cache_ttl_overridden" field. func (_u *UsageLogUpdate) SetCacheTTLOverridden(v bool) *UsageLogUpdate { _u.mutation.SetCacheTTLOverridden(v) @@ -979,6 +1047,11 @@ func (_u *UsageLogUpdate) check() error { return &ValidationError{Name: "image_size_source", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size_source": %w`, err)} } } + if v, ok := _u.mutation.VideoResolution(); ok { + if err := usagelog.VideoResolutionValidator(v); err != nil { + return &ValidationError{Name: "video_resolution", err: fmt.Errorf(`ent: validator failed for field "UsageLog.video_resolution": %w`, err)} + } + } if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UsageLog.user"`) } @@ -1210,6 +1283,27 @@ func (_u *UsageLogUpdate) sqlSave(ctx context.Context) (_node int, err error) { if _u.mutation.ImageSizeBreakdownCleared() { _spec.ClearField(usagelog.FieldImageSizeBreakdown, field.TypeJSON) } + if value, ok := _u.mutation.VideoCount(); ok { + _spec.SetField(usagelog.FieldVideoCount, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedVideoCount(); ok { + _spec.AddField(usagelog.FieldVideoCount, field.TypeInt, value) + } + if value, ok := _u.mutation.VideoResolution(); ok { + _spec.SetField(usagelog.FieldVideoResolution, field.TypeString, value) + } + if _u.mutation.VideoResolutionCleared() { + _spec.ClearField(usagelog.FieldVideoResolution, field.TypeString) + } + if value, ok := _u.mutation.VideoDurationSeconds(); ok { + _spec.SetField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedVideoDurationSeconds(); ok { + _spec.AddField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value) + } + if _u.mutation.VideoDurationSecondsCleared() { + _spec.ClearField(usagelog.FieldVideoDurationSeconds, field.TypeInt) + } if value, ok := _u.mutation.CacheTTLOverridden(); ok { _spec.SetField(usagelog.FieldCacheTTLOverridden, field.TypeBool, value) } @@ -2157,6 +2251,74 @@ func (_u *UsageLogUpdateOne) ClearImageSizeBreakdown() *UsageLogUpdateOne { return _u } +// SetVideoCount sets the "video_count" field. +func (_u *UsageLogUpdateOne) SetVideoCount(v int) *UsageLogUpdateOne { + _u.mutation.ResetVideoCount() + _u.mutation.SetVideoCount(v) + return _u +} + +// SetNillableVideoCount sets the "video_count" field if the given value is not nil. +func (_u *UsageLogUpdateOne) SetNillableVideoCount(v *int) *UsageLogUpdateOne { + if v != nil { + _u.SetVideoCount(*v) + } + return _u +} + +// AddVideoCount adds value to the "video_count" field. +func (_u *UsageLogUpdateOne) AddVideoCount(v int) *UsageLogUpdateOne { + _u.mutation.AddVideoCount(v) + return _u +} + +// SetVideoResolution sets the "video_resolution" field. +func (_u *UsageLogUpdateOne) SetVideoResolution(v string) *UsageLogUpdateOne { + _u.mutation.SetVideoResolution(v) + return _u +} + +// SetNillableVideoResolution sets the "video_resolution" field if the given value is not nil. +func (_u *UsageLogUpdateOne) SetNillableVideoResolution(v *string) *UsageLogUpdateOne { + if v != nil { + _u.SetVideoResolution(*v) + } + return _u +} + +// ClearVideoResolution clears the value of the "video_resolution" field. +func (_u *UsageLogUpdateOne) ClearVideoResolution() *UsageLogUpdateOne { + _u.mutation.ClearVideoResolution() + return _u +} + +// SetVideoDurationSeconds sets the "video_duration_seconds" field. +func (_u *UsageLogUpdateOne) SetVideoDurationSeconds(v int) *UsageLogUpdateOne { + _u.mutation.ResetVideoDurationSeconds() + _u.mutation.SetVideoDurationSeconds(v) + return _u +} + +// SetNillableVideoDurationSeconds sets the "video_duration_seconds" field if the given value is not nil. +func (_u *UsageLogUpdateOne) SetNillableVideoDurationSeconds(v *int) *UsageLogUpdateOne { + if v != nil { + _u.SetVideoDurationSeconds(*v) + } + return _u +} + +// AddVideoDurationSeconds adds value to the "video_duration_seconds" field. +func (_u *UsageLogUpdateOne) AddVideoDurationSeconds(v int) *UsageLogUpdateOne { + _u.mutation.AddVideoDurationSeconds(v) + return _u +} + +// ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field. +func (_u *UsageLogUpdateOne) ClearVideoDurationSeconds() *UsageLogUpdateOne { + _u.mutation.ClearVideoDurationSeconds() + return _u +} + // SetCacheTTLOverridden sets the "cache_ttl_overridden" field. func (_u *UsageLogUpdateOne) SetCacheTTLOverridden(v bool) *UsageLogUpdateOne { _u.mutation.SetCacheTTLOverridden(v) @@ -2338,6 +2500,11 @@ func (_u *UsageLogUpdateOne) check() error { return &ValidationError{Name: "image_size_source", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size_source": %w`, err)} } } + if v, ok := _u.mutation.VideoResolution(); ok { + if err := usagelog.VideoResolutionValidator(v); err != nil { + return &ValidationError{Name: "video_resolution", err: fmt.Errorf(`ent: validator failed for field "UsageLog.video_resolution": %w`, err)} + } + } if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UsageLog.user"`) } @@ -2586,6 +2753,27 @@ func (_u *UsageLogUpdateOne) sqlSave(ctx context.Context) (_node *UsageLog, err if _u.mutation.ImageSizeBreakdownCleared() { _spec.ClearField(usagelog.FieldImageSizeBreakdown, field.TypeJSON) } + if value, ok := _u.mutation.VideoCount(); ok { + _spec.SetField(usagelog.FieldVideoCount, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedVideoCount(); ok { + _spec.AddField(usagelog.FieldVideoCount, field.TypeInt, value) + } + if value, ok := _u.mutation.VideoResolution(); ok { + _spec.SetField(usagelog.FieldVideoResolution, field.TypeString, value) + } + if _u.mutation.VideoResolutionCleared() { + _spec.ClearField(usagelog.FieldVideoResolution, field.TypeString) + } + if value, ok := _u.mutation.VideoDurationSeconds(); ok { + _spec.SetField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedVideoDurationSeconds(); ok { + _spec.AddField(usagelog.FieldVideoDurationSeconds, field.TypeInt, value) + } + if _u.mutation.VideoDurationSecondsCleared() { + _spec.ClearField(usagelog.FieldVideoDurationSeconds, field.TypeInt) + } if value, ok := _u.mutation.CacheTTLOverridden(); ok { _spec.SetField(usagelog.FieldCacheTTLOverridden, field.TypeBool, value) } diff --git a/backend/go.mod b/backend/go.mod index 53d0596ef5..a06f06437d 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -1,6 +1,6 @@ module github.com/Wei-Shaw/sub2api -go 1.26.4 +go 1.26.5 require ( entgo.io/ent v0.14.5 diff --git a/backend/internal/handler/admin/group_handler.go b/backend/internal/handler/admin/group_handler.go index 4595adeb24..56a0b29ed0 100644 --- a/backend/internal/handler/admin/group_handler.go +++ b/backend/internal/handler/admin/group_handler.go @@ -98,6 +98,8 @@ type CreateGroupRequest struct { ImageRateMultiplier *float64 `json:"image_rate_multiplier"` BatchImageDiscountMultiplier *float64 `json:"batch_image_discount_multiplier"` BatchImageHoldMultiplier *float64 `json:"batch_image_hold_multiplier"` + VideoRateIndependent bool `json:"video_rate_independent"` + VideoRateMultiplier *float64 `json:"video_rate_multiplier"` PeakRateEnabled bool `json:"peak_rate_enabled"` PeakStart string `json:"peak_start"` PeakEnd string `json:"peak_end"` @@ -105,6 +107,9 @@ type CreateGroupRequest struct { ImagePrice1K *float64 `json:"image_price_1k"` ImagePrice2K *float64 `json:"image_price_2k"` ImagePrice4K *float64 `json:"image_price_4k"` + VideoPrice480P *float64 `json:"video_price_480p"` + VideoPrice720P *float64 `json:"video_price_720p"` + VideoPrice1080P *float64 `json:"video_price_1080p"` ClaudeCodeOnly bool `json:"claude_code_only"` FallbackGroupID *int64 `json:"fallback_group_id"` FallbackGroupIDOnInvalidRequest *int64 `json:"fallback_group_id_on_invalid_request"` @@ -146,6 +151,8 @@ type UpdateGroupRequest struct { ImageRateMultiplier *float64 `json:"image_rate_multiplier"` BatchImageDiscountMultiplier *float64 `json:"batch_image_discount_multiplier"` BatchImageHoldMultiplier *float64 `json:"batch_image_hold_multiplier"` + VideoRateIndependent *bool `json:"video_rate_independent"` + VideoRateMultiplier *float64 `json:"video_rate_multiplier"` PeakRateEnabled *bool `json:"peak_rate_enabled"` PeakStart *string `json:"peak_start"` PeakEnd *string `json:"peak_end"` @@ -153,6 +160,9 @@ type UpdateGroupRequest struct { ImagePrice1K *float64 `json:"image_price_1k"` ImagePrice2K *float64 `json:"image_price_2k"` ImagePrice4K *float64 `json:"image_price_4k"` + VideoPrice480P *float64 `json:"video_price_480p"` + VideoPrice720P *float64 `json:"video_price_720p"` + VideoPrice1080P *float64 `json:"video_price_1080p"` ClaudeCodeOnly *bool `json:"claude_code_only"` FallbackGroupID *int64 `json:"fallback_group_id"` FallbackGroupIDOnInvalidRequest *int64 `json:"fallback_group_id_on_invalid_request"` @@ -312,6 +322,8 @@ func (h *GroupHandler) Create(c *gin.Context) { ImageRateMultiplier: req.ImageRateMultiplier, BatchImageDiscountMultiplier: req.BatchImageDiscountMultiplier, BatchImageHoldMultiplier: req.BatchImageHoldMultiplier, + VideoRateIndependent: req.VideoRateIndependent, + VideoRateMultiplier: req.VideoRateMultiplier, PeakRateEnabled: req.PeakRateEnabled, PeakStart: req.PeakStart, PeakEnd: req.PeakEnd, @@ -319,6 +331,9 @@ func (h *GroupHandler) Create(c *gin.Context) { ImagePrice1K: req.ImagePrice1K, ImagePrice2K: req.ImagePrice2K, ImagePrice4K: req.ImagePrice4K, + VideoPrice480P: req.VideoPrice480P, + VideoPrice720P: req.VideoPrice720P, + VideoPrice1080P: req.VideoPrice1080P, ClaudeCodeOnly: req.ClaudeCodeOnly, FallbackGroupID: req.FallbackGroupID, FallbackGroupIDOnInvalidRequest: req.FallbackGroupIDOnInvalidRequest, @@ -375,6 +390,8 @@ func (h *GroupHandler) Update(c *gin.Context) { ImageRateMultiplier: req.ImageRateMultiplier, BatchImageDiscountMultiplier: req.BatchImageDiscountMultiplier, BatchImageHoldMultiplier: req.BatchImageHoldMultiplier, + VideoRateIndependent: req.VideoRateIndependent, + VideoRateMultiplier: req.VideoRateMultiplier, PeakRateEnabled: req.PeakRateEnabled, PeakStart: req.PeakStart, PeakEnd: req.PeakEnd, @@ -382,6 +399,9 @@ func (h *GroupHandler) Update(c *gin.Context) { ImagePrice1K: req.ImagePrice1K, ImagePrice2K: req.ImagePrice2K, ImagePrice4K: req.ImagePrice4K, + VideoPrice480P: req.VideoPrice480P, + VideoPrice720P: req.VideoPrice720P, + VideoPrice1080P: req.VideoPrice1080P, ClaudeCodeOnly: req.ClaudeCodeOnly, FallbackGroupID: req.FallbackGroupID, FallbackGroupIDOnInvalidRequest: req.FallbackGroupIDOnInvalidRequest, diff --git a/backend/internal/handler/admin/setting_handler_email.go b/backend/internal/handler/admin/setting_handler_email.go index 9ff0529a5b..68d76de6cc 100644 --- a/backend/internal/handler/admin/setting_handler_email.go +++ b/backend/internal/handler/admin/setting_handler_email.go @@ -1,6 +1,7 @@ package admin import ( + "html" "strings" "github.com/Wei-Shaw/sub2api/internal/handler/dto" @@ -163,7 +164,7 @@ func (h *SettingHandler) SendTestEmail(c *gin.Context) {