Skip to content

Commit

Permalink
Fix video3D
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdigital committed Oct 15, 2024
1 parent 5b7ab2b commit cc87536
Show file tree
Hide file tree
Showing 25 changed files with 136 additions and 136 deletions.
2 changes: 1 addition & 1 deletion graphql/schema/enums.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ enum Language {
zu
}

enum Video3d {
enum Video3D {
V3D
V3DSBS
V3DOU
Expand Down
2 changes: 1 addition & 1 deletion graphql/schema/models.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type TorrentContent {
videoResolution: VideoResolution
videoSource: VideoSource
videoCodec: VideoCodec
video3d: Video3d
video3d: Video3D
videoModifier: VideoModifier
releaseGroup: String
seeders: Int
Expand Down
12 changes: 6 additions & 6 deletions internal/classifier/classification/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type ContentAttributes struct {
VideoResolution model.NullVideoResolution
VideoSource model.NullVideoSource
VideoCodec model.NullVideoCodec
Video3d model.NullVideo3d
Video3D model.NullVideo3D
VideoModifier model.NullVideoModifier
ReleaseGroup model.NullString
}
Expand Down Expand Up @@ -67,8 +67,8 @@ func (a *ContentAttributes) Merge(other ContentAttributes) {
if !a.VideoCodec.Valid {
a.VideoCodec = other.VideoCodec
}
if !a.Video3d.Valid {
a.Video3d = other.Video3d
if !a.Video3D.Valid {
a.Video3D = other.Video3D
}
if !a.VideoModifier.Valid {
a.VideoModifier = other.VideoModifier
Expand All @@ -94,8 +94,8 @@ func (a *ContentAttributes) ApplyHint(h model.TorrentHint) {
if h.VideoCodec.Valid {
a.VideoCodec = h.VideoCodec
}
if h.Video3d.Valid {
a.Video3d = h.Video3d
if h.Video3D.Valid {
a.Video3D = h.Video3D
}
if h.VideoModifier.Valid {
a.VideoModifier = h.VideoModifier
Expand All @@ -109,6 +109,6 @@ func (a *ContentAttributes) InferVideoAttributes(input string) {
a.VideoResolution = model.InferVideoResolution(input)
a.VideoSource = model.InferVideoSource(input)
a.VideoCodec, a.ReleaseGroup = model.InferVideoCodecAndReleaseGroup(input)
a.Video3d = model.InferVideo3d(input)
a.Video3D = model.InferVideo3D(input)
a.VideoModifier = model.InferVideoModifier(input)
}
2 changes: 1 addition & 1 deletion internal/classifier/mocks/LocalSearch.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions internal/database/dao/torrent_contents.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions internal/database/dao/torrent_hints.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/database/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func BuildGenerator(db *gorm.DB) *gen.Generator {
gen.FieldType("video_resolution", "NullVideoResolution"),
gen.FieldType("video_source", "NullVideoSource"),
gen.FieldType("video_codec", "NullVideoCodec"),
gen.FieldType("video_3d", "NullVideo3d"),
gen.FieldType("video_3d", "NullVideo3D"),
gen.FieldType("video_modifier", "NullVideoModifier"),
gen.FieldType("tsv", "fts.Tsvector"),
createdAtReadOnly,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

var VideoResolutionCriteria = torrentContentAttributeCriteria[model.VideoResolution](videoResolutionField)

var Video3dCriteria = torrentContentAttributeCriteria[model.Video3d](video3dField)
var Video3DCriteria = torrentContentAttributeCriteria[model.Video3D](video3dField)

func torrentContentAttributeCriteria[T attribute](getFld func(*dao.Query) field.Field) func(...T) query.Criteria {
return func(values ...T) query.Criteria {
Expand Down
16 changes: 8 additions & 8 deletions internal/database/search/facet_torrent_content_video_3d.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ import (
"gorm.io/gen/field"
)

const Video3dFacetKey = "video_3d"
const Video3DFacetKey = "video_3d"

func video3dField(q *dao.Query) field.Field {
return q.TorrentContent.Video3d
return q.TorrentContent.Video3D
}

func Video3dFacet(options ...query.FacetOption) query.Facet {
return video3dFacet{torrentContentAttributeFacet[model.Video3d]{
func Video3DFacet(options ...query.FacetOption) query.Facet {
return video3dFacet{torrentContentAttributeFacet[model.Video3D]{
FacetConfig: query.NewFacetConfig(
append([]query.FacetOption{
query.FacetHasKey(Video3dFacetKey),
query.FacetHasKey(Video3DFacetKey),
query.FacetHasLabel("Video 3D"),
query.FacetUsesOrLogic(),
query.FacetTriggersCte(),
}, options...)...,
),
field: video3dField,
parse: model.ParseVideo3d,
parse: model.ParseVideo3D,
}}
}

type video3dFacet struct {
torrentContentAttributeFacet[model.Video3d]
torrentContentAttributeFacet[model.Video3D]
}

func (f video3dFacet) Values(query.FacetContext) (map[string]string, error) {
v3ds := model.Video3dValues()
v3ds := model.Video3DValues()
values := make(map[string]string, len(v3ds))
for _, vr := range v3ds {
values[vr.String()] = vr.Label()
Expand Down
2 changes: 1 addition & 1 deletion internal/gql/enums/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var Enums = []enum{
newEnum("FileType", model.FileTypeNames()),
newEnum("FilesStatus", model.FilesStatusNames()),
newEnum("Language", model.LanguageValueStrings()),
newEnum("Video3d", model.Video3dNames()),
newEnum("Video3D", model.Video3DNames()),
newEnum("VideoCodec", model.VideoCodecNames()),
newEnum("VideoModifier", model.VideoModifierNames()),
newEnum("VideoResolution", model.VideoResolutionNames()),
Expand Down
24 changes: 12 additions & 12 deletions internal/gql/gql.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/gql/gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ models:
model:
- github.com/bitmagnet-io/bitmagnet/internal/model.VideoCodec
- github.com/bitmagnet-io/bitmagnet/internal/model.NullVideoCodec
Video3d:
Video3D:
model:
- github.com/bitmagnet-io/bitmagnet/internal/model.Video3d
- github.com/bitmagnet-io/bitmagnet/internal/model.NullVideo3d
- github.com/bitmagnet-io/bitmagnet/internal/model.Video3D
- github.com/bitmagnet-io/bitmagnet/internal/model.NullVideo3D
VideoModifier:
model:
- github.com/bitmagnet-io/bitmagnet/internal/model.VideoModifier
Expand Down
4 changes: 2 additions & 2 deletions internal/gql/gqlmodel/torrent_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type TorrentContent struct {
VideoResolution model.NullVideoResolution
VideoSource model.NullVideoSource
VideoCodec model.NullVideoCodec
Video3d model.NullVideo3d
Video3D model.NullVideo3D
VideoModifier model.NullVideoModifier
ReleaseGroup model.NullString
SearchString string
Expand Down Expand Up @@ -57,7 +57,7 @@ func NewTorrentContentFromResultItem(item search.TorrentContentResultItem) Torre
VideoResolution: item.VideoResolution,
VideoSource: item.VideoSource,
VideoCodec: item.VideoCodec,
Video3d: item.Video3d,
Video3D: item.Video3D,
VideoModifier: item.VideoModifier,
ReleaseGroup: item.ReleaseGroup,
Seeders: item.Seeders,
Expand Down
4 changes: 2 additions & 2 deletions internal/importer/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Item struct {
VideoResolution model.NullVideoResolution
VideoSource model.NullVideoSource
VideoCodec model.NullVideoCodec
Video3d model.NullVideo3d
Video3D model.NullVideo3D
VideoModifier model.NullVideoModifier
ReleaseGroup model.NullString
PublishedAt time.Time
Expand Down Expand Up @@ -275,7 +275,7 @@ func createTorrentModel(info Info, item Item) model.Torrent {
VideoResolution: item.VideoResolution,
VideoSource: item.VideoSource,
VideoCodec: item.VideoCodec,
Video3d: item.Video3d,
Video3D: item.Video3D,
VideoModifier: item.VideoModifier,
ReleaseGroup: item.ReleaseGroup,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/model/torrent_contents.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/model/torrent_contents.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (tc *TorrentContent) UpdateTsv() {
if tc.VideoCodec.Valid {
tsv.AddText(tc.VideoCodec.VideoCodec.String(), fts.TsvectorWeightC)
}
if tc.Video3d.Valid {
if tc.Video3D.Valid {
tsv.AddText("3D", fts.TsvectorWeightC)
}
if tc.VideoModifier.Valid {
Expand Down
2 changes: 1 addition & 1 deletion internal/model/torrent_hints.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions internal/model/video_3d.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import (
"github.com/bitmagnet-io/bitmagnet/internal/keywords"
)

// Video3d represents the 3D type of a video
// Video3D represents the 3D type of a video
// ENUM(V3D, V3DSBS, V3DOU)
type Video3d string
type Video3D string

func (v Video3d) Label() string {
func (v Video3D) Label() string {
return v.String()[1:]
}

var video3dRegex = keywords.MustNewRegexFromKeywords(namesToLower(removeEnumPrefixes(Video3dNames()...)...)...)
var video3dRegex = keywords.MustNewRegexFromKeywords(namesToLower(removeEnumPrefixes(Video3DNames()...)...)...)

func InferVideo3d(input string) NullVideo3d {
func InferVideo3D(input string) NullVideo3D {
if match := video3dRegex.FindStringSubmatch(input); match != nil {
if parsed, parseErr := ParseVideo3d("V" + match[1]); parseErr == nil {
return NewNullVideo3d(parsed)
if parsed, parseErr := ParseVideo3D("V" + match[1]); parseErr == nil {
return NewNullVideo3D(parsed)
}
}
return NullVideo3d{}
return NullVideo3D{}
}
Loading

0 comments on commit cc87536

Please sign in to comment.