Movie group renames (#5039)

* Rename Movie and MoviePartial to Group/GroupPartial
* Rename Movie interfaces
* Update movie url builders to use group
* Rename movieRoutes to groupRoutes
* Update dataloader
* Update names in sqlite package
* Rename in resolvers
* Add GroupByURL to scraper config
* Scraper backward compatibility hacks
This commit is contained in:
WithoutPants
2024-07-04 09:10:26 +10:00
committed by GitHub
parent b69d9cc840
commit 15a7b8a859
83 changed files with 1765 additions and 1646 deletions

View File

@@ -5,54 +5,54 @@ import (
"strconv"
)
type MoviesScenes struct {
MovieID int `json:"movie_id"`
type GroupsScenes struct {
GroupID int `json:"movie_id"`
// SceneID int `json:"scene_id"`
SceneIndex *int `json:"scene_index"`
}
func (s MoviesScenes) SceneMovieInput() SceneMovieInput {
func (s GroupsScenes) SceneMovieInput() SceneMovieInput {
return SceneMovieInput{
MovieID: strconv.Itoa(s.MovieID),
MovieID: strconv.Itoa(s.GroupID),
SceneIndex: s.SceneIndex,
}
}
func (s MoviesScenes) Equal(o MoviesScenes) bool {
return o.MovieID == s.MovieID && ((o.SceneIndex == nil && s.SceneIndex == nil) ||
func (s GroupsScenes) Equal(o GroupsScenes) bool {
return o.GroupID == s.GroupID && ((o.SceneIndex == nil && s.SceneIndex == nil) ||
(o.SceneIndex != nil && s.SceneIndex != nil && *o.SceneIndex == *s.SceneIndex))
}
type UpdateMovieIDs struct {
Movies []MoviesScenes `json:"movies"`
type UpdateGroupIDs struct {
Groups []GroupsScenes `json:"movies"`
Mode RelationshipUpdateMode `json:"mode"`
}
func (u *UpdateMovieIDs) SceneMovieInputs() []SceneMovieInput {
func (u *UpdateGroupIDs) SceneMovieInputs() []SceneMovieInput {
if u == nil {
return nil
}
ret := make([]SceneMovieInput, len(u.Movies))
for _, id := range u.Movies {
ret := make([]SceneMovieInput, len(u.Groups))
for _, id := range u.Groups {
ret = append(ret, id.SceneMovieInput())
}
return ret
}
func (u *UpdateMovieIDs) AddUnique(v MoviesScenes) {
for _, vv := range u.Movies {
if vv.MovieID == v.MovieID {
func (u *UpdateGroupIDs) AddUnique(v GroupsScenes) {
for _, vv := range u.Groups {
if vv.GroupID == v.GroupID {
return
}
}
u.Movies = append(u.Movies, v)
u.Groups = append(u.Groups, v)
}
func MoviesScenesFromInput(input []SceneMovieInput) ([]MoviesScenes, error) {
ret := make([]MoviesScenes, len(input))
func GroupsScenesFromInput(input []SceneMovieInput) ([]GroupsScenes, error) {
ret := make([]GroupsScenes, len(input))
for i, v := range input {
mID, err := strconv.Atoi(v.MovieID)
@@ -60,8 +60,8 @@ func MoviesScenesFromInput(input []SceneMovieInput) ([]MoviesScenes, error) {
return nil, fmt.Errorf("invalid movie ID: %s", v.MovieID)
}
ret[i] = MoviesScenes{
MovieID: mID,
ret[i] = GroupsScenes{
GroupID: mID,
SceneIndex: v.SceneIndex,
}
}