diff --git a/ent/blockedvideos_query.go b/ent/blockedvideos_query.go index 4519cc43..b4f01140 100644 --- a/ent/blockedvideos_query.go +++ b/ent/blockedvideos_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -60,7 +61,7 @@ func (bvq *BlockedVideosQuery) Order(o ...blockedvideos.OrderOption) *BlockedVid // First returns the first BlockedVideos entity from the query. // Returns a *NotFoundError when no BlockedVideos was found. func (bvq *BlockedVideosQuery) First(ctx context.Context) (*BlockedVideos, error) { - nodes, err := bvq.Limit(1).All(setContextOp(ctx, bvq.ctx, "First")) + nodes, err := bvq.Limit(1).All(setContextOp(ctx, bvq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -83,7 +84,7 @@ func (bvq *BlockedVideosQuery) FirstX(ctx context.Context) *BlockedVideos { // Returns a *NotFoundError when no BlockedVideos ID was found. func (bvq *BlockedVideosQuery) FirstID(ctx context.Context) (id string, err error) { var ids []string - if ids, err = bvq.Limit(1).IDs(setContextOp(ctx, bvq.ctx, "FirstID")); err != nil { + if ids, err = bvq.Limit(1).IDs(setContextOp(ctx, bvq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -106,7 +107,7 @@ func (bvq *BlockedVideosQuery) FirstIDX(ctx context.Context) string { // Returns a *NotSingularError when more than one BlockedVideos entity is found. // Returns a *NotFoundError when no BlockedVideos entities are found. func (bvq *BlockedVideosQuery) Only(ctx context.Context) (*BlockedVideos, error) { - nodes, err := bvq.Limit(2).All(setContextOp(ctx, bvq.ctx, "Only")) + nodes, err := bvq.Limit(2).All(setContextOp(ctx, bvq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -134,7 +135,7 @@ func (bvq *BlockedVideosQuery) OnlyX(ctx context.Context) *BlockedVideos { // Returns a *NotFoundError when no entities are found. func (bvq *BlockedVideosQuery) OnlyID(ctx context.Context) (id string, err error) { var ids []string - if ids, err = bvq.Limit(2).IDs(setContextOp(ctx, bvq.ctx, "OnlyID")); err != nil { + if ids, err = bvq.Limit(2).IDs(setContextOp(ctx, bvq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -159,7 +160,7 @@ func (bvq *BlockedVideosQuery) OnlyIDX(ctx context.Context) string { // All executes the query and returns a list of BlockedVideosSlice. func (bvq *BlockedVideosQuery) All(ctx context.Context) ([]*BlockedVideos, error) { - ctx = setContextOp(ctx, bvq.ctx, "All") + ctx = setContextOp(ctx, bvq.ctx, ent.OpQueryAll) if err := bvq.prepareQuery(ctx); err != nil { return nil, err } @@ -181,7 +182,7 @@ func (bvq *BlockedVideosQuery) IDs(ctx context.Context) (ids []string, err error if bvq.ctx.Unique == nil && bvq.path != nil { bvq.Unique(true) } - ctx = setContextOp(ctx, bvq.ctx, "IDs") + ctx = setContextOp(ctx, bvq.ctx, ent.OpQueryIDs) if err = bvq.Select(blockedvideos.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -199,7 +200,7 @@ func (bvq *BlockedVideosQuery) IDsX(ctx context.Context) []string { // Count returns the count of the given query. func (bvq *BlockedVideosQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, bvq.ctx, "Count") + ctx = setContextOp(ctx, bvq.ctx, ent.OpQueryCount) if err := bvq.prepareQuery(ctx); err != nil { return 0, err } @@ -217,7 +218,7 @@ func (bvq *BlockedVideosQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (bvq *BlockedVideosQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, bvq.ctx, "Exist") + ctx = setContextOp(ctx, bvq.ctx, ent.OpQueryExist) switch _, err := bvq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -449,7 +450,7 @@ func (bvgb *BlockedVideosGroupBy) Aggregate(fns ...AggregateFunc) *BlockedVideos // Scan applies the selector query and scans the result into the given value. func (bvgb *BlockedVideosGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, bvgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, bvgb.build.ctx, ent.OpQueryGroupBy) if err := bvgb.build.prepareQuery(ctx); err != nil { return err } @@ -497,7 +498,7 @@ func (bvs *BlockedVideosSelect) Aggregate(fns ...AggregateFunc) *BlockedVideosSe // Scan applies the selector query and scans the result into the given value. func (bvs *BlockedVideosSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, bvs.ctx, "Select") + ctx = setContextOp(ctx, bvs.ctx, ent.OpQuerySelect) if err := bvs.prepareQuery(ctx); err != nil { return err } diff --git a/ent/channel_query.go b/ent/channel_query.go index 72e3526e..359e3994 100644 --- a/ent/channel_query.go +++ b/ent/channel_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -110,7 +111,7 @@ func (cq *ChannelQuery) QueryLive() *LiveQuery { // First returns the first Channel entity from the query. // Returns a *NotFoundError when no Channel was found. func (cq *ChannelQuery) First(ctx context.Context) (*Channel, error) { - nodes, err := cq.Limit(1).All(setContextOp(ctx, cq.ctx, "First")) + nodes, err := cq.Limit(1).All(setContextOp(ctx, cq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -133,7 +134,7 @@ func (cq *ChannelQuery) FirstX(ctx context.Context) *Channel { // Returns a *NotFoundError when no Channel ID was found. func (cq *ChannelQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = cq.Limit(1).IDs(setContextOp(ctx, cq.ctx, "FirstID")); err != nil { + if ids, err = cq.Limit(1).IDs(setContextOp(ctx, cq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -156,7 +157,7 @@ func (cq *ChannelQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one Channel entity is found. // Returns a *NotFoundError when no Channel entities are found. func (cq *ChannelQuery) Only(ctx context.Context) (*Channel, error) { - nodes, err := cq.Limit(2).All(setContextOp(ctx, cq.ctx, "Only")) + nodes, err := cq.Limit(2).All(setContextOp(ctx, cq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -184,7 +185,7 @@ func (cq *ChannelQuery) OnlyX(ctx context.Context) *Channel { // Returns a *NotFoundError when no entities are found. func (cq *ChannelQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = cq.Limit(2).IDs(setContextOp(ctx, cq.ctx, "OnlyID")); err != nil { + if ids, err = cq.Limit(2).IDs(setContextOp(ctx, cq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -209,7 +210,7 @@ func (cq *ChannelQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Channels. func (cq *ChannelQuery) All(ctx context.Context) ([]*Channel, error) { - ctx = setContextOp(ctx, cq.ctx, "All") + ctx = setContextOp(ctx, cq.ctx, ent.OpQueryAll) if err := cq.prepareQuery(ctx); err != nil { return nil, err } @@ -231,7 +232,7 @@ func (cq *ChannelQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if cq.ctx.Unique == nil && cq.path != nil { cq.Unique(true) } - ctx = setContextOp(ctx, cq.ctx, "IDs") + ctx = setContextOp(ctx, cq.ctx, ent.OpQueryIDs) if err = cq.Select(channel.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -249,7 +250,7 @@ func (cq *ChannelQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (cq *ChannelQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, cq.ctx, "Count") + ctx = setContextOp(ctx, cq.ctx, ent.OpQueryCount) if err := cq.prepareQuery(ctx); err != nil { return 0, err } @@ -267,7 +268,7 @@ func (cq *ChannelQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (cq *ChannelQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, cq.ctx, "Exist") + ctx = setContextOp(ctx, cq.ctx, ent.OpQueryExist) switch _, err := cq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -605,7 +606,7 @@ func (cgb *ChannelGroupBy) Aggregate(fns ...AggregateFunc) *ChannelGroupBy { // Scan applies the selector query and scans the result into the given value. func (cgb *ChannelGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, cgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, cgb.build.ctx, ent.OpQueryGroupBy) if err := cgb.build.prepareQuery(ctx); err != nil { return err } @@ -653,7 +654,7 @@ func (cs *ChannelSelect) Aggregate(fns ...AggregateFunc) *ChannelSelect { // Scan applies the selector query and scans the result into the given value. func (cs *ChannelSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, cs.ctx, "Select") + ctx = setContextOp(ctx, cs.ctx, ent.OpQuerySelect) if err := cs.prepareQuery(ctx); err != nil { return err } diff --git a/ent/chapter_create.go b/ent/chapter_create.go index 182a8070..54b9f472 100644 --- a/ent/chapter_create.go +++ b/ent/chapter_create.go @@ -148,7 +148,7 @@ func (cc *ChapterCreate) defaults() { // check runs all checks and user-defined validators on the builder. func (cc *ChapterCreate) check() error { - if _, ok := cc.mutation.VodID(); !ok { + if len(cc.mutation.VodIDs()) == 0 { return &ValidationError{Name: "vod", err: errors.New(`ent: missing required edge "Chapter.vod"`)} } return nil diff --git a/ent/chapter_query.go b/ent/chapter_query.go index 67be8bb6..8e642579 100644 --- a/ent/chapter_query.go +++ b/ent/chapter_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -86,7 +87,7 @@ func (cq *ChapterQuery) QueryVod() *VodQuery { // First returns the first Chapter entity from the query. // Returns a *NotFoundError when no Chapter was found. func (cq *ChapterQuery) First(ctx context.Context) (*Chapter, error) { - nodes, err := cq.Limit(1).All(setContextOp(ctx, cq.ctx, "First")) + nodes, err := cq.Limit(1).All(setContextOp(ctx, cq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -109,7 +110,7 @@ func (cq *ChapterQuery) FirstX(ctx context.Context) *Chapter { // Returns a *NotFoundError when no Chapter ID was found. func (cq *ChapterQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = cq.Limit(1).IDs(setContextOp(ctx, cq.ctx, "FirstID")); err != nil { + if ids, err = cq.Limit(1).IDs(setContextOp(ctx, cq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -132,7 +133,7 @@ func (cq *ChapterQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one Chapter entity is found. // Returns a *NotFoundError when no Chapter entities are found. func (cq *ChapterQuery) Only(ctx context.Context) (*Chapter, error) { - nodes, err := cq.Limit(2).All(setContextOp(ctx, cq.ctx, "Only")) + nodes, err := cq.Limit(2).All(setContextOp(ctx, cq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -160,7 +161,7 @@ func (cq *ChapterQuery) OnlyX(ctx context.Context) *Chapter { // Returns a *NotFoundError when no entities are found. func (cq *ChapterQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = cq.Limit(2).IDs(setContextOp(ctx, cq.ctx, "OnlyID")); err != nil { + if ids, err = cq.Limit(2).IDs(setContextOp(ctx, cq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -185,7 +186,7 @@ func (cq *ChapterQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Chapters. func (cq *ChapterQuery) All(ctx context.Context) ([]*Chapter, error) { - ctx = setContextOp(ctx, cq.ctx, "All") + ctx = setContextOp(ctx, cq.ctx, ent.OpQueryAll) if err := cq.prepareQuery(ctx); err != nil { return nil, err } @@ -207,7 +208,7 @@ func (cq *ChapterQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if cq.ctx.Unique == nil && cq.path != nil { cq.Unique(true) } - ctx = setContextOp(ctx, cq.ctx, "IDs") + ctx = setContextOp(ctx, cq.ctx, ent.OpQueryIDs) if err = cq.Select(chapter.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -225,7 +226,7 @@ func (cq *ChapterQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (cq *ChapterQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, cq.ctx, "Count") + ctx = setContextOp(ctx, cq.ctx, ent.OpQueryCount) if err := cq.prepareQuery(ctx); err != nil { return 0, err } @@ -243,7 +244,7 @@ func (cq *ChapterQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (cq *ChapterQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, cq.ctx, "Exist") + ctx = setContextOp(ctx, cq.ctx, ent.OpQueryExist) switch _, err := cq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -537,7 +538,7 @@ func (cgb *ChapterGroupBy) Aggregate(fns ...AggregateFunc) *ChapterGroupBy { // Scan applies the selector query and scans the result into the given value. func (cgb *ChapterGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, cgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, cgb.build.ctx, ent.OpQueryGroupBy) if err := cgb.build.prepareQuery(ctx); err != nil { return err } @@ -585,7 +586,7 @@ func (cs *ChapterSelect) Aggregate(fns ...AggregateFunc) *ChapterSelect { // Scan applies the selector query and scans the result into the given value. func (cs *ChapterSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, cs.ctx, "Select") + ctx = setContextOp(ctx, cs.ctx, ent.OpQuerySelect) if err := cs.prepareQuery(ctx); err != nil { return err } diff --git a/ent/chapter_update.go b/ent/chapter_update.go index 22252bd3..60607628 100644 --- a/ent/chapter_update.go +++ b/ent/chapter_update.go @@ -174,7 +174,7 @@ func (cu *ChapterUpdate) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (cu *ChapterUpdate) check() error { - if _, ok := cu.mutation.VodID(); cu.mutation.VodCleared() && !ok { + if cu.mutation.VodCleared() && len(cu.mutation.VodIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Chapter.vod"`) } return nil @@ -429,7 +429,7 @@ func (cuo *ChapterUpdateOne) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (cuo *ChapterUpdateOne) check() error { - if _, ok := cuo.mutation.VodID(); cuo.mutation.VodCleared() && !ok { + if cuo.mutation.VodCleared() && len(cuo.mutation.VodIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Chapter.vod"`) } return nil diff --git a/ent/ent.go b/ent/ent.go index 8ebe3d1c..6a84269c 100644 --- a/ent/ent.go +++ b/ent/ent.go @@ -83,7 +83,7 @@ var ( columnCheck sql.ColumnCheck ) -// columnChecker checks if the column exists in the given table. +// checkColumn checks if the column exists in the given table. func checkColumn(table, column string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ diff --git a/ent/live.go b/ent/live.go index 0e658dce..545f2de5 100644 --- a/ent/live.go +++ b/ent/live.go @@ -53,6 +53,8 @@ type Live struct { ClipsIntervalDays int `json:"clips_interval_days"` // Time when clips were last checked. ClipsLastChecked time.Time `json:"clips_last_checked"` + // Ignore last checked time and check all clips. + ClipsIgnoreLastChecked bool `json:"clips_ignore_last_checked"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt time.Time `json:"updated_at"` // CreatedAt holds the value of the "created_at" field. @@ -111,7 +113,7 @@ func (*Live) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case live.FieldWatchLive, live.FieldWatchVod, live.FieldDownloadArchives, live.FieldDownloadHighlights, live.FieldDownloadUploads, live.FieldDownloadSubOnly, live.FieldIsLive, live.FieldArchiveChat, live.FieldRenderChat, live.FieldApplyCategoriesToLive, live.FieldWatchClips: + case live.FieldWatchLive, live.FieldWatchVod, live.FieldDownloadArchives, live.FieldDownloadHighlights, live.FieldDownloadUploads, live.FieldDownloadSubOnly, live.FieldIsLive, live.FieldArchiveChat, live.FieldRenderChat, live.FieldApplyCategoriesToLive, live.FieldWatchClips, live.FieldClipsIgnoreLastChecked: values[i] = new(sql.NullBool) case live.FieldVideoAge, live.FieldClipsLimit, live.FieldClipsIntervalDays: values[i] = new(sql.NullInt64) @@ -246,6 +248,12 @@ func (l *Live) assignValues(columns []string, values []any) error { } else if value.Valid { l.ClipsLastChecked = value.Time } + case live.FieldClipsIgnoreLastChecked: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field clips_ignore_last_checked", values[i]) + } else if value.Valid { + l.ClipsIgnoreLastChecked = value.Bool + } case live.FieldUpdatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field updated_at", values[i]) @@ -367,6 +375,9 @@ func (l *Live) String() string { builder.WriteString("clips_last_checked=") builder.WriteString(l.ClipsLastChecked.Format(time.ANSIC)) builder.WriteString(", ") + builder.WriteString("clips_ignore_last_checked=") + builder.WriteString(fmt.Sprintf("%v", l.ClipsIgnoreLastChecked)) + builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(l.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") diff --git a/ent/live/live.go b/ent/live/live.go index 35d29dab..93799ca2 100644 --- a/ent/live/live.go +++ b/ent/live/live.go @@ -49,6 +49,8 @@ const ( FieldClipsIntervalDays = "clips_interval_days" // FieldClipsLastChecked holds the string denoting the clips_last_checked field in the database. FieldClipsLastChecked = "clips_last_checked" + // FieldClipsIgnoreLastChecked holds the string denoting the clips_ignore_last_checked field in the database. + FieldClipsIgnoreLastChecked = "clips_ignore_last_checked" // FieldUpdatedAt holds the string denoting the updated_at field in the database. FieldUpdatedAt = "updated_at" // FieldCreatedAt holds the string denoting the created_at field in the database. @@ -104,6 +106,7 @@ var Columns = []string{ FieldClipsLimit, FieldClipsIntervalDays, FieldClipsLastChecked, + FieldClipsIgnoreLastChecked, FieldUpdatedAt, FieldCreatedAt, } @@ -162,6 +165,8 @@ var ( DefaultClipsLimit int // DefaultClipsIntervalDays holds the default value on creation for the "clips_interval_days" field. DefaultClipsIntervalDays int + // DefaultClipsIgnoreLastChecked holds the default value on creation for the "clips_ignore_last_checked" field. + DefaultClipsIgnoreLastChecked bool // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. DefaultUpdatedAt func() time.Time // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. @@ -265,6 +270,11 @@ func ByClipsLastChecked(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldClipsLastChecked, opts...).ToFunc() } +// ByClipsIgnoreLastChecked orders the results by the clips_ignore_last_checked field. +func ByClipsIgnoreLastChecked(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldClipsIgnoreLastChecked, opts...).ToFunc() +} + // ByUpdatedAt orders the results by the updated_at field. func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() diff --git a/ent/live/where.go b/ent/live/where.go index ec283913..4acc4a51 100644 --- a/ent/live/where.go +++ b/ent/live/where.go @@ -141,6 +141,11 @@ func ClipsLastChecked(v time.Time) predicate.Live { return predicate.Live(sql.FieldEQ(FieldClipsLastChecked, v)) } +// ClipsIgnoreLastChecked applies equality check predicate on the "clips_ignore_last_checked" field. It's identical to ClipsIgnoreLastCheckedEQ. +func ClipsIgnoreLastChecked(v bool) predicate.Live { + return predicate.Live(sql.FieldEQ(FieldClipsIgnoreLastChecked, v)) +} + // UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. func UpdatedAt(v time.Time) predicate.Live { return predicate.Live(sql.FieldEQ(FieldUpdatedAt, v)) @@ -546,6 +551,16 @@ func ClipsLastCheckedNotNil() predicate.Live { return predicate.Live(sql.FieldNotNull(FieldClipsLastChecked)) } +// ClipsIgnoreLastCheckedEQ applies the EQ predicate on the "clips_ignore_last_checked" field. +func ClipsIgnoreLastCheckedEQ(v bool) predicate.Live { + return predicate.Live(sql.FieldEQ(FieldClipsIgnoreLastChecked, v)) +} + +// ClipsIgnoreLastCheckedNEQ applies the NEQ predicate on the "clips_ignore_last_checked" field. +func ClipsIgnoreLastCheckedNEQ(v bool) predicate.Live { + return predicate.Live(sql.FieldNEQ(FieldClipsIgnoreLastChecked, v)) +} + // UpdatedAtEQ applies the EQ predicate on the "updated_at" field. func UpdatedAtEQ(v time.Time) predicate.Live { return predicate.Live(sql.FieldEQ(FieldUpdatedAt, v)) diff --git a/ent/live_create.go b/ent/live_create.go index 0c5a39a5..6689c1bb 100644 --- a/ent/live_create.go +++ b/ent/live_create.go @@ -265,6 +265,20 @@ func (lc *LiveCreate) SetNillableClipsLastChecked(t *time.Time) *LiveCreate { return lc } +// SetClipsIgnoreLastChecked sets the "clips_ignore_last_checked" field. +func (lc *LiveCreate) SetClipsIgnoreLastChecked(b bool) *LiveCreate { + lc.mutation.SetClipsIgnoreLastChecked(b) + return lc +} + +// SetNillableClipsIgnoreLastChecked sets the "clips_ignore_last_checked" field if the given value is not nil. +func (lc *LiveCreate) SetNillableClipsIgnoreLastChecked(b *bool) *LiveCreate { + if b != nil { + lc.SetClipsIgnoreLastChecked(*b) + } + return lc +} + // SetUpdatedAt sets the "updated_at" field. func (lc *LiveCreate) SetUpdatedAt(t time.Time) *LiveCreate { lc.mutation.SetUpdatedAt(t) @@ -447,6 +461,10 @@ func (lc *LiveCreate) defaults() { v := live.DefaultClipsIntervalDays lc.mutation.SetClipsIntervalDays(v) } + if _, ok := lc.mutation.ClipsIgnoreLastChecked(); !ok { + v := live.DefaultClipsIgnoreLastChecked + lc.mutation.SetClipsIgnoreLastChecked(v) + } if _, ok := lc.mutation.UpdatedAt(); !ok { v := live.DefaultUpdatedAt() lc.mutation.SetUpdatedAt(v) @@ -508,13 +526,16 @@ func (lc *LiveCreate) check() error { if _, ok := lc.mutation.ClipsIntervalDays(); !ok { return &ValidationError{Name: "clips_interval_days", err: errors.New(`ent: missing required field "Live.clips_interval_days"`)} } + if _, ok := lc.mutation.ClipsIgnoreLastChecked(); !ok { + return &ValidationError{Name: "clips_ignore_last_checked", err: errors.New(`ent: missing required field "Live.clips_ignore_last_checked"`)} + } if _, ok := lc.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Live.updated_at"`)} } if _, ok := lc.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Live.created_at"`)} } - if _, ok := lc.mutation.ChannelID(); !ok { + if len(lc.mutation.ChannelIDs()) == 0 { return &ValidationError{Name: "channel", err: errors.New(`ent: missing required edge "Live.channel"`)} } return nil @@ -621,6 +642,10 @@ func (lc *LiveCreate) createSpec() (*Live, *sqlgraph.CreateSpec) { _spec.SetField(live.FieldClipsLastChecked, field.TypeTime, value) _node.ClipsLastChecked = value } + if value, ok := lc.mutation.ClipsIgnoreLastChecked(); ok { + _spec.SetField(live.FieldClipsIgnoreLastChecked, field.TypeBool, value) + _node.ClipsIgnoreLastChecked = value + } if value, ok := lc.mutation.UpdatedAt(); ok { _spec.SetField(live.FieldUpdatedAt, field.TypeTime, value) _node.UpdatedAt = value @@ -964,6 +989,18 @@ func (u *LiveUpsert) ClearClipsLastChecked() *LiveUpsert { return u } +// SetClipsIgnoreLastChecked sets the "clips_ignore_last_checked" field. +func (u *LiveUpsert) SetClipsIgnoreLastChecked(v bool) *LiveUpsert { + u.Set(live.FieldClipsIgnoreLastChecked, v) + return u +} + +// UpdateClipsIgnoreLastChecked sets the "clips_ignore_last_checked" field to the value that was provided on create. +func (u *LiveUpsert) UpdateClipsIgnoreLastChecked() *LiveUpsert { + u.SetExcluded(live.FieldClipsIgnoreLastChecked) + return u +} + // SetUpdatedAt sets the "updated_at" field. func (u *LiveUpsert) SetUpdatedAt(v time.Time) *LiveUpsert { u.Set(live.FieldUpdatedAt, v) @@ -1300,6 +1337,20 @@ func (u *LiveUpsertOne) ClearClipsLastChecked() *LiveUpsertOne { }) } +// SetClipsIgnoreLastChecked sets the "clips_ignore_last_checked" field. +func (u *LiveUpsertOne) SetClipsIgnoreLastChecked(v bool) *LiveUpsertOne { + return u.Update(func(s *LiveUpsert) { + s.SetClipsIgnoreLastChecked(v) + }) +} + +// UpdateClipsIgnoreLastChecked sets the "clips_ignore_last_checked" field to the value that was provided on create. +func (u *LiveUpsertOne) UpdateClipsIgnoreLastChecked() *LiveUpsertOne { + return u.Update(func(s *LiveUpsert) { + s.UpdateClipsIgnoreLastChecked() + }) +} + // SetUpdatedAt sets the "updated_at" field. func (u *LiveUpsertOne) SetUpdatedAt(v time.Time) *LiveUpsertOne { return u.Update(func(s *LiveUpsert) { @@ -1805,6 +1856,20 @@ func (u *LiveUpsertBulk) ClearClipsLastChecked() *LiveUpsertBulk { }) } +// SetClipsIgnoreLastChecked sets the "clips_ignore_last_checked" field. +func (u *LiveUpsertBulk) SetClipsIgnoreLastChecked(v bool) *LiveUpsertBulk { + return u.Update(func(s *LiveUpsert) { + s.SetClipsIgnoreLastChecked(v) + }) +} + +// UpdateClipsIgnoreLastChecked sets the "clips_ignore_last_checked" field to the value that was provided on create. +func (u *LiveUpsertBulk) UpdateClipsIgnoreLastChecked() *LiveUpsertBulk { + return u.Update(func(s *LiveUpsert) { + s.UpdateClipsIgnoreLastChecked() + }) +} + // SetUpdatedAt sets the "updated_at" field. func (u *LiveUpsertBulk) SetUpdatedAt(v time.Time) *LiveUpsertBulk { return u.Update(func(s *LiveUpsert) { diff --git a/ent/live_query.go b/ent/live_query.go index 8173651c..6499446f 100644 --- a/ent/live_query.go +++ b/ent/live_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -135,7 +136,7 @@ func (lq *LiveQuery) QueryTitleRegex() *LiveTitleRegexQuery { // First returns the first Live entity from the query. // Returns a *NotFoundError when no Live was found. func (lq *LiveQuery) First(ctx context.Context) (*Live, error) { - nodes, err := lq.Limit(1).All(setContextOp(ctx, lq.ctx, "First")) + nodes, err := lq.Limit(1).All(setContextOp(ctx, lq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -158,7 +159,7 @@ func (lq *LiveQuery) FirstX(ctx context.Context) *Live { // Returns a *NotFoundError when no Live ID was found. func (lq *LiveQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = lq.Limit(1).IDs(setContextOp(ctx, lq.ctx, "FirstID")); err != nil { + if ids, err = lq.Limit(1).IDs(setContextOp(ctx, lq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -181,7 +182,7 @@ func (lq *LiveQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one Live entity is found. // Returns a *NotFoundError when no Live entities are found. func (lq *LiveQuery) Only(ctx context.Context) (*Live, error) { - nodes, err := lq.Limit(2).All(setContextOp(ctx, lq.ctx, "Only")) + nodes, err := lq.Limit(2).All(setContextOp(ctx, lq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -209,7 +210,7 @@ func (lq *LiveQuery) OnlyX(ctx context.Context) *Live { // Returns a *NotFoundError when no entities are found. func (lq *LiveQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = lq.Limit(2).IDs(setContextOp(ctx, lq.ctx, "OnlyID")); err != nil { + if ids, err = lq.Limit(2).IDs(setContextOp(ctx, lq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -234,7 +235,7 @@ func (lq *LiveQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Lives. func (lq *LiveQuery) All(ctx context.Context) ([]*Live, error) { - ctx = setContextOp(ctx, lq.ctx, "All") + ctx = setContextOp(ctx, lq.ctx, ent.OpQueryAll) if err := lq.prepareQuery(ctx); err != nil { return nil, err } @@ -256,7 +257,7 @@ func (lq *LiveQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if lq.ctx.Unique == nil && lq.path != nil { lq.Unique(true) } - ctx = setContextOp(ctx, lq.ctx, "IDs") + ctx = setContextOp(ctx, lq.ctx, ent.OpQueryIDs) if err = lq.Select(live.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -274,7 +275,7 @@ func (lq *LiveQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (lq *LiveQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, lq.ctx, "Count") + ctx = setContextOp(ctx, lq.ctx, ent.OpQueryCount) if err := lq.prepareQuery(ctx); err != nil { return 0, err } @@ -292,7 +293,7 @@ func (lq *LiveQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (lq *LiveQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, lq.ctx, "Exist") + ctx = setContextOp(ctx, lq.ctx, ent.OpQueryExist) switch _, err := lq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -688,7 +689,7 @@ func (lgb *LiveGroupBy) Aggregate(fns ...AggregateFunc) *LiveGroupBy { // Scan applies the selector query and scans the result into the given value. func (lgb *LiveGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, lgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, lgb.build.ctx, ent.OpQueryGroupBy) if err := lgb.build.prepareQuery(ctx); err != nil { return err } @@ -736,7 +737,7 @@ func (ls *LiveSelect) Aggregate(fns ...AggregateFunc) *LiveSelect { // Scan applies the selector query and scans the result into the given value. func (ls *LiveSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ls.ctx, "Select") + ctx = setContextOp(ctx, ls.ctx, ent.OpQuerySelect) if err := ls.prepareQuery(ctx); err != nil { return err } diff --git a/ent/live_update.go b/ent/live_update.go index 7caf38fe..453af199 100644 --- a/ent/live_update.go +++ b/ent/live_update.go @@ -303,6 +303,20 @@ func (lu *LiveUpdate) ClearClipsLastChecked() *LiveUpdate { return lu } +// SetClipsIgnoreLastChecked sets the "clips_ignore_last_checked" field. +func (lu *LiveUpdate) SetClipsIgnoreLastChecked(b bool) *LiveUpdate { + lu.mutation.SetClipsIgnoreLastChecked(b) + return lu +} + +// SetNillableClipsIgnoreLastChecked sets the "clips_ignore_last_checked" field if the given value is not nil. +func (lu *LiveUpdate) SetNillableClipsIgnoreLastChecked(b *bool) *LiveUpdate { + if b != nil { + lu.SetClipsIgnoreLastChecked(*b) + } + return lu +} + // SetUpdatedAt sets the "updated_at" field. func (lu *LiveUpdate) SetUpdatedAt(t time.Time) *LiveUpdate { lu.mutation.SetUpdatedAt(t) @@ -441,7 +455,7 @@ func (lu *LiveUpdate) defaults() { // check runs all checks and user-defined validators on the builder. func (lu *LiveUpdate) check() error { - if _, ok := lu.mutation.ChannelID(); lu.mutation.ChannelCleared() && !ok { + if lu.mutation.ChannelCleared() && len(lu.mutation.ChannelIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Live.channel"`) } return nil @@ -525,6 +539,9 @@ func (lu *LiveUpdate) sqlSave(ctx context.Context) (n int, err error) { if lu.mutation.ClipsLastCheckedCleared() { _spec.ClearField(live.FieldClipsLastChecked, field.TypeTime) } + if value, ok := lu.mutation.ClipsIgnoreLastChecked(); ok { + _spec.SetField(live.FieldClipsIgnoreLastChecked, field.TypeBool, value) + } if value, ok := lu.mutation.UpdatedAt(); ok { _spec.SetField(live.FieldUpdatedAt, field.TypeTime, value) } @@ -938,6 +955,20 @@ func (luo *LiveUpdateOne) ClearClipsLastChecked() *LiveUpdateOne { return luo } +// SetClipsIgnoreLastChecked sets the "clips_ignore_last_checked" field. +func (luo *LiveUpdateOne) SetClipsIgnoreLastChecked(b bool) *LiveUpdateOne { + luo.mutation.SetClipsIgnoreLastChecked(b) + return luo +} + +// SetNillableClipsIgnoreLastChecked sets the "clips_ignore_last_checked" field if the given value is not nil. +func (luo *LiveUpdateOne) SetNillableClipsIgnoreLastChecked(b *bool) *LiveUpdateOne { + if b != nil { + luo.SetClipsIgnoreLastChecked(*b) + } + return luo +} + // SetUpdatedAt sets the "updated_at" field. func (luo *LiveUpdateOne) SetUpdatedAt(t time.Time) *LiveUpdateOne { luo.mutation.SetUpdatedAt(t) @@ -1089,7 +1120,7 @@ func (luo *LiveUpdateOne) defaults() { // check runs all checks and user-defined validators on the builder. func (luo *LiveUpdateOne) check() error { - if _, ok := luo.mutation.ChannelID(); luo.mutation.ChannelCleared() && !ok { + if luo.mutation.ChannelCleared() && len(luo.mutation.ChannelIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Live.channel"`) } return nil @@ -1190,6 +1221,9 @@ func (luo *LiveUpdateOne) sqlSave(ctx context.Context) (_node *Live, err error) if luo.mutation.ClipsLastCheckedCleared() { _spec.ClearField(live.FieldClipsLastChecked, field.TypeTime) } + if value, ok := luo.mutation.ClipsIgnoreLastChecked(); ok { + _spec.SetField(live.FieldClipsIgnoreLastChecked, field.TypeBool, value) + } if value, ok := luo.mutation.UpdatedAt(); ok { _spec.SetField(live.FieldUpdatedAt, field.TypeTime, value) } diff --git a/ent/livecategory_create.go b/ent/livecategory_create.go index 06da505d..1d13e30c 100644 --- a/ent/livecategory_create.go +++ b/ent/livecategory_create.go @@ -101,7 +101,7 @@ func (lcc *LiveCategoryCreate) check() error { if _, ok := lcc.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "LiveCategory.name"`)} } - if _, ok := lcc.mutation.LiveID(); !ok { + if len(lcc.mutation.LiveIDs()) == 0 { return &ValidationError{Name: "live", err: errors.New(`ent: missing required edge "LiveCategory.live"`)} } return nil diff --git a/ent/livecategory_query.go b/ent/livecategory_query.go index a079c31c..76ddcae5 100644 --- a/ent/livecategory_query.go +++ b/ent/livecategory_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -86,7 +87,7 @@ func (lcq *LiveCategoryQuery) QueryLive() *LiveQuery { // First returns the first LiveCategory entity from the query. // Returns a *NotFoundError when no LiveCategory was found. func (lcq *LiveCategoryQuery) First(ctx context.Context) (*LiveCategory, error) { - nodes, err := lcq.Limit(1).All(setContextOp(ctx, lcq.ctx, "First")) + nodes, err := lcq.Limit(1).All(setContextOp(ctx, lcq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -109,7 +110,7 @@ func (lcq *LiveCategoryQuery) FirstX(ctx context.Context) *LiveCategory { // Returns a *NotFoundError when no LiveCategory ID was found. func (lcq *LiveCategoryQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = lcq.Limit(1).IDs(setContextOp(ctx, lcq.ctx, "FirstID")); err != nil { + if ids, err = lcq.Limit(1).IDs(setContextOp(ctx, lcq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -132,7 +133,7 @@ func (lcq *LiveCategoryQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one LiveCategory entity is found. // Returns a *NotFoundError when no LiveCategory entities are found. func (lcq *LiveCategoryQuery) Only(ctx context.Context) (*LiveCategory, error) { - nodes, err := lcq.Limit(2).All(setContextOp(ctx, lcq.ctx, "Only")) + nodes, err := lcq.Limit(2).All(setContextOp(ctx, lcq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -160,7 +161,7 @@ func (lcq *LiveCategoryQuery) OnlyX(ctx context.Context) *LiveCategory { // Returns a *NotFoundError when no entities are found. func (lcq *LiveCategoryQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = lcq.Limit(2).IDs(setContextOp(ctx, lcq.ctx, "OnlyID")); err != nil { + if ids, err = lcq.Limit(2).IDs(setContextOp(ctx, lcq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -185,7 +186,7 @@ func (lcq *LiveCategoryQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of LiveCategories. func (lcq *LiveCategoryQuery) All(ctx context.Context) ([]*LiveCategory, error) { - ctx = setContextOp(ctx, lcq.ctx, "All") + ctx = setContextOp(ctx, lcq.ctx, ent.OpQueryAll) if err := lcq.prepareQuery(ctx); err != nil { return nil, err } @@ -207,7 +208,7 @@ func (lcq *LiveCategoryQuery) IDs(ctx context.Context) (ids []uuid.UUID, err err if lcq.ctx.Unique == nil && lcq.path != nil { lcq.Unique(true) } - ctx = setContextOp(ctx, lcq.ctx, "IDs") + ctx = setContextOp(ctx, lcq.ctx, ent.OpQueryIDs) if err = lcq.Select(livecategory.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -225,7 +226,7 @@ func (lcq *LiveCategoryQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (lcq *LiveCategoryQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, lcq.ctx, "Count") + ctx = setContextOp(ctx, lcq.ctx, ent.OpQueryCount) if err := lcq.prepareQuery(ctx); err != nil { return 0, err } @@ -243,7 +244,7 @@ func (lcq *LiveCategoryQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (lcq *LiveCategoryQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, lcq.ctx, "Exist") + ctx = setContextOp(ctx, lcq.ctx, ent.OpQueryExist) switch _, err := lcq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -537,7 +538,7 @@ func (lcgb *LiveCategoryGroupBy) Aggregate(fns ...AggregateFunc) *LiveCategoryGr // Scan applies the selector query and scans the result into the given value. func (lcgb *LiveCategoryGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, lcgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, lcgb.build.ctx, ent.OpQueryGroupBy) if err := lcgb.build.prepareQuery(ctx); err != nil { return err } @@ -585,7 +586,7 @@ func (lcs *LiveCategorySelect) Aggregate(fns ...AggregateFunc) *LiveCategorySele // Scan applies the selector query and scans the result into the given value. func (lcs *LiveCategorySelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, lcs.ctx, "Select") + ctx = setContextOp(ctx, lcs.ctx, ent.OpQuerySelect) if err := lcs.prepareQuery(ctx); err != nil { return err } diff --git a/ent/livecategory_update.go b/ent/livecategory_update.go index 2ecc4eda..619d9473 100644 --- a/ent/livecategory_update.go +++ b/ent/livecategory_update.go @@ -94,7 +94,7 @@ func (lcu *LiveCategoryUpdate) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (lcu *LiveCategoryUpdate) check() error { - if _, ok := lcu.mutation.LiveID(); lcu.mutation.LiveCleared() && !ok { + if lcu.mutation.LiveCleared() && len(lcu.mutation.LiveIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "LiveCategory.live"`) } return nil @@ -242,7 +242,7 @@ func (lcuo *LiveCategoryUpdateOne) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (lcuo *LiveCategoryUpdateOne) check() error { - if _, ok := lcuo.mutation.LiveID(); lcuo.mutation.LiveCleared() && !ok { + if lcuo.mutation.LiveCleared() && len(lcuo.mutation.LiveIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "LiveCategory.live"`) } return nil diff --git a/ent/livetitleregex_create.go b/ent/livetitleregex_create.go index c691e39f..f3e7ef17 100644 --- a/ent/livetitleregex_create.go +++ b/ent/livetitleregex_create.go @@ -143,7 +143,7 @@ func (ltrc *LiveTitleRegexCreate) check() error { if _, ok := ltrc.mutation.ApplyToVideos(); !ok { return &ValidationError{Name: "apply_to_videos", err: errors.New(`ent: missing required field "LiveTitleRegex.apply_to_videos"`)} } - if _, ok := ltrc.mutation.LiveID(); !ok { + if len(ltrc.mutation.LiveIDs()) == 0 { return &ValidationError{Name: "live", err: errors.New(`ent: missing required edge "LiveTitleRegex.live"`)} } return nil diff --git a/ent/livetitleregex_query.go b/ent/livetitleregex_query.go index a313dae6..e852f46d 100644 --- a/ent/livetitleregex_query.go +++ b/ent/livetitleregex_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -86,7 +87,7 @@ func (ltrq *LiveTitleRegexQuery) QueryLive() *LiveQuery { // First returns the first LiveTitleRegex entity from the query. // Returns a *NotFoundError when no LiveTitleRegex was found. func (ltrq *LiveTitleRegexQuery) First(ctx context.Context) (*LiveTitleRegex, error) { - nodes, err := ltrq.Limit(1).All(setContextOp(ctx, ltrq.ctx, "First")) + nodes, err := ltrq.Limit(1).All(setContextOp(ctx, ltrq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -109,7 +110,7 @@ func (ltrq *LiveTitleRegexQuery) FirstX(ctx context.Context) *LiveTitleRegex { // Returns a *NotFoundError when no LiveTitleRegex ID was found. func (ltrq *LiveTitleRegexQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = ltrq.Limit(1).IDs(setContextOp(ctx, ltrq.ctx, "FirstID")); err != nil { + if ids, err = ltrq.Limit(1).IDs(setContextOp(ctx, ltrq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -132,7 +133,7 @@ func (ltrq *LiveTitleRegexQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one LiveTitleRegex entity is found. // Returns a *NotFoundError when no LiveTitleRegex entities are found. func (ltrq *LiveTitleRegexQuery) Only(ctx context.Context) (*LiveTitleRegex, error) { - nodes, err := ltrq.Limit(2).All(setContextOp(ctx, ltrq.ctx, "Only")) + nodes, err := ltrq.Limit(2).All(setContextOp(ctx, ltrq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -160,7 +161,7 @@ func (ltrq *LiveTitleRegexQuery) OnlyX(ctx context.Context) *LiveTitleRegex { // Returns a *NotFoundError when no entities are found. func (ltrq *LiveTitleRegexQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = ltrq.Limit(2).IDs(setContextOp(ctx, ltrq.ctx, "OnlyID")); err != nil { + if ids, err = ltrq.Limit(2).IDs(setContextOp(ctx, ltrq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -185,7 +186,7 @@ func (ltrq *LiveTitleRegexQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of LiveTitleRegexes. func (ltrq *LiveTitleRegexQuery) All(ctx context.Context) ([]*LiveTitleRegex, error) { - ctx = setContextOp(ctx, ltrq.ctx, "All") + ctx = setContextOp(ctx, ltrq.ctx, ent.OpQueryAll) if err := ltrq.prepareQuery(ctx); err != nil { return nil, err } @@ -207,7 +208,7 @@ func (ltrq *LiveTitleRegexQuery) IDs(ctx context.Context) (ids []uuid.UUID, err if ltrq.ctx.Unique == nil && ltrq.path != nil { ltrq.Unique(true) } - ctx = setContextOp(ctx, ltrq.ctx, "IDs") + ctx = setContextOp(ctx, ltrq.ctx, ent.OpQueryIDs) if err = ltrq.Select(livetitleregex.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -225,7 +226,7 @@ func (ltrq *LiveTitleRegexQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (ltrq *LiveTitleRegexQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, ltrq.ctx, "Count") + ctx = setContextOp(ctx, ltrq.ctx, ent.OpQueryCount) if err := ltrq.prepareQuery(ctx); err != nil { return 0, err } @@ -243,7 +244,7 @@ func (ltrq *LiveTitleRegexQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (ltrq *LiveTitleRegexQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, ltrq.ctx, "Exist") + ctx = setContextOp(ctx, ltrq.ctx, ent.OpQueryExist) switch _, err := ltrq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -537,7 +538,7 @@ func (ltrgb *LiveTitleRegexGroupBy) Aggregate(fns ...AggregateFunc) *LiveTitleRe // Scan applies the selector query and scans the result into the given value. func (ltrgb *LiveTitleRegexGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ltrgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, ltrgb.build.ctx, ent.OpQueryGroupBy) if err := ltrgb.build.prepareQuery(ctx); err != nil { return err } @@ -585,7 +586,7 @@ func (ltrs *LiveTitleRegexSelect) Aggregate(fns ...AggregateFunc) *LiveTitleRege // Scan applies the selector query and scans the result into the given value. func (ltrs *LiveTitleRegexSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ltrs.ctx, "Select") + ctx = setContextOp(ctx, ltrs.ctx, ent.OpQuerySelect) if err := ltrs.prepareQuery(ctx); err != nil { return err } diff --git a/ent/livetitleregex_update.go b/ent/livetitleregex_update.go index a0c87331..1ae91feb 100644 --- a/ent/livetitleregex_update.go +++ b/ent/livetitleregex_update.go @@ -122,7 +122,7 @@ func (ltru *LiveTitleRegexUpdate) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (ltru *LiveTitleRegexUpdate) check() error { - if _, ok := ltru.mutation.LiveID(); ltru.mutation.LiveCleared() && !ok { + if ltru.mutation.LiveCleared() && len(ltru.mutation.LiveIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "LiveTitleRegex.live"`) } return nil @@ -304,7 +304,7 @@ func (ltruo *LiveTitleRegexUpdateOne) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (ltruo *LiveTitleRegexUpdateOne) check() error { - if _, ok := ltruo.mutation.LiveID(); ltruo.mutation.LiveCleared() && !ok { + if ltruo.mutation.LiveCleared() && len(ltruo.mutation.LiveIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "LiveTitleRegex.live"`) } return nil diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index 0fc70aa5..9cabd0c9 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -80,6 +80,7 @@ var ( {Name: "clips_limit", Type: field.TypeInt, Default: 0}, {Name: "clips_interval_days", Type: field.TypeInt, Default: 0}, {Name: "clips_last_checked", Type: field.TypeTime, Nullable: true}, + {Name: "clips_ignore_last_checked", Type: field.TypeBool, Default: false}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_at", Type: field.TypeTime}, {Name: "channel_live", Type: field.TypeUUID}, @@ -92,7 +93,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "lives_channels_live", - Columns: []*schema.Column{LivesColumns[20]}, + Columns: []*schema.Column{LivesColumns[21]}, RefColumns: []*schema.Column{ChannelsColumns[0]}, OnDelete: schema.NoAction, }, diff --git a/ent/multistreaminfo_create.go b/ent/multistreaminfo_create.go index fadca1d2..a5378158 100644 --- a/ent/multistreaminfo_create.go +++ b/ent/multistreaminfo_create.go @@ -94,10 +94,10 @@ func (mic *MultistreamInfoCreate) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (mic *MultistreamInfoCreate) check() error { - if _, ok := mic.mutation.VodID(); !ok { + if len(mic.mutation.VodIDs()) == 0 { return &ValidationError{Name: "vod", err: errors.New(`ent: missing required edge "MultistreamInfo.vod"`)} } - if _, ok := mic.mutation.PlaylistID(); !ok { + if len(mic.mutation.PlaylistIDs()) == 0 { return &ValidationError{Name: "playlist", err: errors.New(`ent: missing required edge "MultistreamInfo.playlist"`)} } return nil diff --git a/ent/multistreaminfo_query.go b/ent/multistreaminfo_query.go index 4b73a26c..84e8ac9d 100644 --- a/ent/multistreaminfo_query.go +++ b/ent/multistreaminfo_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -110,7 +111,7 @@ func (miq *MultistreamInfoQuery) QueryPlaylist() *PlaylistQuery { // First returns the first MultistreamInfo entity from the query. // Returns a *NotFoundError when no MultistreamInfo was found. func (miq *MultistreamInfoQuery) First(ctx context.Context) (*MultistreamInfo, error) { - nodes, err := miq.Limit(1).All(setContextOp(ctx, miq.ctx, "First")) + nodes, err := miq.Limit(1).All(setContextOp(ctx, miq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -133,7 +134,7 @@ func (miq *MultistreamInfoQuery) FirstX(ctx context.Context) *MultistreamInfo { // Returns a *NotFoundError when no MultistreamInfo ID was found. func (miq *MultistreamInfoQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = miq.Limit(1).IDs(setContextOp(ctx, miq.ctx, "FirstID")); err != nil { + if ids, err = miq.Limit(1).IDs(setContextOp(ctx, miq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -156,7 +157,7 @@ func (miq *MultistreamInfoQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one MultistreamInfo entity is found. // Returns a *NotFoundError when no MultistreamInfo entities are found. func (miq *MultistreamInfoQuery) Only(ctx context.Context) (*MultistreamInfo, error) { - nodes, err := miq.Limit(2).All(setContextOp(ctx, miq.ctx, "Only")) + nodes, err := miq.Limit(2).All(setContextOp(ctx, miq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -184,7 +185,7 @@ func (miq *MultistreamInfoQuery) OnlyX(ctx context.Context) *MultistreamInfo { // Returns a *NotFoundError when no entities are found. func (miq *MultistreamInfoQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = miq.Limit(2).IDs(setContextOp(ctx, miq.ctx, "OnlyID")); err != nil { + if ids, err = miq.Limit(2).IDs(setContextOp(ctx, miq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -209,7 +210,7 @@ func (miq *MultistreamInfoQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of MultistreamInfos. func (miq *MultistreamInfoQuery) All(ctx context.Context) ([]*MultistreamInfo, error) { - ctx = setContextOp(ctx, miq.ctx, "All") + ctx = setContextOp(ctx, miq.ctx, ent.OpQueryAll) if err := miq.prepareQuery(ctx); err != nil { return nil, err } @@ -231,7 +232,7 @@ func (miq *MultistreamInfoQuery) IDs(ctx context.Context) (ids []int, err error) if miq.ctx.Unique == nil && miq.path != nil { miq.Unique(true) } - ctx = setContextOp(ctx, miq.ctx, "IDs") + ctx = setContextOp(ctx, miq.ctx, ent.OpQueryIDs) if err = miq.Select(multistreaminfo.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -249,7 +250,7 @@ func (miq *MultistreamInfoQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (miq *MultistreamInfoQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, miq.ctx, "Count") + ctx = setContextOp(ctx, miq.ctx, ent.OpQueryCount) if err := miq.prepareQuery(ctx); err != nil { return 0, err } @@ -267,7 +268,7 @@ func (miq *MultistreamInfoQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (miq *MultistreamInfoQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, miq.ctx, "Exist") + ctx = setContextOp(ctx, miq.ctx, ent.OpQueryExist) switch _, err := miq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -612,7 +613,7 @@ func (migb *MultistreamInfoGroupBy) Aggregate(fns ...AggregateFunc) *Multistream // Scan applies the selector query and scans the result into the given value. func (migb *MultistreamInfoGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, migb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, migb.build.ctx, ent.OpQueryGroupBy) if err := migb.build.prepareQuery(ctx); err != nil { return err } @@ -660,7 +661,7 @@ func (mis *MultistreamInfoSelect) Aggregate(fns ...AggregateFunc) *MultistreamIn // Scan applies the selector query and scans the result into the given value. func (mis *MultistreamInfoSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, mis.ctx, "Select") + ctx = setContextOp(ctx, mis.ctx, ent.OpQuerySelect) if err := mis.prepareQuery(ctx); err != nil { return err } diff --git a/ent/multistreaminfo_update.go b/ent/multistreaminfo_update.go index 1ad1555c..bb362799 100644 --- a/ent/multistreaminfo_update.go +++ b/ent/multistreaminfo_update.go @@ -107,10 +107,10 @@ func (miu *MultistreamInfoUpdate) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (miu *MultistreamInfoUpdate) check() error { - if _, ok := miu.mutation.VodID(); miu.mutation.VodCleared() && !ok { + if miu.mutation.VodCleared() && len(miu.mutation.VodIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "MultistreamInfo.vod"`) } - if _, ok := miu.mutation.PlaylistID(); miu.mutation.PlaylistCleared() && !ok { + if miu.mutation.PlaylistCleared() && len(miu.mutation.PlaylistIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "MultistreamInfo.playlist"`) } return nil @@ -277,10 +277,10 @@ func (miuo *MultistreamInfoUpdateOne) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (miuo *MultistreamInfoUpdateOne) check() error { - if _, ok := miuo.mutation.VodID(); miuo.mutation.VodCleared() && !ok { + if miuo.mutation.VodCleared() && len(miuo.mutation.VodIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "MultistreamInfo.vod"`) } - if _, ok := miuo.mutation.PlaylistID(); miuo.mutation.PlaylistCleared() && !ok { + if miuo.mutation.PlaylistCleared() && len(miuo.mutation.PlaylistIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "MultistreamInfo.playlist"`) } return nil diff --git a/ent/mutation.go b/ent/mutation.go index d478c747..485b323d 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -2067,43 +2067,44 @@ func (m *ChapterMutation) ResetEdge(name string) error { // LiveMutation represents an operation that mutates the Live nodes in the graph. type LiveMutation struct { config - op Op - typ string - id *uuid.UUID - watch_live *bool - watch_vod *bool - download_archives *bool - download_highlights *bool - download_uploads *bool - download_sub_only *bool - is_live *bool - archive_chat *bool - resolution *string - last_live *time.Time - render_chat *bool - video_age *int64 - addvideo_age *int64 - apply_categories_to_live *bool - watch_clips *bool - clips_limit *int - addclips_limit *int - clips_interval_days *int - addclips_interval_days *int - clips_last_checked *time.Time - updated_at *time.Time - created_at *time.Time - clearedFields map[string]struct{} - channel *uuid.UUID - clearedchannel bool - categories map[uuid.UUID]struct{} - removedcategories map[uuid.UUID]struct{} - clearedcategories bool - title_regex map[uuid.UUID]struct{} - removedtitle_regex map[uuid.UUID]struct{} - clearedtitle_regex bool - done bool - oldValue func(context.Context) (*Live, error) - predicates []predicate.Live + op Op + typ string + id *uuid.UUID + watch_live *bool + watch_vod *bool + download_archives *bool + download_highlights *bool + download_uploads *bool + download_sub_only *bool + is_live *bool + archive_chat *bool + resolution *string + last_live *time.Time + render_chat *bool + video_age *int64 + addvideo_age *int64 + apply_categories_to_live *bool + watch_clips *bool + clips_limit *int + addclips_limit *int + clips_interval_days *int + addclips_interval_days *int + clips_last_checked *time.Time + clips_ignore_last_checked *bool + updated_at *time.Time + created_at *time.Time + clearedFields map[string]struct{} + channel *uuid.UUID + clearedchannel bool + categories map[uuid.UUID]struct{} + removedcategories map[uuid.UUID]struct{} + clearedcategories bool + title_regex map[uuid.UUID]struct{} + removedtitle_regex map[uuid.UUID]struct{} + clearedtitle_regex bool + done bool + oldValue func(context.Context) (*Live, error) + predicates []predicate.Live } var _ ent.Mutation = (*LiveMutation)(nil) @@ -2908,6 +2909,42 @@ func (m *LiveMutation) ResetClipsLastChecked() { delete(m.clearedFields, live.FieldClipsLastChecked) } +// SetClipsIgnoreLastChecked sets the "clips_ignore_last_checked" field. +func (m *LiveMutation) SetClipsIgnoreLastChecked(b bool) { + m.clips_ignore_last_checked = &b +} + +// ClipsIgnoreLastChecked returns the value of the "clips_ignore_last_checked" field in the mutation. +func (m *LiveMutation) ClipsIgnoreLastChecked() (r bool, exists bool) { + v := m.clips_ignore_last_checked + if v == nil { + return + } + return *v, true +} + +// OldClipsIgnoreLastChecked returns the old "clips_ignore_last_checked" field's value of the Live entity. +// If the Live 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 *LiveMutation) OldClipsIgnoreLastChecked(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldClipsIgnoreLastChecked is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldClipsIgnoreLastChecked requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldClipsIgnoreLastChecked: %w", err) + } + return oldValue.ClipsIgnoreLastChecked, nil +} + +// ResetClipsIgnoreLastChecked resets all changes to the "clips_ignore_last_checked" field. +func (m *LiveMutation) ResetClipsIgnoreLastChecked() { + m.clips_ignore_last_checked = nil +} + // SetUpdatedAt sets the "updated_at" field. func (m *LiveMutation) SetUpdatedAt(t time.Time) { m.updated_at = &t @@ -3161,7 +3198,7 @@ func (m *LiveMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *LiveMutation) Fields() []string { - fields := make([]string, 0, 19) + fields := make([]string, 0, 20) if m.watch_live != nil { fields = append(fields, live.FieldWatchLive) } @@ -3213,6 +3250,9 @@ func (m *LiveMutation) Fields() []string { if m.clips_last_checked != nil { fields = append(fields, live.FieldClipsLastChecked) } + if m.clips_ignore_last_checked != nil { + fields = append(fields, live.FieldClipsIgnoreLastChecked) + } if m.updated_at != nil { fields = append(fields, live.FieldUpdatedAt) } @@ -3261,6 +3301,8 @@ func (m *LiveMutation) Field(name string) (ent.Value, bool) { return m.ClipsIntervalDays() case live.FieldClipsLastChecked: return m.ClipsLastChecked() + case live.FieldClipsIgnoreLastChecked: + return m.ClipsIgnoreLastChecked() case live.FieldUpdatedAt: return m.UpdatedAt() case live.FieldCreatedAt: @@ -3308,6 +3350,8 @@ func (m *LiveMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldClipsIntervalDays(ctx) case live.FieldClipsLastChecked: return m.OldClipsLastChecked(ctx) + case live.FieldClipsIgnoreLastChecked: + return m.OldClipsIgnoreLastChecked(ctx) case live.FieldUpdatedAt: return m.OldUpdatedAt(ctx) case live.FieldCreatedAt: @@ -3440,6 +3484,13 @@ func (m *LiveMutation) SetField(name string, value ent.Value) error { } m.SetClipsLastChecked(v) return nil + case live.FieldClipsIgnoreLastChecked: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetClipsIgnoreLastChecked(v) + return nil case live.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { @@ -3608,6 +3659,9 @@ func (m *LiveMutation) ResetField(name string) error { case live.FieldClipsLastChecked: m.ResetClipsLastChecked() return nil + case live.FieldClipsIgnoreLastChecked: + m.ResetClipsIgnoreLastChecked() + return nil case live.FieldUpdatedAt: m.ResetUpdatedAt() return nil diff --git a/ent/mutedsegment_create.go b/ent/mutedsegment_create.go index e69d9aa0..4f369546 100644 --- a/ent/mutedsegment_create.go +++ b/ent/mutedsegment_create.go @@ -110,7 +110,7 @@ func (msc *MutedSegmentCreate) check() error { if _, ok := msc.mutation.End(); !ok { return &ValidationError{Name: "end", err: errors.New(`ent: missing required field "MutedSegment.end"`)} } - if _, ok := msc.mutation.VodID(); !ok { + if len(msc.mutation.VodIDs()) == 0 { return &ValidationError{Name: "vod", err: errors.New(`ent: missing required edge "MutedSegment.vod"`)} } return nil diff --git a/ent/mutedsegment_query.go b/ent/mutedsegment_query.go index e86f573f..efadab07 100644 --- a/ent/mutedsegment_query.go +++ b/ent/mutedsegment_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -86,7 +87,7 @@ func (msq *MutedSegmentQuery) QueryVod() *VodQuery { // First returns the first MutedSegment entity from the query. // Returns a *NotFoundError when no MutedSegment was found. func (msq *MutedSegmentQuery) First(ctx context.Context) (*MutedSegment, error) { - nodes, err := msq.Limit(1).All(setContextOp(ctx, msq.ctx, "First")) + nodes, err := msq.Limit(1).All(setContextOp(ctx, msq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -109,7 +110,7 @@ func (msq *MutedSegmentQuery) FirstX(ctx context.Context) *MutedSegment { // Returns a *NotFoundError when no MutedSegment ID was found. func (msq *MutedSegmentQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = msq.Limit(1).IDs(setContextOp(ctx, msq.ctx, "FirstID")); err != nil { + if ids, err = msq.Limit(1).IDs(setContextOp(ctx, msq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -132,7 +133,7 @@ func (msq *MutedSegmentQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one MutedSegment entity is found. // Returns a *NotFoundError when no MutedSegment entities are found. func (msq *MutedSegmentQuery) Only(ctx context.Context) (*MutedSegment, error) { - nodes, err := msq.Limit(2).All(setContextOp(ctx, msq.ctx, "Only")) + nodes, err := msq.Limit(2).All(setContextOp(ctx, msq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -160,7 +161,7 @@ func (msq *MutedSegmentQuery) OnlyX(ctx context.Context) *MutedSegment { // Returns a *NotFoundError when no entities are found. func (msq *MutedSegmentQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = msq.Limit(2).IDs(setContextOp(ctx, msq.ctx, "OnlyID")); err != nil { + if ids, err = msq.Limit(2).IDs(setContextOp(ctx, msq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -185,7 +186,7 @@ func (msq *MutedSegmentQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of MutedSegments. func (msq *MutedSegmentQuery) All(ctx context.Context) ([]*MutedSegment, error) { - ctx = setContextOp(ctx, msq.ctx, "All") + ctx = setContextOp(ctx, msq.ctx, ent.OpQueryAll) if err := msq.prepareQuery(ctx); err != nil { return nil, err } @@ -207,7 +208,7 @@ func (msq *MutedSegmentQuery) IDs(ctx context.Context) (ids []uuid.UUID, err err if msq.ctx.Unique == nil && msq.path != nil { msq.Unique(true) } - ctx = setContextOp(ctx, msq.ctx, "IDs") + ctx = setContextOp(ctx, msq.ctx, ent.OpQueryIDs) if err = msq.Select(mutedsegment.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -225,7 +226,7 @@ func (msq *MutedSegmentQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (msq *MutedSegmentQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, msq.ctx, "Count") + ctx = setContextOp(ctx, msq.ctx, ent.OpQueryCount) if err := msq.prepareQuery(ctx); err != nil { return 0, err } @@ -243,7 +244,7 @@ func (msq *MutedSegmentQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (msq *MutedSegmentQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, msq.ctx, "Exist") + ctx = setContextOp(ctx, msq.ctx, ent.OpQueryExist) switch _, err := msq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -537,7 +538,7 @@ func (msgb *MutedSegmentGroupBy) Aggregate(fns ...AggregateFunc) *MutedSegmentGr // Scan applies the selector query and scans the result into the given value. func (msgb *MutedSegmentGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, msgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, msgb.build.ctx, ent.OpQueryGroupBy) if err := msgb.build.prepareQuery(ctx); err != nil { return err } @@ -585,7 +586,7 @@ func (mss *MutedSegmentSelect) Aggregate(fns ...AggregateFunc) *MutedSegmentSele // Scan applies the selector query and scans the result into the given value. func (mss *MutedSegmentSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, mss.ctx, "Select") + ctx = setContextOp(ctx, mss.ctx, ent.OpQuerySelect) if err := mss.prepareQuery(ctx); err != nil { return err } diff --git a/ent/mutedsegment_update.go b/ent/mutedsegment_update.go index 706ca812..b52577fd 100644 --- a/ent/mutedsegment_update.go +++ b/ent/mutedsegment_update.go @@ -122,7 +122,7 @@ func (msu *MutedSegmentUpdate) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (msu *MutedSegmentUpdate) check() error { - if _, ok := msu.mutation.VodID(); msu.mutation.VodCleared() && !ok { + if msu.mutation.VodCleared() && len(msu.mutation.VodIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "MutedSegment.vod"`) } return nil @@ -307,7 +307,7 @@ func (msuo *MutedSegmentUpdateOne) ExecX(ctx context.Context) { // check runs all checks and user-defined validators on the builder. func (msuo *MutedSegmentUpdateOne) check() error { - if _, ok := msuo.mutation.VodID(); msuo.mutation.VodCleared() && !ok { + if msuo.mutation.VodCleared() && len(msuo.mutation.VodIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "MutedSegment.vod"`) } return nil diff --git a/ent/playback_query.go b/ent/playback_query.go index c84a9ed5..000509ad 100644 --- a/ent/playback_query.go +++ b/ent/playback_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -61,7 +62,7 @@ func (pq *PlaybackQuery) Order(o ...playback.OrderOption) *PlaybackQuery { // First returns the first Playback entity from the query. // Returns a *NotFoundError when no Playback was found. func (pq *PlaybackQuery) First(ctx context.Context) (*Playback, error) { - nodes, err := pq.Limit(1).All(setContextOp(ctx, pq.ctx, "First")) + nodes, err := pq.Limit(1).All(setContextOp(ctx, pq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -84,7 +85,7 @@ func (pq *PlaybackQuery) FirstX(ctx context.Context) *Playback { // Returns a *NotFoundError when no Playback ID was found. func (pq *PlaybackQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = pq.Limit(1).IDs(setContextOp(ctx, pq.ctx, "FirstID")); err != nil { + if ids, err = pq.Limit(1).IDs(setContextOp(ctx, pq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -107,7 +108,7 @@ func (pq *PlaybackQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one Playback entity is found. // Returns a *NotFoundError when no Playback entities are found. func (pq *PlaybackQuery) Only(ctx context.Context) (*Playback, error) { - nodes, err := pq.Limit(2).All(setContextOp(ctx, pq.ctx, "Only")) + nodes, err := pq.Limit(2).All(setContextOp(ctx, pq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -135,7 +136,7 @@ func (pq *PlaybackQuery) OnlyX(ctx context.Context) *Playback { // Returns a *NotFoundError when no entities are found. func (pq *PlaybackQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = pq.Limit(2).IDs(setContextOp(ctx, pq.ctx, "OnlyID")); err != nil { + if ids, err = pq.Limit(2).IDs(setContextOp(ctx, pq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -160,7 +161,7 @@ func (pq *PlaybackQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Playbacks. func (pq *PlaybackQuery) All(ctx context.Context) ([]*Playback, error) { - ctx = setContextOp(ctx, pq.ctx, "All") + ctx = setContextOp(ctx, pq.ctx, ent.OpQueryAll) if err := pq.prepareQuery(ctx); err != nil { return nil, err } @@ -182,7 +183,7 @@ func (pq *PlaybackQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if pq.ctx.Unique == nil && pq.path != nil { pq.Unique(true) } - ctx = setContextOp(ctx, pq.ctx, "IDs") + ctx = setContextOp(ctx, pq.ctx, ent.OpQueryIDs) if err = pq.Select(playback.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -200,7 +201,7 @@ func (pq *PlaybackQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (pq *PlaybackQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, pq.ctx, "Count") + ctx = setContextOp(ctx, pq.ctx, ent.OpQueryCount) if err := pq.prepareQuery(ctx); err != nil { return 0, err } @@ -218,7 +219,7 @@ func (pq *PlaybackQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (pq *PlaybackQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, pq.ctx, "Exist") + ctx = setContextOp(ctx, pq.ctx, ent.OpQueryExist) switch _, err := pq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -450,7 +451,7 @@ func (pgb *PlaybackGroupBy) Aggregate(fns ...AggregateFunc) *PlaybackGroupBy { // Scan applies the selector query and scans the result into the given value. func (pgb *PlaybackGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, pgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, pgb.build.ctx, ent.OpQueryGroupBy) if err := pgb.build.prepareQuery(ctx); err != nil { return err } @@ -498,7 +499,7 @@ func (ps *PlaybackSelect) Aggregate(fns ...AggregateFunc) *PlaybackSelect { // Scan applies the selector query and scans the result into the given value. func (ps *PlaybackSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ps.ctx, "Select") + ctx = setContextOp(ctx, ps.ctx, ent.OpQuerySelect) if err := ps.prepareQuery(ctx); err != nil { return err } diff --git a/ent/playlist_query.go b/ent/playlist_query.go index 4bd290fe..c8e9179f 100644 --- a/ent/playlist_query.go +++ b/ent/playlist_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -110,7 +111,7 @@ func (pq *PlaylistQuery) QueryMultistreamInfo() *MultistreamInfoQuery { // First returns the first Playlist entity from the query. // Returns a *NotFoundError when no Playlist was found. func (pq *PlaylistQuery) First(ctx context.Context) (*Playlist, error) { - nodes, err := pq.Limit(1).All(setContextOp(ctx, pq.ctx, "First")) + nodes, err := pq.Limit(1).All(setContextOp(ctx, pq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -133,7 +134,7 @@ func (pq *PlaylistQuery) FirstX(ctx context.Context) *Playlist { // Returns a *NotFoundError when no Playlist ID was found. func (pq *PlaylistQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = pq.Limit(1).IDs(setContextOp(ctx, pq.ctx, "FirstID")); err != nil { + if ids, err = pq.Limit(1).IDs(setContextOp(ctx, pq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -156,7 +157,7 @@ func (pq *PlaylistQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one Playlist entity is found. // Returns a *NotFoundError when no Playlist entities are found. func (pq *PlaylistQuery) Only(ctx context.Context) (*Playlist, error) { - nodes, err := pq.Limit(2).All(setContextOp(ctx, pq.ctx, "Only")) + nodes, err := pq.Limit(2).All(setContextOp(ctx, pq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -184,7 +185,7 @@ func (pq *PlaylistQuery) OnlyX(ctx context.Context) *Playlist { // Returns a *NotFoundError when no entities are found. func (pq *PlaylistQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = pq.Limit(2).IDs(setContextOp(ctx, pq.ctx, "OnlyID")); err != nil { + if ids, err = pq.Limit(2).IDs(setContextOp(ctx, pq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -209,7 +210,7 @@ func (pq *PlaylistQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Playlists. func (pq *PlaylistQuery) All(ctx context.Context) ([]*Playlist, error) { - ctx = setContextOp(ctx, pq.ctx, "All") + ctx = setContextOp(ctx, pq.ctx, ent.OpQueryAll) if err := pq.prepareQuery(ctx); err != nil { return nil, err } @@ -231,7 +232,7 @@ func (pq *PlaylistQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if pq.ctx.Unique == nil && pq.path != nil { pq.Unique(true) } - ctx = setContextOp(ctx, pq.ctx, "IDs") + ctx = setContextOp(ctx, pq.ctx, ent.OpQueryIDs) if err = pq.Select(playlist.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -249,7 +250,7 @@ func (pq *PlaylistQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (pq *PlaylistQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, pq.ctx, "Count") + ctx = setContextOp(ctx, pq.ctx, ent.OpQueryCount) if err := pq.prepareQuery(ctx); err != nil { return 0, err } @@ -267,7 +268,7 @@ func (pq *PlaylistQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (pq *PlaylistQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, pq.ctx, "Exist") + ctx = setContextOp(ctx, pq.ctx, ent.OpQueryExist) switch _, err := pq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -635,7 +636,7 @@ func (pgb *PlaylistGroupBy) Aggregate(fns ...AggregateFunc) *PlaylistGroupBy { // Scan applies the selector query and scans the result into the given value. func (pgb *PlaylistGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, pgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, pgb.build.ctx, ent.OpQueryGroupBy) if err := pgb.build.prepareQuery(ctx); err != nil { return err } @@ -683,7 +684,7 @@ func (ps *PlaylistSelect) Aggregate(fns ...AggregateFunc) *PlaylistSelect { // Scan applies the selector query and scans the result into the given value. func (ps *PlaylistSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ps.ctx, "Select") + ctx = setContextOp(ctx, ps.ctx, ent.OpQuerySelect) if err := ps.prepareQuery(ctx); err != nil { return err } diff --git a/ent/queue_create.go b/ent/queue_create.go index 7e24e27e..303cca1c 100644 --- a/ent/queue_create.go +++ b/ent/queue_create.go @@ -549,7 +549,7 @@ func (qc *QueueCreate) check() error { if _, ok := qc.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Queue.created_at"`)} } - if _, ok := qc.mutation.VodID(); !ok { + if len(qc.mutation.VodIDs()) == 0 { return &ValidationError{Name: "vod", err: errors.New(`ent: missing required edge "Queue.vod"`)} } return nil diff --git a/ent/queue_query.go b/ent/queue_query.go index 38c3083b..289fef90 100644 --- a/ent/queue_query.go +++ b/ent/queue_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -86,7 +87,7 @@ func (qq *QueueQuery) QueryVod() *VodQuery { // First returns the first Queue entity from the query. // Returns a *NotFoundError when no Queue was found. func (qq *QueueQuery) First(ctx context.Context) (*Queue, error) { - nodes, err := qq.Limit(1).All(setContextOp(ctx, qq.ctx, "First")) + nodes, err := qq.Limit(1).All(setContextOp(ctx, qq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -109,7 +110,7 @@ func (qq *QueueQuery) FirstX(ctx context.Context) *Queue { // Returns a *NotFoundError when no Queue ID was found. func (qq *QueueQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = qq.Limit(1).IDs(setContextOp(ctx, qq.ctx, "FirstID")); err != nil { + if ids, err = qq.Limit(1).IDs(setContextOp(ctx, qq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -132,7 +133,7 @@ func (qq *QueueQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one Queue entity is found. // Returns a *NotFoundError when no Queue entities are found. func (qq *QueueQuery) Only(ctx context.Context) (*Queue, error) { - nodes, err := qq.Limit(2).All(setContextOp(ctx, qq.ctx, "Only")) + nodes, err := qq.Limit(2).All(setContextOp(ctx, qq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -160,7 +161,7 @@ func (qq *QueueQuery) OnlyX(ctx context.Context) *Queue { // Returns a *NotFoundError when no entities are found. func (qq *QueueQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = qq.Limit(2).IDs(setContextOp(ctx, qq.ctx, "OnlyID")); err != nil { + if ids, err = qq.Limit(2).IDs(setContextOp(ctx, qq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -185,7 +186,7 @@ func (qq *QueueQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Queues. func (qq *QueueQuery) All(ctx context.Context) ([]*Queue, error) { - ctx = setContextOp(ctx, qq.ctx, "All") + ctx = setContextOp(ctx, qq.ctx, ent.OpQueryAll) if err := qq.prepareQuery(ctx); err != nil { return nil, err } @@ -207,7 +208,7 @@ func (qq *QueueQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if qq.ctx.Unique == nil && qq.path != nil { qq.Unique(true) } - ctx = setContextOp(ctx, qq.ctx, "IDs") + ctx = setContextOp(ctx, qq.ctx, ent.OpQueryIDs) if err = qq.Select(queue.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -225,7 +226,7 @@ func (qq *QueueQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (qq *QueueQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, qq.ctx, "Count") + ctx = setContextOp(ctx, qq.ctx, ent.OpQueryCount) if err := qq.prepareQuery(ctx); err != nil { return 0, err } @@ -243,7 +244,7 @@ func (qq *QueueQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (qq *QueueQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, qq.ctx, "Exist") + ctx = setContextOp(ctx, qq.ctx, ent.OpQueryExist) switch _, err := qq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -537,7 +538,7 @@ func (qgb *QueueGroupBy) Aggregate(fns ...AggregateFunc) *QueueGroupBy { // Scan applies the selector query and scans the result into the given value. func (qgb *QueueGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, qgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, qgb.build.ctx, ent.OpQueryGroupBy) if err := qgb.build.prepareQuery(ctx); err != nil { return err } @@ -585,7 +586,7 @@ func (qs *QueueSelect) Aggregate(fns ...AggregateFunc) *QueueSelect { // Scan applies the selector query and scans the result into the given value. func (qs *QueueSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, qs.ctx, "Select") + ctx = setContextOp(ctx, qs.ctx, ent.OpQuerySelect) if err := qs.prepareQuery(ctx); err != nil { return err } diff --git a/ent/queue_update.go b/ent/queue_update.go index b5f43118..f27479ef 100644 --- a/ent/queue_update.go +++ b/ent/queue_update.go @@ -517,7 +517,7 @@ func (qu *QueueUpdate) check() error { return &ValidationError{Name: "task_chat_move", err: fmt.Errorf(`ent: validator failed for field "Queue.task_chat_move": %w`, err)} } } - if _, ok := qu.mutation.VodID(); qu.mutation.VodCleared() && !ok { + if qu.mutation.VodCleared() && len(qu.mutation.VodIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Queue.vod"`) } return nil @@ -1191,7 +1191,7 @@ func (quo *QueueUpdateOne) check() error { return &ValidationError{Name: "task_chat_move", err: fmt.Errorf(`ent: validator failed for field "Queue.task_chat_move": %w`, err)} } } - if _, ok := quo.mutation.VodID(); quo.mutation.VodCleared() && !ok { + if quo.mutation.VodCleared() && len(quo.mutation.VodIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Queue.vod"`) } return nil diff --git a/ent/runtime.go b/ent/runtime.go index 8ab8471a..2781dc34 100644 --- a/ent/runtime.go +++ b/ent/runtime.go @@ -125,14 +125,18 @@ func init() { liveDescClipsIntervalDays := liveFields[16].Descriptor() // live.DefaultClipsIntervalDays holds the default value on creation for the clips_interval_days field. live.DefaultClipsIntervalDays = liveDescClipsIntervalDays.Default.(int) + // liveDescClipsIgnoreLastChecked is the schema descriptor for clips_ignore_last_checked field. + liveDescClipsIgnoreLastChecked := liveFields[18].Descriptor() + // live.DefaultClipsIgnoreLastChecked holds the default value on creation for the clips_ignore_last_checked field. + live.DefaultClipsIgnoreLastChecked = liveDescClipsIgnoreLastChecked.Default.(bool) // liveDescUpdatedAt is the schema descriptor for updated_at field. - liveDescUpdatedAt := liveFields[18].Descriptor() + liveDescUpdatedAt := liveFields[19].Descriptor() // live.DefaultUpdatedAt holds the default value on creation for the updated_at field. live.DefaultUpdatedAt = liveDescUpdatedAt.Default.(func() time.Time) // live.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. live.UpdateDefaultUpdatedAt = liveDescUpdatedAt.UpdateDefault.(func() time.Time) // liveDescCreatedAt is the schema descriptor for created_at field. - liveDescCreatedAt := liveFields[19].Descriptor() + liveDescCreatedAt := liveFields[20].Descriptor() // live.DefaultCreatedAt holds the default value on creation for the created_at field. live.DefaultCreatedAt = liveDescCreatedAt.Default.(func() time.Time) // liveDescID is the schema descriptor for id field. diff --git a/ent/runtime/runtime.go b/ent/runtime/runtime.go index 36ec57d5..c5458162 100644 --- a/ent/runtime/runtime.go +++ b/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in github.com/zibbp/ganymede/ent/runtime.go const ( - Version = "v0.13.1" // Version of ent codegen. - Sum = "h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE=" // Sum of ent codegen. + Version = "v0.14.1" // Version of ent codegen. + Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen. ) diff --git a/ent/schema/live.go b/ent/schema/live.go index 158bb877..d2c6ac4f 100644 --- a/ent/schema/live.go +++ b/ent/schema/live.go @@ -39,6 +39,7 @@ func (Live) Fields() []ent.Field { field.Int("clips_limit").Default(0).Comment("The number of clips to archive."), field.Int("clips_interval_days").Default(0).Comment("How often channel should be checked for clips to archive in days."), field.Time("clips_last_checked").Comment("Time when clips were last checked.").Optional(), + field.Bool("clips_ignore_last_checked").Default(false).Comment("Ignore last checked time and check all clips."), field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now), field.Time("created_at").Default(time.Now).Immutable(), } diff --git a/ent/sessions_query.go b/ent/sessions_query.go index 7e904227..bda1669e 100644 --- a/ent/sessions_query.go +++ b/ent/sessions_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -60,7 +61,7 @@ func (sq *SessionsQuery) Order(o ...sessions.OrderOption) *SessionsQuery { // First returns the first Sessions entity from the query. // Returns a *NotFoundError when no Sessions was found. func (sq *SessionsQuery) First(ctx context.Context) (*Sessions, error) { - nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) + nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -83,7 +84,7 @@ func (sq *SessionsQuery) FirstX(ctx context.Context) *Sessions { // Returns a *NotFoundError when no Sessions ID was found. func (sq *SessionsQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil { + if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -106,7 +107,7 @@ func (sq *SessionsQuery) FirstIDX(ctx context.Context) int { // Returns a *NotSingularError when more than one Sessions entity is found. // Returns a *NotFoundError when no Sessions entities are found. func (sq *SessionsQuery) Only(ctx context.Context) (*Sessions, error) { - nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only")) + nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -134,7 +135,7 @@ func (sq *SessionsQuery) OnlyX(ctx context.Context) *Sessions { // Returns a *NotFoundError when no entities are found. func (sq *SessionsQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil { + if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -159,7 +160,7 @@ func (sq *SessionsQuery) OnlyIDX(ctx context.Context) int { // All executes the query and returns a list of SessionsSlice. func (sq *SessionsQuery) All(ctx context.Context) ([]*Sessions, error) { - ctx = setContextOp(ctx, sq.ctx, "All") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryAll) if err := sq.prepareQuery(ctx); err != nil { return nil, err } @@ -181,7 +182,7 @@ func (sq *SessionsQuery) IDs(ctx context.Context) (ids []int, err error) { if sq.ctx.Unique == nil && sq.path != nil { sq.Unique(true) } - ctx = setContextOp(ctx, sq.ctx, "IDs") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryIDs) if err = sq.Select(sessions.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -199,7 +200,7 @@ func (sq *SessionsQuery) IDsX(ctx context.Context) []int { // Count returns the count of the given query. func (sq *SessionsQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, sq.ctx, "Count") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryCount) if err := sq.prepareQuery(ctx); err != nil { return 0, err } @@ -217,7 +218,7 @@ func (sq *SessionsQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (sq *SessionsQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, sq.ctx, "Exist") + ctx = setContextOp(ctx, sq.ctx, ent.OpQueryExist) switch _, err := sq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -449,7 +450,7 @@ func (sgb *SessionsGroupBy) Aggregate(fns ...AggregateFunc) *SessionsGroupBy { // Scan applies the selector query and scans the result into the given value. func (sgb *SessionsGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, sgb.build.ctx, ent.OpQueryGroupBy) if err := sgb.build.prepareQuery(ctx); err != nil { return err } @@ -497,7 +498,7 @@ func (ss *SessionsSelect) Aggregate(fns ...AggregateFunc) *SessionsSelect { // Scan applies the selector query and scans the result into the given value. func (ss *SessionsSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ss.ctx, "Select") + ctx = setContextOp(ctx, ss.ctx, ent.OpQuerySelect) if err := ss.prepareQuery(ctx); err != nil { return err } diff --git a/ent/twitchcategory_query.go b/ent/twitchcategory_query.go index 0d6a5e25..497e5740 100644 --- a/ent/twitchcategory_query.go +++ b/ent/twitchcategory_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -60,7 +61,7 @@ func (tcq *TwitchCategoryQuery) Order(o ...twitchcategory.OrderOption) *TwitchCa // First returns the first TwitchCategory entity from the query. // Returns a *NotFoundError when no TwitchCategory was found. func (tcq *TwitchCategoryQuery) First(ctx context.Context) (*TwitchCategory, error) { - nodes, err := tcq.Limit(1).All(setContextOp(ctx, tcq.ctx, "First")) + nodes, err := tcq.Limit(1).All(setContextOp(ctx, tcq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -83,7 +84,7 @@ func (tcq *TwitchCategoryQuery) FirstX(ctx context.Context) *TwitchCategory { // Returns a *NotFoundError when no TwitchCategory ID was found. func (tcq *TwitchCategoryQuery) FirstID(ctx context.Context) (id string, err error) { var ids []string - if ids, err = tcq.Limit(1).IDs(setContextOp(ctx, tcq.ctx, "FirstID")); err != nil { + if ids, err = tcq.Limit(1).IDs(setContextOp(ctx, tcq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -106,7 +107,7 @@ func (tcq *TwitchCategoryQuery) FirstIDX(ctx context.Context) string { // Returns a *NotSingularError when more than one TwitchCategory entity is found. // Returns a *NotFoundError when no TwitchCategory entities are found. func (tcq *TwitchCategoryQuery) Only(ctx context.Context) (*TwitchCategory, error) { - nodes, err := tcq.Limit(2).All(setContextOp(ctx, tcq.ctx, "Only")) + nodes, err := tcq.Limit(2).All(setContextOp(ctx, tcq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -134,7 +135,7 @@ func (tcq *TwitchCategoryQuery) OnlyX(ctx context.Context) *TwitchCategory { // Returns a *NotFoundError when no entities are found. func (tcq *TwitchCategoryQuery) OnlyID(ctx context.Context) (id string, err error) { var ids []string - if ids, err = tcq.Limit(2).IDs(setContextOp(ctx, tcq.ctx, "OnlyID")); err != nil { + if ids, err = tcq.Limit(2).IDs(setContextOp(ctx, tcq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -159,7 +160,7 @@ func (tcq *TwitchCategoryQuery) OnlyIDX(ctx context.Context) string { // All executes the query and returns a list of TwitchCategories. func (tcq *TwitchCategoryQuery) All(ctx context.Context) ([]*TwitchCategory, error) { - ctx = setContextOp(ctx, tcq.ctx, "All") + ctx = setContextOp(ctx, tcq.ctx, ent.OpQueryAll) if err := tcq.prepareQuery(ctx); err != nil { return nil, err } @@ -181,7 +182,7 @@ func (tcq *TwitchCategoryQuery) IDs(ctx context.Context) (ids []string, err erro if tcq.ctx.Unique == nil && tcq.path != nil { tcq.Unique(true) } - ctx = setContextOp(ctx, tcq.ctx, "IDs") + ctx = setContextOp(ctx, tcq.ctx, ent.OpQueryIDs) if err = tcq.Select(twitchcategory.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -199,7 +200,7 @@ func (tcq *TwitchCategoryQuery) IDsX(ctx context.Context) []string { // Count returns the count of the given query. func (tcq *TwitchCategoryQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, tcq.ctx, "Count") + ctx = setContextOp(ctx, tcq.ctx, ent.OpQueryCount) if err := tcq.prepareQuery(ctx); err != nil { return 0, err } @@ -217,7 +218,7 @@ func (tcq *TwitchCategoryQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (tcq *TwitchCategoryQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, tcq.ctx, "Exist") + ctx = setContextOp(ctx, tcq.ctx, ent.OpQueryExist) switch _, err := tcq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -449,7 +450,7 @@ func (tcgb *TwitchCategoryGroupBy) Aggregate(fns ...AggregateFunc) *TwitchCatego // Scan applies the selector query and scans the result into the given value. func (tcgb *TwitchCategoryGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, tcgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, tcgb.build.ctx, ent.OpQueryGroupBy) if err := tcgb.build.prepareQuery(ctx); err != nil { return err } @@ -497,7 +498,7 @@ func (tcs *TwitchCategorySelect) Aggregate(fns ...AggregateFunc) *TwitchCategory // Scan applies the selector query and scans the result into the given value. func (tcs *TwitchCategorySelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, tcs.ctx, "Select") + ctx = setContextOp(ctx, tcs.ctx, ent.OpQuerySelect) if err := tcs.prepareQuery(ctx); err != nil { return err } diff --git a/ent/user_query.go b/ent/user_query.go index c089c61b..26cca329 100644 --- a/ent/user_query.go +++ b/ent/user_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -61,7 +62,7 @@ func (uq *UserQuery) Order(o ...user.OrderOption) *UserQuery { // First returns the first User entity from the query. // Returns a *NotFoundError when no User was found. func (uq *UserQuery) First(ctx context.Context) (*User, error) { - nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, "First")) + nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -84,7 +85,7 @@ func (uq *UserQuery) FirstX(ctx context.Context) *User { // Returns a *NotFoundError when no User ID was found. func (uq *UserQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, "FirstID")); err != nil { + if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -107,7 +108,7 @@ func (uq *UserQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one User entity is found. // Returns a *NotFoundError when no User entities are found. func (uq *UserQuery) Only(ctx context.Context) (*User, error) { - nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, "Only")) + nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -135,7 +136,7 @@ func (uq *UserQuery) OnlyX(ctx context.Context) *User { // Returns a *NotFoundError when no entities are found. func (uq *UserQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, "OnlyID")); err != nil { + if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -160,7 +161,7 @@ func (uq *UserQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Users. func (uq *UserQuery) All(ctx context.Context) ([]*User, error) { - ctx = setContextOp(ctx, uq.ctx, "All") + ctx = setContextOp(ctx, uq.ctx, ent.OpQueryAll) if err := uq.prepareQuery(ctx); err != nil { return nil, err } @@ -182,7 +183,7 @@ func (uq *UserQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if uq.ctx.Unique == nil && uq.path != nil { uq.Unique(true) } - ctx = setContextOp(ctx, uq.ctx, "IDs") + ctx = setContextOp(ctx, uq.ctx, ent.OpQueryIDs) if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -200,7 +201,7 @@ func (uq *UserQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (uq *UserQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, uq.ctx, "Count") + ctx = setContextOp(ctx, uq.ctx, ent.OpQueryCount) if err := uq.prepareQuery(ctx); err != nil { return 0, err } @@ -218,7 +219,7 @@ func (uq *UserQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (uq *UserQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, uq.ctx, "Exist") + ctx = setContextOp(ctx, uq.ctx, ent.OpQueryExist) switch _, err := uq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -450,7 +451,7 @@ func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy { // Scan applies the selector query and scans the result into the given value. func (ugb *UserGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ugb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, ugb.build.ctx, ent.OpQueryGroupBy) if err := ugb.build.prepareQuery(ctx); err != nil { return err } @@ -498,7 +499,7 @@ func (us *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect { // Scan applies the selector query and scans the result into the given value. func (us *UserSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, us.ctx, "Select") + ctx = setContextOp(ctx, us.ctx, ent.OpQuerySelect) if err := us.prepareQuery(ctx); err != nil { return err } diff --git a/ent/vod_create.go b/ent/vod_create.go index f323b500..aaab158d 100644 --- a/ent/vod_create.go +++ b/ent/vod_create.go @@ -825,7 +825,7 @@ func (vc *VodCreate) check() error { if _, ok := vc.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Vod.created_at"`)} } - if _, ok := vc.mutation.ChannelID(); !ok { + if len(vc.mutation.ChannelIDs()) == 0 { return &ValidationError{Name: "channel", err: errors.New(`ent: missing required edge "Vod.channel"`)} } return nil diff --git a/ent/vod_query.go b/ent/vod_query.go index 0fbc609a..fb80da87 100644 --- a/ent/vod_query.go +++ b/ent/vod_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -207,7 +208,7 @@ func (vq *VodQuery) QueryMultistreamInfo() *MultistreamInfoQuery { // First returns the first Vod entity from the query. // Returns a *NotFoundError when no Vod was found. func (vq *VodQuery) First(ctx context.Context) (*Vod, error) { - nodes, err := vq.Limit(1).All(setContextOp(ctx, vq.ctx, "First")) + nodes, err := vq.Limit(1).All(setContextOp(ctx, vq.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -230,7 +231,7 @@ func (vq *VodQuery) FirstX(ctx context.Context) *Vod { // Returns a *NotFoundError when no Vod ID was found. func (vq *VodQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = vq.Limit(1).IDs(setContextOp(ctx, vq.ctx, "FirstID")); err != nil { + if ids, err = vq.Limit(1).IDs(setContextOp(ctx, vq.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -253,7 +254,7 @@ func (vq *VodQuery) FirstIDX(ctx context.Context) uuid.UUID { // Returns a *NotSingularError when more than one Vod entity is found. // Returns a *NotFoundError when no Vod entities are found. func (vq *VodQuery) Only(ctx context.Context) (*Vod, error) { - nodes, err := vq.Limit(2).All(setContextOp(ctx, vq.ctx, "Only")) + nodes, err := vq.Limit(2).All(setContextOp(ctx, vq.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -281,7 +282,7 @@ func (vq *VodQuery) OnlyX(ctx context.Context) *Vod { // Returns a *NotFoundError when no entities are found. func (vq *VodQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { var ids []uuid.UUID - if ids, err = vq.Limit(2).IDs(setContextOp(ctx, vq.ctx, "OnlyID")); err != nil { + if ids, err = vq.Limit(2).IDs(setContextOp(ctx, vq.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -306,7 +307,7 @@ func (vq *VodQuery) OnlyIDX(ctx context.Context) uuid.UUID { // All executes the query and returns a list of Vods. func (vq *VodQuery) All(ctx context.Context) ([]*Vod, error) { - ctx = setContextOp(ctx, vq.ctx, "All") + ctx = setContextOp(ctx, vq.ctx, ent.OpQueryAll) if err := vq.prepareQuery(ctx); err != nil { return nil, err } @@ -328,7 +329,7 @@ func (vq *VodQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { if vq.ctx.Unique == nil && vq.path != nil { vq.Unique(true) } - ctx = setContextOp(ctx, vq.ctx, "IDs") + ctx = setContextOp(ctx, vq.ctx, ent.OpQueryIDs) if err = vq.Select(vod.FieldID).Scan(ctx, &ids); err != nil { return nil, err } @@ -346,7 +347,7 @@ func (vq *VodQuery) IDsX(ctx context.Context) []uuid.UUID { // Count returns the count of the given query. func (vq *VodQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, vq.ctx, "Count") + ctx = setContextOp(ctx, vq.ctx, ent.OpQueryCount) if err := vq.prepareQuery(ctx); err != nil { return 0, err } @@ -364,7 +365,7 @@ func (vq *VodQuery) CountX(ctx context.Context) int { // Exist returns true if the query has elements in the graph. func (vq *VodQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, vq.ctx, "Exist") + ctx = setContextOp(ctx, vq.ctx, ent.OpQueryExist) switch _, err := vq.FirstID(ctx); { case IsNotFound(err): return false, nil @@ -939,7 +940,7 @@ func (vgb *VodGroupBy) Aggregate(fns ...AggregateFunc) *VodGroupBy { // Scan applies the selector query and scans the result into the given value. func (vgb *VodGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, vgb.build.ctx, "GroupBy") + ctx = setContextOp(ctx, vgb.build.ctx, ent.OpQueryGroupBy) if err := vgb.build.prepareQuery(ctx); err != nil { return err } @@ -987,7 +988,7 @@ func (vs *VodSelect) Aggregate(fns ...AggregateFunc) *VodSelect { // Scan applies the selector query and scans the result into the given value. func (vs *VodSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, vs.ctx, "Select") + ctx = setContextOp(ctx, vs.ctx, ent.OpQuerySelect) if err := vs.prepareQuery(ctx); err != nil { return err } diff --git a/ent/vod_update.go b/ent/vod_update.go index 56766f8f..4d855365 100644 --- a/ent/vod_update.go +++ b/ent/vod_update.go @@ -1065,7 +1065,7 @@ func (vu *VodUpdate) check() error { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Vod.type": %w`, err)} } } - if _, ok := vu.mutation.ChannelID(); vu.mutation.ChannelCleared() && !ok { + if vu.mutation.ChannelCleared() && len(vu.mutation.ChannelIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Vod.channel"`) } return nil @@ -2618,7 +2618,7 @@ func (vuo *VodUpdateOne) check() error { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Vod.type": %w`, err)} } } - if _, ok := vuo.mutation.ChannelID(); vuo.mutation.ChannelCleared() && !ok { + if vuo.mutation.ChannelCleared() && len(vuo.mutation.ChannelIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Vod.channel"`) } return nil diff --git a/frontend/app/components/admin/watched/DrawerContent.tsx b/frontend/app/components/admin/watched/DrawerContent.tsx index a233c6a5..55da1ffe 100644 --- a/frontend/app/components/admin/watched/DrawerContent.tsx +++ b/frontend/app/components/admin/watched/DrawerContent.tsx @@ -1,13 +1,15 @@ import { useAxiosPrivate } from "@/app/hooks/useAxios"; import { Channel, useFetchChannels } from "@/app/hooks/useChannels"; import { WatchedChannel, WatchedChannelTitleRegex, useCreateWatchedChannel, useEditWatchedChannel } from "@/app/hooks/useWatchedChannels"; -import { ActionIcon, Button, NumberInput, TextInput, Tooltip, Text, Divider, Checkbox, Select, Title, Box, Group, Grid, MultiSelect } from "@mantine/core"; +import { ActionIcon, Button, NumberInput, TextInput, Tooltip, Text, Divider, Checkbox, Select, Title, Box, Group, Grid, MultiSelect, Collapse } from "@mantine/core"; import { useForm } from "@mantine/form"; import { showNotification } from "@mantine/notifications"; import { IconPlus, IconTrash } from "@tabler/icons-react"; import { useEffect, useState } from "react"; import classes from "./Watched.module.css" import { getTwitchCategories } from "@/app/hooks/useCategory"; +import { useDisclosure } from "@mantine/hooks"; +import Link from "next/link"; type Props = { watchedChannel: WatchedChannel | null @@ -42,6 +44,8 @@ const AdminWatchedChannelDrawerContent = ({ watchedChannel, mode, handleClose }: const [channelSelect, setChannelSelect] = useState([]); + const [clipMoreInfoOpened, { toggle: clipMoreInfoToggle }] = useDisclosure(false); + // Initialize edit watched channel mutation const editWatchedChannelMutation = useEditWatchedChannel(); @@ -64,6 +68,7 @@ const AdminWatchedChannelDrawerContent = ({ watchedChannel, mode, handleClose }: watch_clips: watchedChannel?.watch_clips ?? false, clips_limit: watchedChannel?.clips_limit || 5, clips_interval_days: watchedChannel?.clips_interval_days || 7, + clips_ignore_last_checked: watchedChannel?.clips_ignore_last_checked ?? false, live_title_regexes: [], categories: [] as string[], }, @@ -126,6 +131,7 @@ const AdminWatchedChannelDrawerContent = ({ watchedChannel, mode, handleClose }: watch_clips: formValues.watch_clips, clips_limit: formValues.clips_limit, clips_interval_days: formValues.clips_interval_days, + clips_ignore_last_checked: formValues.clips_ignore_last_checked, is_live: false, // Default value edges: { channel: { id: formValues.channel_id } as Channel, @@ -167,6 +173,7 @@ const AdminWatchedChannelDrawerContent = ({ watchedChannel, mode, handleClose }: watch_clips: formValues.watch_clips, clips_limit: formValues.clips_limit, clips_interval_days: formValues.clips_interval_days, + clips_ignore_last_checked: formValues.clips_ignore_last_checked, edges: { ...watchedChannel.edges, title_regex: liveTitleRegexes @@ -213,6 +220,8 @@ const AdminWatchedChannelDrawerContent = ({ watchedChannel, mode, handleClose }: return (
+ Read the watched channel wiki page for more information about each feature. +
{ handleSubmitForm() })}> @@ -323,9 +332,19 @@ const AdminWatchedChannelDrawerContent = ({ watchedChannel, mode, handleClose }: Channel Clips Archive past channel clips. - This feature is meant to archive the most popular (view count) clips the past interval days. For example, if you set number of clips to 5 and interval to 7, the top 5 clips from the past 7 days will be archived. It will not run again until 7 days have passed. No restrictions (categories, age, title, regex, etc) are applied to this. + This feature is meant to archive the most popular (view count) clips from the past interval days. For example, if you set number of clips to 5 and interval to 7, the top 5 clips from the past 7 days will be archived. It will not run again until 7 days have passed. No restrictions (categories, age, title, regex, etc) are applied to this. + + More Information + + + + If you want to perform a one-time import of a channel's most popular clips, set the interval to a large number (1000) and the number of clips to a large number (250). This will import the top 250 clips from the past 1000 days. It is recommended to change the interval and number of clips to a lower number after the initial import. + + + + + +
diff --git a/frontend/app/hooks/useWatchedChannels.ts b/frontend/app/hooks/useWatchedChannels.ts index 5c22149b..855ad4fe 100644 --- a/frontend/app/hooks/useWatchedChannels.ts +++ b/frontend/app/hooks/useWatchedChannels.ts @@ -23,6 +23,7 @@ export interface WatchedChannel { watch_clips: boolean; clips_limit: number; clips_interval_days: number; + clips_ignore_last_checked: boolean; updated_at: string; created_at: string; edges: WatchedChannelEdges; @@ -77,6 +78,7 @@ const editWatchedChannel = async ( watch_clips: watchedChannel.watch_clips, clips_limit: watchedChannel.clips_limit, clips_interval_days: watchedChannel.clips_interval_days, + clips_ignore_last_checked: watchedChannel.clips_ignore_last_checked, }); return response.data.data; }; @@ -105,6 +107,7 @@ const createWatchedChannel = async ( watch_clips: watchedChannel.watch_clips, clips_limit: watchedChannel.clips_limit, clips_interval_days: watchedChannel.clips_interval_days, + clips_ignore_last_checked: watchedChannel.clips_ignore_last_checked, }); return response.data.data; }; diff --git a/go.sum b/go.sum index bc5deebe..f9b24b79 100644 --- a/go.sum +++ b/go.sum @@ -301,6 +301,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -348,6 +350,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/npillmayer/nestext v0.1.3/go.mod h1:h2lrijH8jpicr25dFY+oAJLyzlya6jhnuG+zWp9L0Uk= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= @@ -431,6 +435,9 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/internal/channel/channel.go b/internal/channel/channel.go index 97dfae7d..a6027612 100644 --- a/internal/channel/channel.go +++ b/internal/channel/channel.go @@ -134,7 +134,6 @@ func (s *Service) UpdateChannel(cId uuid.UUID, channelDto Channel) (*ent.Channel func (s *Service) CheckChannelExists(cName string) bool { _, err := s.Store.Client.Channel.Query().Where(channel.Name(cName)).Only(context.Background()) if err != nil { - fmt.Println(err) // if channel not found if _, ok := err.(*ent.NotFoundError); ok { return false @@ -150,7 +149,6 @@ func (s *Service) CheckChannelExists(cName string) bool { func (s *Service) CheckChannelExistsByExtId(id string) bool { _, err := s.Store.Client.Channel.Query().Where(channel.ExtID(id)).Only(context.Background()) if err != nil { - fmt.Println(err) // if channel not found if _, ok := err.(*ent.NotFoundError); ok { return false diff --git a/internal/chat/seventv.go b/internal/chat/seventv.go index 166bbbce..35cec054 100644 --- a/internal/chat/seventv.go +++ b/internal/chat/seventv.go @@ -192,7 +192,6 @@ func Get7TVGlobalEmotes(ctx context.Context) ([]platform.Emote, error) { } func Get7TVChannelEmotes(ctx context.Context, channelId string) ([]platform.Emote, error) { - fmt.Println("foooo") client := &http.Client{} req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://7tv.io/v3/users/twitch/%s", channelId), nil) if err != nil { diff --git a/internal/live/clip.go b/internal/live/clip.go index 830fb479..e712880c 100644 --- a/internal/live/clip.go +++ b/internal/live/clip.go @@ -2,10 +2,10 @@ package live import ( "context" + "strconv" "time" "github.com/rs/zerolog" - "github.com/rs/zerolog/log" "github.com/zibbp/ganymede/ent/channel" "github.com/zibbp/ganymede/ent/live" "github.com/zibbp/ganymede/ent/vod" @@ -36,28 +36,45 @@ func (s *Service) CheckWatchedChannelClips(ctx context.Context, logger zerolog.L continue } - // Check if clips need to be checked for channel now := time.Now() - lastChecked := watchedChannel.ClipsLastChecked - - // Round times down to the nearest hour to avoid partial hour comparisons - roundedNow := now.Truncate(time.Hour) - roundedLastChecked := lastChecked.Truncate(time.Hour) - - // Calculate full hours between checks - diffHours := roundedNow.Sub(roundedLastChecked).Hours() - channelIntervalHours := watchedChannel.ClipsIntervalDays * 24 - - if diffHours < float64(channelIntervalHours) { - logger.Info(). - Str("channel", watchedChannel.Edges.Channel.DisplayName). - Float64("hours_passed", diffHours). - Int("hours_required", channelIntervalHours). - Msg("skipping clip check, not enough time has passed") - continue + // Check if channel clips should be checked + if !watchedChannel.ClipsIgnoreLastChecked { + // Check if clips need to be checked for channel + lastChecked := watchedChannel.ClipsLastChecked + + // Round times down to the nearest hour to avoid partial hour comparisons + roundedNow := now.Truncate(time.Hour) + roundedLastChecked := lastChecked.Truncate(time.Hour) + + // Calculate full hours between checks + diffHours := roundedNow.Sub(roundedLastChecked).Hours() + // Calculate channel interval in hours + // Default to 24 hours if not set (archiving all clips) + var channelIntervalHours int + if watchedChannel.ClipsIntervalDays == 0 { + channelIntervalHours = 24 + } else { + channelIntervalHours = watchedChannel.ClipsIntervalDays * 24 + } + + if diffHours < float64(channelIntervalHours) { + logger.Info(). + Str("channel", watchedChannel.Edges.Channel.DisplayName). + Float64("hours_passed", diffHours). + Int("hours_required", channelIntervalHours). + Msg("skipping clip check, not enough time has passed") + continue + } } - startedAt := now.AddDate(0, 0, -watchedChannel.ClipsIntervalDays) + var startedAt time.Time + if watchedChannel.ClipsIntervalDays == 0 { + startedAt = time.Time{} + } else { + startedAt = now.AddDate(0, 0, -watchedChannel.ClipsIntervalDays) + } + + logger.Info().Str("limit", strconv.Itoa(watchedChannel.ClipsLimit)).Str("started_at", startedAt.String()).Msgf("getting clips for channel %s", watchedChannel.Edges.Channel.Name) // Get clips clips, err := s.PlatformTwitch.GetChannelClips(ctx, watchedChannel.Edges.Channel.ExtID, platform.ClipsFilter{ @@ -70,6 +87,8 @@ func (s *Service) CheckWatchedChannelClips(ctx context.Context, logger zerolog.L continue } + logger.Info().Str("channel", watchedChannel.Edges.Channel.Name).Int("clips", len(clips)).Msg("got clips") + // Fetch all videos from DB dbVideos, err := s.Store.Client.Vod.Query().Where(vod.HasChannelWith(channel.ID(watchedChannel.Edges.Channel.ID))).All(context.Background()) if err != nil { @@ -79,6 +98,7 @@ func (s *Service) CheckWatchedChannelClips(ctx context.Context, logger zerolog.L // Check if video is already in DB for _, clip := range clips { + logger.Debug().Str("clip_id", clip.ID).Msg("checking if clip should be archived") // Video is not in DB if !contains(dbVideos, clip.ID) { // Archive clip @@ -90,10 +110,12 @@ func (s *Service) CheckWatchedChannelClips(ctx context.Context, logger zerolog.L } err = s.ArchiveService.ArchiveClip(ctx, input) if err != nil { - log.Error().Err(err).Str("clip_id", clip.ID).Msgf("error archiving clip") + logger.Error().Err(err).Str("clip_id", clip.ID).Msgf("error archiving clip") continue } logger.Info().Str("clip_id", clip.ID).Msgf("archiving clip") + } else { + logger.Debug().Str("clip_id", clip.ID).Msgf("clip already archived") } } diff --git a/internal/live/live.go b/internal/live/live.go index c098b6af..7b5668c4 100644 --- a/internal/live/live.go +++ b/internal/live/live.go @@ -33,25 +33,26 @@ type Service struct { } type Live struct { - ID uuid.UUID `json:"id"` - WatchLive bool `json:"watch_live"` - WatchVod bool `json:"watch_vod"` - DownloadArchives bool `json:"download_archives"` - DownloadHighlights bool `json:"download_highlights"` - DownloadUploads bool `json:"download_uploads"` - IsLive bool `json:"is_live"` - ArchiveChat bool `json:"archive_chat"` - Resolution string `json:"resolution"` - LastLive time.Time `json:"last_live"` - RenderChat bool `json:"render_chat"` - DownloadSubOnly bool `json:"download_sub_only"` - Categories []string `json:"categories"` - ApplyCategoriesToLive bool `json:"apply_categories_to_live"` - VideoAge int64 `json:"video_age"` // Restrict fetching videos to a certain age. - TitleRegex []ent.LiveTitleRegex `json:"title_regex"` - WatchClips bool `json:"watch_clips"` - ClipsLimit int `json:"clips_limit"` - ClipsIntervalDays int `json:"clips_interval_days"` + ID uuid.UUID `json:"id"` + WatchLive bool `json:"watch_live"` + WatchVod bool `json:"watch_vod"` + DownloadArchives bool `json:"download_archives"` + DownloadHighlights bool `json:"download_highlights"` + DownloadUploads bool `json:"download_uploads"` + IsLive bool `json:"is_live"` + ArchiveChat bool `json:"archive_chat"` + Resolution string `json:"resolution"` + LastLive time.Time `json:"last_live"` + RenderChat bool `json:"render_chat"` + DownloadSubOnly bool `json:"download_sub_only"` + Categories []string `json:"categories"` + ApplyCategoriesToLive bool `json:"apply_categories_to_live"` + VideoAge int64 `json:"video_age"` // Restrict fetching videos to a certain age. + TitleRegex []ent.LiveTitleRegex `json:"title_regex"` + WatchClips bool `json:"watch_clips"` + ClipsLimit int `json:"clips_limit"` + ClipsIntervalDays int `json:"clips_interval_days"` + ClipsIgnoreLastChecked bool `json:"clips_ignore_last_checked"` } type ConvertChat struct { @@ -92,7 +93,7 @@ func (s *Service) AddLiveWatchedChannel(c echo.Context, liveDto Live) (*ent.Live return nil, fmt.Errorf("channel already watched") } - l, err := s.Store.Client.Live.Create().SetChannelID(liveDto.ID).SetWatchLive(liveDto.WatchLive).SetWatchVod(liveDto.WatchVod).SetDownloadArchives(liveDto.DownloadArchives).SetDownloadHighlights(liveDto.DownloadHighlights).SetDownloadUploads(liveDto.DownloadUploads).SetResolution(liveDto.Resolution).SetArchiveChat(liveDto.ArchiveChat).SetRenderChat(liveDto.RenderChat).SetDownloadSubOnly(liveDto.DownloadSubOnly).SetVideoAge(liveDto.VideoAge).SetApplyCategoriesToLive(liveDto.ApplyCategoriesToLive).SetWatchClips(liveDto.WatchClips).SetClipsLimit(liveDto.ClipsLimit).SetClipsIntervalDays(liveDto.ClipsIntervalDays).Save(c.Request().Context()) + l, err := s.Store.Client.Live.Create().SetChannelID(liveDto.ID).SetWatchLive(liveDto.WatchLive).SetWatchVod(liveDto.WatchVod).SetDownloadArchives(liveDto.DownloadArchives).SetDownloadHighlights(liveDto.DownloadHighlights).SetDownloadUploads(liveDto.DownloadUploads).SetResolution(liveDto.Resolution).SetArchiveChat(liveDto.ArchiveChat).SetRenderChat(liveDto.RenderChat).SetDownloadSubOnly(liveDto.DownloadSubOnly).SetVideoAge(liveDto.VideoAge).SetApplyCategoriesToLive(liveDto.ApplyCategoriesToLive).SetWatchClips(liveDto.WatchClips).SetClipsLimit(liveDto.ClipsLimit).SetClipsIntervalDays(liveDto.ClipsIntervalDays).SetClipsIgnoreLastChecked(liveDto.ClipsIgnoreLastChecked).Save(c.Request().Context()) if err != nil { return nil, fmt.Errorf("error adding watched channel: %v", err) } @@ -118,7 +119,7 @@ func (s *Service) AddLiveWatchedChannel(c echo.Context, liveDto Live) (*ent.Live } func (s *Service) UpdateLiveWatchedChannel(c echo.Context, liveDto Live) (*ent.Live, error) { - l, err := s.Store.Client.Live.UpdateOneID(liveDto.ID).SetWatchLive(liveDto.WatchLive).SetWatchVod(liveDto.WatchVod).SetDownloadArchives(liveDto.DownloadArchives).SetDownloadHighlights(liveDto.DownloadHighlights).SetDownloadUploads(liveDto.DownloadUploads).SetResolution(liveDto.Resolution).SetArchiveChat(liveDto.ArchiveChat).SetRenderChat(liveDto.RenderChat).SetDownloadSubOnly(liveDto.DownloadSubOnly).SetVideoAge(liveDto.VideoAge).SetApplyCategoriesToLive(liveDto.ApplyCategoriesToLive).SetClipsLimit(liveDto.ClipsLimit).SetClipsIntervalDays(liveDto.ClipsIntervalDays).SetWatchClips(liveDto.WatchClips).Save(c.Request().Context()) + l, err := s.Store.Client.Live.UpdateOneID(liveDto.ID).SetWatchLive(liveDto.WatchLive).SetWatchVod(liveDto.WatchVod).SetDownloadArchives(liveDto.DownloadArchives).SetDownloadHighlights(liveDto.DownloadHighlights).SetDownloadUploads(liveDto.DownloadUploads).SetResolution(liveDto.Resolution).SetArchiveChat(liveDto.ArchiveChat).SetRenderChat(liveDto.RenderChat).SetDownloadSubOnly(liveDto.DownloadSubOnly).SetVideoAge(liveDto.VideoAge).SetApplyCategoriesToLive(liveDto.ApplyCategoriesToLive).SetClipsLimit(liveDto.ClipsLimit).SetClipsIntervalDays(liveDto.ClipsIntervalDays).SetClipsIgnoreLastChecked(liveDto.ClipsIgnoreLastChecked).SetWatchClips(liveDto.WatchClips).Save(c.Request().Context()) if err != nil { return nil, fmt.Errorf("error updating watched channel: %v", err) } diff --git a/internal/platform/twitch.go b/internal/platform/twitch.go index e41de195..82ce0a72 100644 --- a/internal/platform/twitch.go +++ b/internal/platform/twitch.go @@ -607,11 +607,14 @@ func ArchiveVideoActivity(ctx context.Context, input dto.ArchiveVideoInput) erro // GetChannelClips gets a Twitch channel's clip with some filter options. Twitch returns the clips sorted by view count descending. func (c *TwitchConnection) GetChannelClips(ctx context.Context, channelId string, filter ClipsFilter) ([]ClipInfo, error) { - // todo: allow more than 100 clips - if filter.Limit > 100 { - return nil, fmt.Errorf("clips limited to a max of 100") + internalLimit := filter.Limit + + // set limit to 100 if limit is 0 or greater than 100 + if filter.Limit == 0 || filter.Limit > 100 { + internalLimit = 100 } - limitStr := strconv.Itoa(filter.Limit) + + limitStr := strconv.Itoa(internalLimit) params := url.Values{ "broadcaster_id": []string{channelId}, "started_at": []string{filter.StartedAt.Format(time.RFC3339)}, @@ -633,6 +636,34 @@ func (c *TwitchConnection) GetChannelClips(ctx context.Context, channelId string var clips []TwitchClip clips = append(clips, resp.Data...) + // pagination + cursor := resp.Pagination.Cursor + for cursor != "" { + params.Del("after") + params.Set("after", cursor) + + body, err := c.twitchMakeHTTPRequest("GET", "clips", params, nil) + if err != nil { + return nil, err + } + + var resp TwitchGetClipsResponse + err = json.Unmarshal(body, &resp) + if err != nil { + return nil, err + } + + clips = append(clips, resp.Data...) + cursor = resp.Pagination.Cursor + + // break if limit is reached except if limit is 0 (all clips) + if filter.Limit != 0 { + if len(clips) >= filter.Limit { + break + } + } + } + var info []ClipInfo for _, clip := range clips { // parse dates @@ -667,6 +698,11 @@ func (c *TwitchConnection) GetChannelClips(ctx context.Context, channelId string }) } + // get exact number of clips if limit is set + if filter.Limit != 0 && filter.Limit < len(info) { + info = info[:filter.Limit] + } + return info, nil } diff --git a/internal/transport/http/live.go b/internal/transport/http/live.go index dd841019..426a8970 100644 --- a/internal/transport/http/live.go +++ b/internal/transport/http/live.go @@ -20,23 +20,24 @@ type LiveService interface { } type AddWatchedChannelRequest struct { - WatchLive bool `json:"watch_live" validate:"boolean"` - WatchVod bool `json:"watch_vod" validate:"boolean"` - DownloadArchives bool `json:"download_archives" validate:"boolean"` - DownloadHighlights bool `json:"download_highlights" validate:"boolean"` - DownloadUploads bool `json:"download_uploads" validate:"boolean"` - ChannelID string `json:"channel_id" validate:"required"` - Resolution string `json:"resolution" validate:"required,oneof=best source 720p60 480p 360p 160p 480p30 360p30 160p30 audio"` - ArchiveChat bool `json:"archive_chat" validate:"boolean"` - RenderChat bool `json:"render_chat" validate:"boolean"` - DownloadSubOnly bool `json:"download_sub_only" validate:"boolean"` - Categories []string `json:"categories"` - ApplyCategoriesToLive bool `json:"apply_categories_to_live" validate:"boolean"` - VideoAge int64 `json:"video_age"` // retrict fetching videos to a certain age - Regex []AddLiveTitleRegex `json:"regex"` - WatchClips bool `json:"watch_clips" validate:"boolean"` - ClipsLimit int `json:"clips_limit" validate:"number,gte=1"` - ClipsIntervalDays int `json:"clips_interval_days" validate:"number,gte=1"` + WatchLive bool `json:"watch_live" validate:"boolean"` + WatchVod bool `json:"watch_vod" validate:"boolean"` + DownloadArchives bool `json:"download_archives" validate:"boolean"` + DownloadHighlights bool `json:"download_highlights" validate:"boolean"` + DownloadUploads bool `json:"download_uploads" validate:"boolean"` + ChannelID string `json:"channel_id" validate:"required"` + Resolution string `json:"resolution" validate:"required,oneof=best source 720p60 480p 360p 160p 480p30 360p30 160p30 audio"` + ArchiveChat bool `json:"archive_chat" validate:"boolean"` + RenderChat bool `json:"render_chat" validate:"boolean"` + DownloadSubOnly bool `json:"download_sub_only" validate:"boolean"` + Categories []string `json:"categories"` + ApplyCategoriesToLive bool `json:"apply_categories_to_live" validate:"boolean"` + VideoAge int64 `json:"video_age"` // retrict fetching videos to a certain age + Regex []AddLiveTitleRegex `json:"regex"` + WatchClips bool `json:"watch_clips" validate:"boolean"` + ClipsLimit int `json:"clips_limit" validate:"number,gte=1"` + ClipsIntervalDays int `json:"clips_interval_days" validate:"number,gte=1"` + ClipsIgnoreLastChecked bool `json:"clips_ignore_last_checked" validate:"boolean"` } type AddLiveTitleRegex struct { @@ -46,22 +47,23 @@ type AddLiveTitleRegex struct { } type UpdateWatchedChannelRequest struct { - WatchLive bool `json:"watch_live" validate:"boolean"` - WatchVod bool `json:"watch_vod" validate:"boolean"` - DownloadArchives bool `json:"download_archives" validate:"boolean"` - DownloadHighlights bool `json:"download_highlights" validate:"boolean"` - DownloadUploads bool `json:"download_uploads" validate:"boolean"` - Resolution string `json:"resolution" validate:"required,oneof=best source 720p60 480p 360p 160p 480p30 360p30 160p30 audio"` - ArchiveChat bool `json:"archive_chat" validate:"boolean"` - RenderChat bool `json:"render_chat" validate:"boolean"` - DownloadSubOnly bool `json:"download_sub_only" validate:"boolean"` - Categories []string `json:"categories"` - ApplyCategoriesToLive bool `json:"apply_categories_to_live" validate:"boolean"` - VideoAge int64 `json:"video_age"` // retrict fetching videos to a certain age - Regex []AddLiveTitleRegex `json:"regex"` - WatchClips bool `json:"watch_clips" validate:"boolean"` - ClipsLimit int `json:"clips_limit" validate:"number,gte=1"` - ClipsIntervalDays int `json:"clips_interval_days" validate:"number,gte=1"` + WatchLive bool `json:"watch_live" validate:"boolean"` + WatchVod bool `json:"watch_vod" validate:"boolean"` + DownloadArchives bool `json:"download_archives" validate:"boolean"` + DownloadHighlights bool `json:"download_highlights" validate:"boolean"` + DownloadUploads bool `json:"download_uploads" validate:"boolean"` + Resolution string `json:"resolution" validate:"required,oneof=best source 720p60 480p 360p 160p 480p30 360p30 160p30 audio"` + ArchiveChat bool `json:"archive_chat" validate:"boolean"` + RenderChat bool `json:"render_chat" validate:"boolean"` + DownloadSubOnly bool `json:"download_sub_only" validate:"boolean"` + Categories []string `json:"categories"` + ApplyCategoriesToLive bool `json:"apply_categories_to_live" validate:"boolean"` + VideoAge int64 `json:"video_age"` // retrict fetching videos to a certain age + Regex []AddLiveTitleRegex `json:"regex"` + WatchClips bool `json:"watch_clips" validate:"boolean"` + ClipsLimit int `json:"clips_limit" validate:"number,gte=1"` + ClipsIntervalDays int `json:"clips_interval_days" validate:"number,gte=1"` + ClipsIgnoreLastChecked bool `json:"clips_ignore_last_checked" validate:"boolean"` } type ConvertChatRequest struct { @@ -74,13 +76,14 @@ type ConvertChatRequest struct { } type ArchiveLiveChannelRequest struct { - ChannelID string `json:"channel_id" validate:"required"` - Resolution string `json:"resolution" validate:"required,oneof=best source 720p60 480p 360p 160p 480p30 360p30 160p30 audio"` - ArchiveChat bool `json:"archive_chat"` - RenderChat bool `json:"render_chat"` - WatchClips bool `json:"watch_clips" validate:"boolean"` - ClipsLimit int `json:"clips_limit" validate:"number,gte=1"` - ClipsIntervalDays int `json:"clips_interval_days" validate:"number,gte=1"` + ChannelID string `json:"channel_id" validate:"required"` + Resolution string `json:"resolution" validate:"required,oneof=best source 720p60 480p 360p 160p 480p30 360p30 160p30 audio"` + ArchiveChat bool `json:"archive_chat"` + RenderChat bool `json:"render_chat"` + WatchClips bool `json:"watch_clips" validate:"boolean"` + ClipsLimit int `json:"clips_limit" validate:"number,gte=1"` + ClipsIntervalDays int `json:"clips_interval_days" validate:"number,gte=1"` + ClipsIgnoreLastChecked bool `json:"clips_ignore_last_checked" validate:"boolean"` } // GetLiveWatchedChannels godoc @@ -134,23 +137,24 @@ func (h *Handler) AddLiveWatchedChannel(c echo.Context) error { } liveDto := live.Live{ - ID: cUUID, - WatchLive: ccr.WatchLive, - WatchVod: ccr.WatchVod, - DownloadArchives: ccr.DownloadArchives, - DownloadHighlights: ccr.DownloadHighlights, - DownloadUploads: ccr.DownloadUploads, - IsLive: false, - ArchiveChat: ccr.ArchiveChat, - Resolution: ccr.Resolution, - RenderChat: ccr.RenderChat, - DownloadSubOnly: ccr.DownloadSubOnly, - Categories: ccr.Categories, - ApplyCategoriesToLive: ccr.ApplyCategoriesToLive, - VideoAge: ccr.VideoAge, - WatchClips: ccr.WatchClips, - ClipsLimit: ccr.ClipsLimit, - ClipsIntervalDays: ccr.ClipsIntervalDays, + ID: cUUID, + WatchLive: ccr.WatchLive, + WatchVod: ccr.WatchVod, + DownloadArchives: ccr.DownloadArchives, + DownloadHighlights: ccr.DownloadHighlights, + DownloadUploads: ccr.DownloadUploads, + IsLive: false, + ArchiveChat: ccr.ArchiveChat, + Resolution: ccr.Resolution, + RenderChat: ccr.RenderChat, + DownloadSubOnly: ccr.DownloadSubOnly, + Categories: ccr.Categories, + ApplyCategoriesToLive: ccr.ApplyCategoriesToLive, + VideoAge: ccr.VideoAge, + WatchClips: ccr.WatchClips, + ClipsLimit: ccr.ClipsLimit, + ClipsIntervalDays: ccr.ClipsIntervalDays, + ClipsIgnoreLastChecked: ccr.ClipsIgnoreLastChecked, } for _, regex := range ccr.Regex { @@ -205,22 +209,23 @@ func (h *Handler) UpdateLiveWatchedChannel(c echo.Context) error { } liveDto := live.Live{ - ID: lID, - WatchLive: ccr.WatchLive, - WatchVod: ccr.WatchVod, - DownloadArchives: ccr.DownloadArchives, - DownloadHighlights: ccr.DownloadHighlights, - DownloadUploads: ccr.DownloadUploads, - ArchiveChat: ccr.ArchiveChat, - Resolution: ccr.Resolution, - RenderChat: ccr.RenderChat, - DownloadSubOnly: ccr.DownloadSubOnly, - Categories: ccr.Categories, - ApplyCategoriesToLive: ccr.ApplyCategoriesToLive, - VideoAge: ccr.VideoAge, - WatchClips: ccr.WatchClips, - ClipsLimit: ccr.ClipsLimit, - ClipsIntervalDays: ccr.ClipsIntervalDays, + ID: lID, + WatchLive: ccr.WatchLive, + WatchVod: ccr.WatchVod, + DownloadArchives: ccr.DownloadArchives, + DownloadHighlights: ccr.DownloadHighlights, + DownloadUploads: ccr.DownloadUploads, + ArchiveChat: ccr.ArchiveChat, + Resolution: ccr.Resolution, + RenderChat: ccr.RenderChat, + DownloadSubOnly: ccr.DownloadSubOnly, + Categories: ccr.Categories, + ApplyCategoriesToLive: ccr.ApplyCategoriesToLive, + VideoAge: ccr.VideoAge, + WatchClips: ccr.WatchClips, + ClipsLimit: ccr.ClipsLimit, + ClipsIntervalDays: ccr.ClipsIntervalDays, + ClipsIgnoreLastChecked: ccr.ClipsIgnoreLastChecked, } for _, regex := range ccr.Regex { diff --git a/internal/transport/http/playback.go b/internal/transport/http/playback.go index 0c60f203..5064ab65 100644 --- a/internal/transport/http/playback.go +++ b/internal/transport/http/playback.go @@ -207,7 +207,6 @@ func (h *Handler) GetLastPlaybacks(c echo.Context) error { func (h *Handler) StartPlayback(c echo.Context) error { videoId, err := uuid.Parse(c.QueryParam("video_id")) if err != nil { - fmt.Println(err) return echo.NewHTTPError(http.StatusBadRequest, "invalid video id") } diff --git a/internal/utils/file.go b/internal/utils/file.go index 19626bfa..e8b6f8fe 100644 --- a/internal/utils/file.go +++ b/internal/utils/file.go @@ -293,7 +293,7 @@ func ReadLastLines(path string, lines int) ([]byte, error) { c := exec.Command("bash", "-c", cmd) out, err := c.Output() if err != nil { - fmt.Println(err) + log.Error().Err(err).Msgf("error reading last lines: %v - supplied path: %s", err, path) return nil, fmt.Errorf("error reading last lines: %v - supplied path: %s", err, path) } return out, nil