Compare commits

...

5 Commits

Author SHA1 Message Date
WithoutPants
e9fa7d071e Add changelog entries 2023-02-21 12:06:17 +11:00
DingDongSoLong4
dd5cff2aec Minor gallery-related fixes (#3448)
* Fix gallery titles
* Fix SceneListTable
2023-02-21 12:00:33 +11:00
DingDongSoLong4
c7c4d5b126 Optimize allData queries (#3452)
* Add specific fields to allData queries
* Add additional allData endpoints
2023-02-21 11:53:08 +11:00
DingDongSoLong4
ccbe3c4e92 Fix batch performer panic (#3456) 2023-02-21 11:45:58 +11:00
DingDongSoLong4
96ce260a40 Fix allTags cache reset (#3444) 2023-02-21 11:45:13 +11:00
25 changed files with 203 additions and 115 deletions

View File

@@ -46,6 +46,9 @@ fragment SlimSceneData on Scene {
files {
path
}
folder {
path
}
title
}

View File

@@ -6,26 +6,27 @@ query MarkerStrings($q: String, $sort: String) {
}
}
query AllTags {
allTags {
...TagData
}
}
query AllPerformersForFilter {
allPerformers {
...SlimPerformerData
id
name
disambiguation
alias_list
}
}
query AllStudiosForFilter {
allStudios {
...SlimStudioData
id
name
aliases
}
}
query AllMoviesForFilter {
allMovies {
...SlimMovieData
id
name
}
}

View File

@@ -144,6 +144,10 @@ type Query {
# Get everything
allScenes: [Scene!]!
allSceneMarkers: [SceneMarker!]!
allImages: [Image!]!
allGalleries: [Gallery!]!
allPerformers: [Performer!]!
allStudios: [Studio!]!
allMovies: [Movie!]!

View File

@@ -41,3 +41,14 @@ func (r *queryResolver) FindGalleries(ctx context.Context, galleryFilter *models
return ret, nil
}
func (r *queryResolver) AllGalleries(ctx context.Context) (ret []*models.Gallery, err error) {
if err := r.withReadTxn(ctx, func(ctx context.Context) error {
ret, err = r.repository.Gallery.All(ctx)
return err
}); err != nil {
return nil, err
}
return ret, nil
}

View File

@@ -84,3 +84,14 @@ func (r *queryResolver) FindImages(ctx context.Context, imageFilter *models.Imag
return ret, nil
}
func (r *queryResolver) AllImages(ctx context.Context) (ret []*models.Image, err error) {
if err := r.withReadTxn(ctx, func(ctx context.Context) error {
ret, err = r.repository.Image.All(ctx)
return err
}); err != nil {
return nil, err
}
return ret, nil
}

View File

@@ -232,3 +232,14 @@ func (r *queryResolver) FindDuplicateScenes(ctx context.Context, distance *int)
return ret, nil
}
func (r *queryResolver) AllScenes(ctx context.Context) (ret []*models.Scene, err error) {
if err := r.withReadTxn(ctx, func(ctx context.Context) error {
ret, err = r.repository.Scene.All(ctx)
return err
}); err != nil {
return nil, err
}
return ret, nil
}

View File

@@ -24,3 +24,14 @@ func (r *queryResolver) FindSceneMarkers(ctx context.Context, sceneMarkerFilter
return ret, nil
}
func (r *queryResolver) AllSceneMarkers(ctx context.Context) (ret []*models.SceneMarker, err error) {
if err := r.withReadTxn(ctx, func(ctx context.Context) error {
ret, err = r.repository.SceneMarker.All(ctx)
return err
}); err != nil {
return nil, err
}
return ret, nil
}

View File

@@ -191,8 +191,14 @@ func (t *StashBoxPerformerTagTask) stashBoxPerformerTag(ctx context.Context) {
}
} else if t.name != nil && performer.Name != nil {
currentTime := time.Now()
var aliases []string
if performer.Aliases != nil {
aliases = stringslice.FromString(*performer.Aliases, ",")
} else {
aliases = []string{}
}
newPerformer := models.Performer{
Aliases: models.NewRelatedStrings(stringslice.FromString(*performer.Aliases, ",")),
Aliases: models.NewRelatedStrings(aliases),
Birthdate: getDate(performer.Birthdate),
CareerLength: getString(performer.CareerLength),
Country: getString(performer.Country),

View File

@@ -14,6 +14,50 @@ type SceneMarkerReaderWriter struct {
mock.Mock
}
// All provides a mock function with given fields: ctx
func (_m *SceneMarkerReaderWriter) All(ctx context.Context) ([]*models.SceneMarker, error) {
ret := _m.Called(ctx)
var r0 []*models.SceneMarker
if rf, ok := ret.Get(0).(func(context.Context) []*models.SceneMarker); ok {
r0 = rf(ctx)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*models.SceneMarker)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
r1 = rf(ctx)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Count provides a mock function with given fields: ctx
func (_m *SceneMarkerReaderWriter) Count(ctx context.Context) (int, error) {
ret := _m.Called(ctx)
var r0 int
if rf, ok := ret.Get(0).(func(context.Context) int); ok {
r0 = rf(ctx)
} else {
r0 = ret.Get(0).(int)
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
r1 = rf(ctx)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// CountByTagID provides a mock function with given fields: ctx, tagID
func (_m *SceneMarkerReaderWriter) CountByTagID(ctx context.Context, tagID int) (int, error) {
ret := _m.Called(ctx, tagID)

View File

@@ -638,29 +638,8 @@ func (_m *SceneReaderWriter) GetTagIDs(ctx context.Context, relatedID int) ([]in
return r0, r1
}
// SaveActivity provides a mock function with given fields: ctx, id, resumeTime, playDuration
func (_m *SceneReaderWriter) SaveActivity(ctx context.Context, id int, resumeTime *float64, playDuration *float64) (bool, error) {
ret := _m.Called(ctx, id, resumeTime, playDuration)
var r0 bool
if rf, ok := ret.Get(0).(func(context.Context, int, *float64, *float64) bool); ok {
r0 = rf(ctx, id, resumeTime, playDuration)
} else {
r0 = ret.Get(0).(bool)
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, int, *float64, *float64) error); ok {
r1 = rf(ctx, id, resumeTime, playDuration)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// IncrementWatchCount provides a mock function with given fields: ctx, id
func (_m *SceneReaderWriter) IncrementWatchCount(ctx context.Context, id int) (int, error) {
// IncrementOCounter provides a mock function with given fields: ctx, id
func (_m *SceneReaderWriter) IncrementOCounter(ctx context.Context, id int) (int, error) {
ret := _m.Called(ctx, id)
var r0 int
@@ -680,8 +659,8 @@ func (_m *SceneReaderWriter) IncrementWatchCount(ctx context.Context, id int) (i
return r0, r1
}
// IncrementOCounter provides a mock function with given fields: ctx, id
func (_m *SceneReaderWriter) IncrementOCounter(ctx context.Context, id int) (int, error) {
// IncrementWatchCount provides a mock function with given fields: ctx, id
func (_m *SceneReaderWriter) IncrementWatchCount(ctx context.Context, id int) (int, error) {
ret := _m.Called(ctx, id)
var r0 int
@@ -745,6 +724,27 @@ func (_m *SceneReaderWriter) ResetOCounter(ctx context.Context, id int) (int, er
return r0, r1
}
// SaveActivity provides a mock function with given fields: ctx, id, resumeTime, playDuration
func (_m *SceneReaderWriter) SaveActivity(ctx context.Context, id int, resumeTime *float64, playDuration *float64) (bool, error) {
ret := _m.Called(ctx, id, resumeTime, playDuration)
var r0 bool
if rf, ok := ret.Get(0).(func(context.Context, int, *float64, *float64) bool); ok {
r0 = rf(ctx, id, resumeTime, playDuration)
} else {
r0 = ret.Get(0).(bool)
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, int, *float64, *float64) error); ok {
r1 = rf(ctx, id, resumeTime, playDuration)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Size provides a mock function with given fields: ctx
func (_m *SceneReaderWriter) Size(ctx context.Context) (float64, error) {
ret := _m.Called(ctx)

View File

@@ -36,6 +36,8 @@ type SceneMarkerReader interface {
CountByTagID(ctx context.Context, tagID int) (int, error)
GetMarkerStrings(ctx context.Context, q *string, sort *string) ([]*MarkerStringsResultType, error)
Wall(ctx context.Context, q *string) ([]*SceneMarker, error)
Count(ctx context.Context) (int, error)
All(ctx context.Context) ([]*SceneMarker, error)
Query(ctx context.Context, sceneMarkerFilter *SceneMarkerFilterType, findFilter *FindFilterType) ([]*SceneMarker, int, error)
GetTagIDs(ctx context.Context, imageID int) ([]int, error)
}

View File

@@ -346,3 +346,11 @@ func (qb *sceneMarkerQueryBuilder) UpdateTags(ctx context.Context, id int, tagID
// Delete the existing joins and then create new ones
return qb.tagsRepository().replace(ctx, id, tagIDs)
}
func (qb *sceneMarkerQueryBuilder) Count(ctx context.Context) (int, error) {
return qb.runCountQuery(ctx, qb.buildCountQuery("SELECT scene_markers.id FROM scene_markers"), nil)
}
func (qb *sceneMarkerQueryBuilder) All(ctx context.Context) ([]*models.SceneMarker, error) {
return qb.querySceneMarkers(ctx, selectAll("scene_markers")+qb.getSceneMarkerSort(nil, nil), nil)
}

View File

@@ -222,4 +222,6 @@ func queryMarkers(ctx context.Context, t *testing.T, sqb models.SceneMarkerReade
// TODO Find
// TODO GetMarkerStrings
// TODO Wall
// TODO Count
// TODO All
// TODO Query

View File

@@ -32,7 +32,3 @@
margin-right: 0.25em;
}
}
.field-options-table td:first-child {
padding-left: 0.75rem;
}

View File

@@ -1,9 +1,9 @@
import React from "react";
import { Form } from "react-bootstrap";
import { defineMessages, MessageDescriptor, useIntl } from "react-intl";
import { FilterSelect, ValidTypes } from "../../Shared";
import { Criterion } from "../../../models/list-filter/criteria/criterion";
import { IHierarchicalLabelValue } from "../../../models/list-filter/types";
import { FilterSelect, SelectObject } from "src/components/Shared/Select";
import { Criterion } from "src/models/list-filter/criteria/criterion";
import { IHierarchicalLabelValue } from "src/models/list-filter/types";
interface IHierarchicalLabelValueFilterProps {
criterion: Criterion<IHierarchicalLabelValue>;
@@ -36,11 +36,11 @@ export const HierarchicalLabelValueFilter: React.FC<IHierarchicalLabelValueFilte
},
});
function onSelectionChanged(items: ValidTypes[]) {
function onSelectionChanged(items: SelectObject[]) {
const { value } = criterion;
value.items = items.map((i) => ({
id: i.id,
label: i.name!,
label: i.name ?? i.title ?? "",
}));
onValueChanged(value);
}

View File

@@ -1,8 +1,8 @@
import React from "react";
import { Form } from "react-bootstrap";
import { FilterSelect, ValidTypes } from "../../Shared";
import { Criterion } from "../../../models/list-filter/criteria/criterion";
import { ILabeledId } from "../../../models/list-filter/types";
import { FilterSelect, SelectObject } from "src/components/Shared/Select";
import { Criterion } from "src/models/list-filter/criteria/criterion";
import { ILabeledId } from "src/models/list-filter/types";
interface ILabeledIdFilterProps {
criterion: Criterion<ILabeledId[]>;
@@ -26,11 +26,11 @@ export const LabeledIdFilter: React.FC<ILabeledIdFilterProps> = ({
)
return null;
function onSelectionChanged(items: ValidTypes[]) {
function onSelectionChanged(items: SelectObject[]) {
onValueChanged(
items.map((i) => ({
id: i.id,
label: i.name!,
label: i.name ?? i.title ?? "",
}))
);
}

View File

@@ -47,6 +47,7 @@ import {
faTrashAlt,
} from "@fortawesome/free-solid-svg-icons";
import { objectTitle } from "src/core/files";
import { galleryTitle } from "src/core/galleries";
import { useRatingKeybinds } from "src/hooks/keybinds";
const SceneScrapeDialog = lazy(() => import("./SceneScrapeDialog"));
@@ -105,7 +106,7 @@ export const SceneEditPanel: React.FC<IProps> = ({
setGalleries(
scene.galleries?.map((g) => ({
id: g.id,
title: objectTitle(g),
title: galleryTitle(g),
})) ?? []
);
}, [scene.galleries]);

View File

@@ -1,13 +1,12 @@
// @ts-nocheck
/* eslint-disable jsx-a11y/control-has-associated-label */
import React from "react";
import { Table, Button, Form } from "react-bootstrap";
import { Table, Form } from "react-bootstrap";
import { Link } from "react-router-dom";
import * as GQL from "src/core/generated-graphql";
import { NavUtils, TextUtils } from "src/utils";
import { Icon } from "src/components/Shared";
import { FormattedMessage } from "react-intl";
import { objectTitle } from "src/core/files";
import { galleryTitle } from "src/core/galleries";
import SceneQueue from "src/models/sceneQueue";
interface ISceneListTableProps {
scenes: GQL.SlimSceneDataFragment[];
@@ -19,14 +18,14 @@ interface ISceneListTableProps {
export const SceneListTable: React.FC<ISceneListTableProps> = (
props: ISceneListTableProps
) => {
const renderTags = (tags: GQL.SlimTagDataFragment[]) =>
const renderTags = (tags: Partial<GQL.TagDataFragment>[]) =>
tags.map((tag) => (
<Link key={tag.id} to={NavUtils.makeTagScenesUrl(tag)}>
<h6>{tag.name}</h6>
</Link>
));
const renderPerformers = (performers: Partial<GQL.Performer>[]) =>
const renderPerformers = (performers: Partial<GQL.PerformerDataFragment>[]) =>
performers.map((performer) => (
<Link key={performer.id} to={NavUtils.makePerformerScenesUrl(performer)}>
<h6>{performer.name}</h6>
@@ -34,13 +33,21 @@ export const SceneListTable: React.FC<ISceneListTableProps> = (
));
const renderMovies = (scene: GQL.SlimSceneDataFragment) =>
scene.movies.map((sceneMovie) =>
!sceneMovie.movie ? undefined : (
<Link to={NavUtils.makeMovieScenesUrl(sceneMovie.movie)}>
<h6>{sceneMovie.movie.name}</h6>
</Link>
)
);
scene.movies.map((sceneMovie) => (
<Link
key={sceneMovie.movie.id}
to={NavUtils.makeMovieScenesUrl(sceneMovie.movie)}
>
<h6>{sceneMovie.movie.name}</h6>
</Link>
));
const renderGalleries = (scene: GQL.SlimSceneDataFragment) =>
scene.galleries.map((gallery) => (
<Link key={gallery.id} to={`/galleries/${gallery.id}`}>
<h6>{galleryTitle(gallery)}</h6>
</Link>
));
const renderSceneRow = (scene: GQL.SlimSceneDataFragment, index: number) => {
const sceneLink = props.queue
@@ -60,7 +67,7 @@ export const SceneListTable: React.FC<ISceneListTableProps> = (
type="checkbox"
checked={props.selectedIds.has(scene.id)}
onChange={() =>
props.onSelectChange!(
props.onSelectChange(
scene.id,
!props.selectedIds.has(scene.id),
shiftKey
@@ -102,15 +109,7 @@ export const SceneListTable: React.FC<ISceneListTableProps> = (
)}
</td>
<td>{renderMovies(scene)}</td>
<td>
{scene.gallery && (
<Button className="minimal">
<Link to={`/galleries/${scene.gallery.id}`}>
<Icon icon={faImage} />
</Link>
</Button>
)}
</td>
<td>{renderGalleries(scene)}</td>
</tr>
);
};
@@ -144,7 +143,7 @@ export const SceneListTable: React.FC<ISceneListTableProps> = (
<FormattedMessage id="movies" />
</th>
<th>
<FormattedMessage id="gallery" />
<FormattedMessage id="galleries" />
</th>
</tr>
</thead>

View File

@@ -3,13 +3,7 @@ import { useIntl } from "react-intl";
import * as GQL from "src/core/generated-graphql";
import { Button, ButtonGroup } from "react-bootstrap";
import { FilterSelect } from "./Select";
type ValidTypes =
| GQL.SlimPerformerDataFragment
| GQL.SlimTagDataFragment
| GQL.SlimStudioDataFragment
| GQL.SlimMovieDataFragment;
import { FilterSelect, SelectObject } from "./Select";
interface IMultiSetProps {
type: "performers" | "studios" | "tags" | "movies";
@@ -31,7 +25,7 @@ const MultiSet: React.FunctionComponent<IMultiSetProps> = (
GQL.BulkUpdateIdMode.Remove,
];
function onUpdate(items: ValidTypes[]) {
function onUpdate(items: SelectObject[]) {
props.onUpdate(items.map((i) => i.id));
}

View File

@@ -31,11 +31,11 @@ import { objectTitle } from "src/core/files";
import { galleryTitle } from "src/core/galleries";
import { TagPopover } from "../Tags/TagPopover";
export type ValidTypes =
| GQL.SlimPerformerDataFragment
| GQL.SlimTagDataFragment
| GQL.SlimStudioDataFragment
| GQL.SlimMovieDataFragment;
export type SelectObject = {
id: string;
name?: string | null;
title?: string | null;
};
type Option = { value: string; label: string };
interface ITypeProps {
@@ -53,7 +53,7 @@ interface ITypeProps {
interface IFilterProps {
ids?: string[];
initialIds?: string[];
onSelect?: (item: ValidTypes[]) => void;
onSelect?: (item: SelectObject[]) => void;
noSelectionString?: string;
className?: string;
isMulti?: boolean;
@@ -90,9 +90,9 @@ interface ISelectProps<T extends boolean> {
noOptionsMessage?: string | null;
}
interface IFilterComponentProps extends IFilterProps {
items: Array<ValidTypes>;
toOption?: (item: ValidTypes) => Option;
onCreate?: (name: string) => Promise<{ item: ValidTypes; message: string }>;
items: SelectObject[];
toOption?: (item: SelectObject) => Option;
onCreate?: (name: string) => Promise<{ item: SelectObject; message: string }>;
}
interface IFilterSelectProps<T extends boolean>
extends Omit<ISelectProps<T>, "onChange" | "items" | "onCreateOption"> {}
@@ -272,7 +272,7 @@ const FilterSelectComponent = <T extends boolean>(
}
return {
value: i.id,
label: i.name ?? "",
label: i.name ?? i.title ?? "",
};
});

View File

@@ -8,7 +8,7 @@ import {
Icon,
OperationButton,
PerformerSelect,
ValidTypes,
SelectObject,
} from "src/components/Shared";
import { OptionalField } from "../IncludeButton";
import { faSave } from "@fortawesome/free-solid-svg-icons";
@@ -43,7 +43,7 @@ const PerformerResult: React.FC<IPerformerResultProps> = ({
(stashID) => stashID.endpoint === endpoint && stashID.stash_id
);
const handlePerformerSelect = (performers: ValidTypes[]) => {
const handlePerformerSelect = (performers: SelectObject[]) => {
if (performers.length) {
setSelectedID(performers[0].id);
} else {

View File

@@ -7,7 +7,7 @@ import {
Icon,
OperationButton,
StudioSelect,
ValidTypes,
SelectObject,
} from "src/components/Shared";
import * as GQL from "src/core/generated-graphql";
@@ -41,7 +41,7 @@ const StudioResult: React.FC<IStudioResultProps> = ({
(stashID) => stashID.endpoint === endpoint && stashID.stash_id
);
const handleSelect = (studios: ValidTypes[]) => {
const handleSelect = (studios: SelectObject[]) => {
if (studios.length) {
setSelectedID(studios[0].id);
} else {

View File

@@ -313,7 +313,6 @@ export const usePlugins = () => GQL.usePluginsQuery();
export const usePluginTasks = () => GQL.usePluginTasksQuery();
export const useMarkerStrings = () => GQL.useMarkerStringsQuery();
export const useAllTags = () => GQL.useAllTagsQuery();
export const useAllTagsForFilter = () => GQL.useAllTagsForFilterQuery();
export const useAllPerformersForFilter = () =>
GQL.useAllPerformersForFilterQuery();
@@ -408,7 +407,6 @@ const sceneMutationImpactedQueries = [
GQL.FindMoviesDocument,
GQL.FindTagDocument,
GQL.FindTagsDocument,
GQL.AllTagsDocument,
];
export const useSceneUpdate = () =>
@@ -572,7 +570,6 @@ const imageMutationImpactedQueries = [
GQL.FindStudiosDocument,
GQL.FindTagDocument,
GQL.FindTagsDocument,
GQL.AllTagsDocument,
GQL.FindGalleryDocument,
GQL.FindGalleriesDocument,
];
@@ -706,7 +703,6 @@ const galleryMutationImpactedQueries = [
GQL.FindStudiosDocument,
GQL.FindTagDocument,
GQL.FindTagsDocument,
GQL.AllTagsDocument,
GQL.FindGalleryDocument,
GQL.FindGalleriesDocument,
];
@@ -853,7 +849,6 @@ export const tagMutationImpactedQueries = [
GQL.FindSceneDocument,
GQL.FindScenesDocument,
GQL.FindSceneMarkersDocument,
GQL.AllTagsDocument,
GQL.AllTagsForFilterDocument,
GQL.FindTagsDocument,
];
@@ -861,15 +856,10 @@ export const tagMutationImpactedQueries = [
export const useTagCreate = () =>
GQL.useTagCreateMutation({
refetchQueries: getQueryNames([
GQL.AllTagsDocument,
GQL.AllTagsForFilterDocument,
GQL.FindTagsDocument,
]),
update: deleteCache([
GQL.FindTagsDocument,
GQL.AllTagsDocument,
GQL.AllTagsForFilterDocument,
]),
update: deleteCache([GQL.AllTagsForFilterDocument, GQL.FindTagsDocument]),
});
export const useTagUpdate = () =>
GQL.useTagUpdateMutation({

View File

@@ -14,6 +14,8 @@
* Changed performer aliases to be a list, rather than a string field. ([#3113](https://github.com/stashapp/stash/pull/3113))
### 🐛 Bug fixes
* **[0.19.1]** Fixed performance issues with Scene Tagger view. ([#3444](https://github.com/stashapp/stash/pull/3444), [#3452](https://github.com/stashapp/stash/pull/3452))
* **[0.19.1]** Fixed panic when batch adding performers from the Tagger view. ([#3456](https://github.com/stashapp/stash/pull/3456))
* Fixed folder symlinks not being handled correctly during clean. ([#3415](https://github.com/stashapp/stash/pull/3415))
* Fixed error when clicking Scrape All when a file-less scene is in the scene list. ([#3414](https://github.com/stashapp/stash/pull/3414))
* Fixed clicking popover pills not clearing search term. ([#3408](https://github.com/stashapp/stash/pull/3408))

View File

@@ -126,14 +126,6 @@ hr {
border: none;
border-color: #414c53;
padding: 0.25rem 0.75rem;
&:first-child {
padding-left: 0;
}
&:last-child {
padding-right: 0;
}
}
}