Remove slim graphql endpoints (#1207)

This commit is contained in:
InfiniteTF 2021-03-17 01:17:01 +01:00 committed by GitHub
parent 7e6127975d
commit 58243cded0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 22 additions and 185 deletions

View File

@ -13,24 +13,24 @@ query AllTags {
}
query AllPerformersForFilter {
allPerformersSlim {
allPerformers {
...SlimPerformerData
}
}
query AllStudiosForFilter {
allStudiosSlim {
allStudios {
...SlimStudioData
}
}
query AllMoviesForFilter {
allMoviesSlim {
allMovies {
...SlimMovieData
}
}
query AllTagsForFilter {
allTagsSlim {
allTags {
id
name
}

View File

@ -115,11 +115,6 @@ type Query {
# Get everything with minimal metadata
allPerformersSlim: [Performer!]!
allStudiosSlim: [Studio!]!
allMoviesSlim: [Movie!]!
allTagsSlim: [Tag!]!
# Version
version: Version!

View File

@ -53,14 +53,3 @@ func (r *queryResolver) AllMovies(ctx context.Context) (ret []*models.Movie, err
return ret, nil
}
func (r *queryResolver) AllMoviesSlim(ctx context.Context) (ret []*models.Movie, err error) {
if err := r.withReadTxn(ctx, func(repo models.ReaderRepository) error {
ret, err = repo.Movie().AllSlim()
return err
}); err != nil {
return nil, err
}
return ret, nil
}

View File

@ -52,14 +52,3 @@ func (r *queryResolver) AllPerformers(ctx context.Context) (ret []*models.Perfor
return ret, nil
}
func (r *queryResolver) AllPerformersSlim(ctx context.Context) (ret []*models.Performer, err error) {
if err := r.withReadTxn(ctx, func(repo models.ReaderRepository) error {
ret, err = repo.Performer().AllSlim()
return err
}); err != nil {
return nil, err
}
return ret, nil
}

View File

@ -54,14 +54,3 @@ func (r *queryResolver) AllStudios(ctx context.Context) (ret []*models.Studio, e
return ret, nil
}
func (r *queryResolver) AllStudiosSlim(ctx context.Context) (ret []*models.Studio, err error) {
if err := r.withReadTxn(ctx, func(repo models.ReaderRepository) error {
ret, err = repo.Studio().AllSlim()
return err
}); err != nil {
return nil, err
}
return ret, nil
}

View File

@ -53,14 +53,3 @@ func (r *queryResolver) AllTags(ctx context.Context) (ret []*models.Tag, err err
return ret, nil
}
func (r *queryResolver) AllTagsSlim(ctx context.Context) (ret []*models.Tag, err error) {
if err := r.withReadTxn(ctx, func(repo models.ReaderRepository) error {
ret, err = repo.Tag().AllSlim()
return err
}); err != nil {
return nil, err
}
return ret, nil
}

View File

@ -35,29 +35,6 @@ func (_m *MovieReaderWriter) All() ([]*models.Movie, error) {
return r0, r1
}
// AllSlim provides a mock function with given fields:
func (_m *MovieReaderWriter) AllSlim() ([]*models.Movie, error) {
ret := _m.Called()
var r0 []*models.Movie
if rf, ok := ret.Get(0).(func() []*models.Movie); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*models.Movie)
}
}
var r1 error
if rf, ok := ret.Get(1).(func() error); ok {
r1 = rf()
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Count provides a mock function with given fields:
func (_m *MovieReaderWriter) Count() (int, error) {
ret := _m.Called()

View File

@ -35,29 +35,6 @@ func (_m *PerformerReaderWriter) All() ([]*models.Performer, error) {
return r0, r1
}
// AllSlim provides a mock function with given fields:
func (_m *PerformerReaderWriter) AllSlim() ([]*models.Performer, error) {
ret := _m.Called()
var r0 []*models.Performer
if rf, ok := ret.Get(0).(func() []*models.Performer); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*models.Performer)
}
}
var r1 error
if rf, ok := ret.Get(1).(func() error); ok {
r1 = rf()
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Count provides a mock function with given fields:
func (_m *PerformerReaderWriter) Count() (int, error) {
ret := _m.Called()

View File

@ -35,29 +35,6 @@ func (_m *StudioReaderWriter) All() ([]*models.Studio, error) {
return r0, r1
}
// AllSlim provides a mock function with given fields:
func (_m *StudioReaderWriter) AllSlim() ([]*models.Studio, error) {
ret := _m.Called()
var r0 []*models.Studio
if rf, ok := ret.Get(0).(func() []*models.Studio); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*models.Studio)
}
}
var r1 error
if rf, ok := ret.Get(1).(func() error); ok {
r1 = rf()
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Count provides a mock function with given fields:
func (_m *StudioReaderWriter) Count() (int, error) {
ret := _m.Called()

View File

@ -35,29 +35,6 @@ func (_m *TagReaderWriter) All() ([]*models.Tag, error) {
return r0, r1
}
// AllSlim provides a mock function with given fields:
func (_m *TagReaderWriter) AllSlim() ([]*models.Tag, error) {
ret := _m.Called()
var r0 []*models.Tag
if rf, ok := ret.Get(0).(func() []*models.Tag); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*models.Tag)
}
}
var r1 error
if rf, ok := ret.Get(1).(func() error); ok {
r1 = rf()
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Count provides a mock function with given fields:
func (_m *TagReaderWriter) Count() (int, error) {
ret := _m.Called()

View File

@ -8,7 +8,6 @@ type MovieReader interface {
FindByNames(names []string, nocase bool) ([]*Movie, error)
All() ([]*Movie, error)
Count() (int, error)
AllSlim() ([]*Movie, error)
Query(movieFilter *MovieFilterType, findFilter *FindFilterType) ([]*Movie, int, error)
GetFrontImage(movieID int) ([]byte, error)
GetBackImage(movieID int) ([]byte, error)

View File

@ -11,7 +11,6 @@ type PerformerReader interface {
CountByTagID(tagID int) (int, error)
Count() (int, error)
All() ([]*Performer, error)
AllSlim() ([]*Performer, error)
Query(performerFilter *PerformerFilterType, findFilter *FindFilterType) ([]*Performer, int, error)
GetImage(performerID int) ([]byte, error)
GetStashIDs(performerID int) ([]*StashID, error)

View File

@ -7,7 +7,6 @@ type StudioReader interface {
FindByName(name string, nocase bool) (*Studio, error)
Count() (int, error)
All() ([]*Studio, error)
AllSlim() ([]*Studio, error)
Query(studioFilter *StudioFilterType, findFilter *FindFilterType) ([]*Studio, int, error)
GetImage(studioID int) ([]byte, error)
HasImage(studioID int) (bool, error)

View File

@ -12,7 +12,6 @@ type TagReader interface {
FindByNames(names []string, nocase bool) ([]*Tag, error)
Count() (int, error)
All() ([]*Tag, error)
AllSlim() ([]*Tag, error)
Query(tagFilter *TagFilterType, findFilter *FindFilterType) ([]*Tag, int, error)
GetImage(tagID int) ([]byte, error)
}

View File

@ -114,10 +114,6 @@ func (qb *movieQueryBuilder) All() ([]*models.Movie, error) {
return qb.queryMovies(selectAll("movies")+qb.getMovieSort(nil), nil)
}
func (qb *movieQueryBuilder) AllSlim() ([]*models.Movie, error) {
return qb.queryMovies("SELECT movies.id, movies.name FROM movies "+qb.getMovieSort(nil), nil)
}
func (qb *movieQueryBuilder) Query(movieFilter *models.MovieFilterType, findFilter *models.FindFilterType) ([]*models.Movie, int, error) {
if findFilter == nil {
findFilter = &models.FindFilterType{}

View File

@ -173,10 +173,6 @@ func (qb *performerQueryBuilder) All() ([]*models.Performer, error) {
return qb.queryPerformers(selectAll("performers")+qb.getPerformerSort(nil), nil)
}
func (qb *performerQueryBuilder) AllSlim() ([]*models.Performer, error) {
return qb.queryPerformers("SELECT performers.id, performers.name, performers.gender FROM performers "+qb.getPerformerSort(nil), nil)
}
func (qb *performerQueryBuilder) Query(performerFilter *models.PerformerFilterType, findFilter *models.FindFilterType) ([]*models.Performer, int, error) {
if performerFilter == nil {
performerFilter = &models.PerformerFilterType{}

View File

@ -121,10 +121,6 @@ func (qb *studioQueryBuilder) All() ([]*models.Studio, error) {
return qb.queryStudios(selectAll("studios")+qb.getStudioSort(nil), nil)
}
func (qb *studioQueryBuilder) AllSlim() ([]*models.Studio, error) {
return qb.queryStudios("SELECT studios.id, studios.name, studios.parent_id FROM studios "+qb.getStudioSort(nil), nil)
}
func (qb *studioQueryBuilder) Query(studioFilter *models.StudioFilterType, findFilter *models.FindFilterType) ([]*models.Studio, int, error) {
if studioFilter == nil {
studioFilter = &models.StudioFilterType{}

View File

@ -192,10 +192,6 @@ func (qb *tagQueryBuilder) All() ([]*models.Tag, error) {
return qb.queryTags(selectAll("tags")+qb.getDefaultTagSort(), nil)
}
func (qb *tagQueryBuilder) AllSlim() ([]*models.Tag, error) {
return qb.queryTags("SELECT tags.id, tags.name FROM tags "+qb.getDefaultTagSort(), nil)
}
func (qb *tagQueryBuilder) validateFilter(tagFilter *models.TagFilterType) error {
const and = "AND"
const or = "OR"

View File

@ -3,8 +3,6 @@ import * as GQL from "src/core/generated-graphql";
import { useAllMoviesForFilter } from "src/core/StashService";
import { Form, Row, Col } from "react-bootstrap";
type ValidTypes = GQL.SlimMovieDataFragment;
export type MovieSceneIndexMap = Map<string, number | undefined>;
export interface IProps {
@ -17,8 +15,8 @@ export const SceneMovieTable: React.FunctionComponent<IProps> = (
) => {
const { data } = useAllMoviesForFilter();
const items = !!data && !!data.allMoviesSlim ? data.allMoviesSlim : [];
let itemsFilter: ValidTypes[] = [];
const items = !!data && !!data.allMovies ? data.allMovies : [];
let itemsFilter: GQL.SlimMovieDataFragment[] = [];
if (!!props.movieSceneIndexes && !!items) {
props.movieSceneIndexes.forEach((_index, movieId) => {

View File

@ -377,7 +377,7 @@ export const PerformerSelect: React.FC<IFilterProps> = (props) => {
const { data, loading } = useAllPerformersForFilter();
const [createPerformer] = usePerformerCreate();
const performers = data?.allPerformersSlim ?? [];
const performers = data?.allPerformers ?? [];
const onCreate = async (name: string) => {
const result = await createPerformer({
@ -410,7 +410,7 @@ export const StudioSelect: React.FC<
const [createStudio] = useStudioCreate({ name: "" });
const exclude = props.excludeIds ?? [];
const studios = (data?.allStudiosSlim ?? []).filter(
const studios = (data?.allStudios ?? []).filter(
(studio) => !exclude.includes(studio.id)
);
@ -435,7 +435,7 @@ export const StudioSelect: React.FC<
export const MovieSelect: React.FC<IFilterProps> = (props) => {
const { data, loading } = useAllMoviesForFilter();
const items = data?.allMoviesSlim ?? [];
const items = data?.allMovies ?? [];
return (
<FilterSelectComponent
@ -454,7 +454,7 @@ export const TagSelect: React.FC<IFilterProps> = (props) => {
const [createTag] = useTagCreate({ name: "" });
const placeholder = props.noSelectionString ?? "Select tags...";
const tags = data?.allTagsSlim ?? [];
const tags = data?.allTags ?? [];
const onCreate = async (name: string) => {
const result = await createTag({

View File

@ -263,7 +263,7 @@ const StashSearchResult: React.FC<IStashSearchResultProps> = ({
const newTagIDs = tagOperation === "merge" ? updatedTags : [];
const tags = scene.tags ?? [];
if (tags.length > 0) {
const tagDict: Record<string, string> = (allTags?.allTagsSlim ?? [])
const tagDict: Record<string, string> = (allTags?.allTags ?? [])
.filter((t) => t.name)
.reduce(
(dict, t) => ({ ...dict, [t.name.toLowerCase()]: t.id }),

View File

@ -65,21 +65,21 @@ export const useCreatePerformer = () => {
>({
query: GQL.AllPerformersForFilterDocument,
});
const allPerformersSlim = sortBy(
const allPerformers = sortBy(
[
...(currentQuery?.allPerformersSlim ?? []),
...(currentQuery?.allPerformers ?? []),
newPerformer.data.performerCreate,
],
["name"]
);
if (allPerformersSlim.length > 1) {
if (allPerformers.length > 1) {
store.writeQuery<
GQL.AllPerformersForFilterQuery,
GQL.AllPerformersForFilterQueryVariables
>({
query: GQL.AllPerformersForFilterDocument,
data: {
allPerformersSlim,
allPerformers,
},
});
}
@ -169,18 +169,18 @@ export const useCreateStudio = () => {
>({
query: GQL.AllStudiosForFilterDocument,
});
const allStudiosSlim = sortBy(
[...(currentQuery?.allStudiosSlim ?? []), result.data.studioCreate],
const allStudios = sortBy(
[...(currentQuery?.allStudios ?? []), result.data.studioCreate],
["name"]
);
if (allStudiosSlim.length > 1) {
if (allStudios.length > 1) {
store.writeQuery<
GQL.AllStudiosForFilterQuery,
GQL.AllStudiosForFilterQueryVariables
>({
query: GQL.AllStudiosForFilterDocument,
data: {
allStudiosSlim,
allStudios,
},
});
}
@ -225,8 +225,8 @@ export const useCreateTag = () => {
>({
query: GQL.AllTagsForFilterDocument,
});
const allTagsSlim = sortBy(
[...(currentQuery?.allTagsSlim ?? []), result.data.tagCreate],
const allTags = sortBy(
[...(currentQuery?.allTags ?? []), result.data.tagCreate],
["name"]
);
@ -236,7 +236,7 @@ export const useCreateTag = () => {
>({
query: GQL.AllTagsForFilterDocument,
data: {
allTagsSlim,
allTags,
},
});
},