Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into prs/3931
Browse files Browse the repository at this point in the history
  • Loading branch information
WithoutPants committed Sep 1, 2023
2 parents 97ef26c + c364346 commit 6bd8959
Show file tree
Hide file tree
Showing 300 changed files with 9,402 additions and 6,822 deletions.
4 changes: 4 additions & 0 deletions .mockery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dir: ./pkg/models
name: ".*ReaderWriter"
outpkg: mocks
output: ./pkg/models/mocks
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ it:
# generates test mocks
.PHONY: generate-test-mocks
generate-test-mocks:
go run github.com/vektra/mockery/v2 --dir ./pkg/models --name '.*ReaderWriter' --outpkg mocks --output ./pkg/models/mocks
go run github.com/vektra/mockery/v2

# runs server
# sets the config file to use the local dev config
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Stash
https://stashapp.cc

[![Build](https://github.com/stashapp/stash/actions/workflows/build.yml/badge.svg?branch=develop&event=push)](https://github.com/stashapp/stash/actions/workflows/build.yml)
[![Docker pulls](https://img.shields.io/docker/pulls/stashapp/stash.svg)](https://hub.docker.com/r/stashapp/stash 'DockerHub')
Expand All @@ -21,7 +20,7 @@ https://stashapp.cc

You can [watch a SFW demo video](https://vimeo.com/545323354) to see it in action.

For further information you can [read the in-app manual](ui/v2.5/src/docs/en).
For further information you can consult the [documentation](https://docs.stashapp.cc) or [read the in-app manual](ui/v2.5/src/docs/en).

# Installing Stash

Expand Down Expand Up @@ -49,10 +48,10 @@ Many community-maintained scrapers are available for download from [CommunityScr
<sub>[StashDB](http://stashdb.org) is the canonical instance of our open source metadata API, [stash-box](https://github.com/stashapp/stash-box).</sub>

# Translation
[![Translate](https://translate.stashapp.cc/widgets/stash/-/stash-desktop-client/svg-badge.svg)](https://translate.stashapp.cc/engage/stash/)
[![Translate](https://hosted.weblate.org/widget/stashapp/stash/svg-badge.svg)](https://hosted.weblate.org/engage/stashapp/)
🇧🇷 🇨🇳 🇩🇰 🇳🇱 🇬🇧 🇪🇪 🇫🇮 🇫🇷 🇩🇪 🇮🇹 🇯🇵 🇰🇷 🇵🇱 🇷🇺 🇪🇸 🇸🇪 🇹🇼 🇹🇷

Stash is available in 25 languages (so far!) and it could be in your language too. If you want to help us translate Stash into your language, you can make an account at [translate.stashapp.cc](https://translate.stashapp.cc/projects/stash/stash-desktop-client/) to get started contributing new languages or improving existing ones. Thanks!
Stash is available in 25 languages (so far!) and it could be in your language too. We use Weblate to coordinate community translations. If you want to help us translate Stash into your language, you can make an account at [Stash's Weblate](https://hosted.weblate.org/projects/stashapp/stash/) to get started contributing new languages or improving existing ones. Thanks!

# Support (FAQ)

Expand Down
6 changes: 3 additions & 3 deletions cmd/phasher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

flag "github.com/spf13/pflag"
"github.com/stashapp/stash/pkg/ffmpeg"
"github.com/stashapp/stash/pkg/file"
"github.com/stashapp/stash/pkg/hash/videophash"
"github.com/stashapp/stash/pkg/models"
)

func customUsage() {
Expand All @@ -28,8 +28,8 @@ func printPhash(ff *ffmpeg.FFMpeg, ffp ffmpeg.FFProbe, inputfile string, quiet *
// videoFile.Path (from BaseFile)
// videoFile.Duration
// The rest of the struct isn't needed.
vf := &file.VideoFile{
BaseFile: &file.BaseFile{Path: inputfile},
vf := &models.VideoFile{
BaseFile: &models.BaseFile{Path: inputfile},
Duration: ffvideoFile.FileDuration,
}

Expand Down
32 changes: 32 additions & 0 deletions gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ autobind:

models:
# Scalars
ID:
model:
- github.com/99designs/gqlgen/graphql.ID
- github.com/99designs/gqlgen/graphql.IntID
- github.com/stashapp/stash/pkg/models.FileID
- github.com/stashapp/stash/pkg/models.FolderID
Int64:
model: github.com/99designs/gqlgen/graphql.Int64
Timestamp:
Expand All @@ -33,6 +39,30 @@ models:
fields:
title:
resolver: true
# override models, from internal/api/models.go
BaseFile:
model: github.com/stashapp/stash/internal/api.BaseFile
GalleryFile:
model: github.com/stashapp/stash/internal/api.GalleryFile
fields:
# override fingerprint field
fingerprints:
fieldName: FingerprintSlice
VideoFile:
fields:
# override fingerprint field
fingerprints:
fieldName: FingerprintSlice
# override float fields - #1572
duration:
fieldName: DurationFinite
frame_rate:
fieldName: FrameRateFinite
ImageFile:
fields:
# override fingerprint field
fingerprints:
fieldName: FingerprintSlice
# autobind on config causes generation issues
BlobsStorageType:
model: github.com/stashapp/stash/internal/manager/config.BlobsStorageType
Expand Down Expand Up @@ -118,4 +148,6 @@ models:
model: github.com/stashapp/stash/internal/identify.MetadataOptions
ScraperSourceInput:
model: github.com/stashapp/stash/pkg/scraper.Source
SavedFindFilterType:
model: github.com/stashapp/stash/pkg/models.FindFilterType

10 changes: 9 additions & 1 deletion graphql/documents/data/filter.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@ fragment SavedFilterData on SavedFilter {
id
mode
name
filter
find_filter {
q
page
per_page
sort
direction
}
object_filter
ui_options
}
7 changes: 7 additions & 0 deletions graphql/documents/data/performer-slim.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ fragment SlimPerformerData on Performer {
death_date
weight
}

fragment SelectPerformerData on Performer {
id
name
disambiguation
alias_list
}
9 changes: 0 additions & 9 deletions graphql/documents/queries/misc.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ query MarkerStrings($q: String, $sort: String) {
}
}

query AllPerformersForFilter {
allPerformers {
id
name
disambiguation
alias_list
}
}

query AllStudiosForFilter {
allStudios {
id
Expand Down
24 changes: 23 additions & 1 deletion graphql/documents/queries/performer.graphql
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
query FindPerformers(
$filter: FindFilterType
$performer_filter: PerformerFilterType
$performer_ids: [Int!]
) {
findPerformers(filter: $filter, performer_filter: $performer_filter) {
findPerformers(
filter: $filter
performer_filter: $performer_filter
performer_ids: $performer_ids
) {
count
performers {
...PerformerData
Expand All @@ -15,3 +20,20 @@ query FindPerformer($id: ID!) {
...PerformerData
}
}

query FindPerformersForSelect(
$filter: FindFilterType
$performer_filter: PerformerFilterType
$performer_ids: [Int!]
) {
findPerformers(
filter: $filter
performer_filter: $performer_filter
performer_ids: $performer_ids
) {
count
performers {
...SelectPerformerData
}
}
}
5 changes: 4 additions & 1 deletion graphql/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Query {
findPerformers(
performer_filter: PerformerFilterType
filter: FindFilterType
performer_ids: [Int!]
): FindPerformersResultType!

"Find a studio by ID"
Expand Down Expand Up @@ -223,11 +224,13 @@ type Query {
allSceneMarkers: [SceneMarker!]!
allImages: [Image!]!
allGalleries: [Gallery!]!
allPerformers: [Performer!]!
allStudios: [Studio!]!
allMovies: [Movie!]!
allTags: [Tag!]!

# @deprecated
allPerformers: [Performer!]!

# Get everything with minimal metadata

# Version
Expand Down
31 changes: 27 additions & 4 deletions graphql/schema/types/filters.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ input FindFilterType {
direction: SortDirectionEnum
}

type SavedFindFilterType {
q: String
page: Int
"""
use per_page = -1 to indicate all results. Defaults to 25.
"""
per_page: Int
sort: String
direction: SortDirectionEnum
}

enum ResolutionEnum {
"144p"
VERY_LOW
Expand Down Expand Up @@ -604,15 +615,24 @@ type SavedFilter {
name: String!
"JSON-encoded filter string"
filter: String!
@deprecated(reason: "use find_filter and object_filter instead")
find_filter: SavedFindFilterType
# maps to any of the AnyFilterInput types
# using a generic Map instead of creating and maintaining match types for inputs
object_filter: Map
# generic map for ui options
ui_options: Map
}

input SaveFilterInput {
"provide ID to overwrite existing filter"
id: ID
mode: FilterMode!
name: String!
"JSON-encoded filter string"
filter: String!
find_filter: FindFilterType
object_filter: Map
# generic map for ui options
ui_options: Map
}

input DestroyFilterInput {
Expand All @@ -621,6 +641,9 @@ input DestroyFilterInput {

input SetDefaultFilterInput {
mode: FilterMode!
"JSON-encoded filter string - null to clear"
filter: String
"null to clear"
find_filter: FindFilterType
object_filter: Map
# generic map for ui options
ui_options: Map
}
39 changes: 19 additions & 20 deletions internal/api/loaders/dataloaders.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//go:generate go run -mod=vendor github.com/vektah/dataloaden SceneLoader int *github.com/stashapp/stash/pkg/models.Scene
//go:generate go run -mod=vendor github.com/vektah/dataloaden GalleryLoader int *github.com/stashapp/stash/pkg/models.Gallery
//go:generate go run -mod=vendor github.com/vektah/dataloaden ImageLoader int *github.com/stashapp/stash/pkg/models.Image
//go:generate go run -mod=vendor github.com/vektah/dataloaden PerformerLoader int *github.com/stashapp/stash/pkg/models.Performer
//go:generate go run -mod=vendor github.com/vektah/dataloaden StudioLoader int *github.com/stashapp/stash/pkg/models.Studio
//go:generate go run -mod=vendor github.com/vektah/dataloaden TagLoader int *github.com/stashapp/stash/pkg/models.Tag
//go:generate go run -mod=vendor github.com/vektah/dataloaden MovieLoader int *github.com/stashapp/stash/pkg/models.Movie
//go:generate go run -mod=vendor github.com/vektah/dataloaden FileLoader github.com/stashapp/stash/pkg/file.ID github.com/stashapp/stash/pkg/file.File
//go:generate go run -mod=vendor github.com/vektah/dataloaden SceneFileIDsLoader int []github.com/stashapp/stash/pkg/file.ID
//go:generate go run -mod=vendor github.com/vektah/dataloaden ImageFileIDsLoader int []github.com/stashapp/stash/pkg/file.ID
//go:generate go run -mod=vendor github.com/vektah/dataloaden GalleryFileIDsLoader int []github.com/stashapp/stash/pkg/file.ID
//go:generate go run github.com/vektah/dataloaden SceneLoader int *github.com/stashapp/stash/pkg/models.Scene
//go:generate go run github.com/vektah/dataloaden GalleryLoader int *github.com/stashapp/stash/pkg/models.Gallery
//go:generate go run github.com/vektah/dataloaden ImageLoader int *github.com/stashapp/stash/pkg/models.Image
//go:generate go run github.com/vektah/dataloaden PerformerLoader int *github.com/stashapp/stash/pkg/models.Performer
//go:generate go run github.com/vektah/dataloaden StudioLoader int *github.com/stashapp/stash/pkg/models.Studio
//go:generate go run github.com/vektah/dataloaden TagLoader int *github.com/stashapp/stash/pkg/models.Tag
//go:generate go run github.com/vektah/dataloaden MovieLoader int *github.com/stashapp/stash/pkg/models.Movie
//go:generate go run github.com/vektah/dataloaden FileLoader github.com/stashapp/stash/pkg/models.FileID github.com/stashapp/stash/pkg/models.File
//go:generate go run github.com/vektah/dataloaden SceneFileIDsLoader int []github.com/stashapp/stash/pkg/models.FileID
//go:generate go run github.com/vektah/dataloaden ImageFileIDsLoader int []github.com/stashapp/stash/pkg/models.FileID
//go:generate go run github.com/vektah/dataloaden GalleryFileIDsLoader int []github.com/stashapp/stash/pkg/models.FileID

package loaders

Expand All @@ -18,7 +18,6 @@ import (
"time"

"github.com/stashapp/stash/internal/manager"
"github.com/stashapp/stash/pkg/file"
"github.com/stashapp/stash/pkg/models"
"github.com/stashapp/stash/pkg/txn"
)
Expand Down Expand Up @@ -216,8 +215,8 @@ func (m Middleware) fetchMovies(ctx context.Context) func(keys []int) ([]*models
}
}

func (m Middleware) fetchFiles(ctx context.Context) func(keys []file.ID) ([]file.File, []error) {
return func(keys []file.ID) (ret []file.File, errs []error) {
func (m Middleware) fetchFiles(ctx context.Context) func(keys []models.FileID) ([]models.File, []error) {
return func(keys []models.FileID) (ret []models.File, errs []error) {
err := m.withTxn(ctx, func(ctx context.Context) error {
var err error
ret, err = m.Repository.File.Find(ctx, keys...)
Expand All @@ -227,8 +226,8 @@ func (m Middleware) fetchFiles(ctx context.Context) func(keys []file.ID) ([]file
}
}

func (m Middleware) fetchScenesFileIDs(ctx context.Context) func(keys []int) ([][]file.ID, []error) {
return func(keys []int) (ret [][]file.ID, errs []error) {
func (m Middleware) fetchScenesFileIDs(ctx context.Context) func(keys []int) ([][]models.FileID, []error) {
return func(keys []int) (ret [][]models.FileID, errs []error) {
err := m.withTxn(ctx, func(ctx context.Context) error {
var err error
ret, err = m.Repository.Scene.GetManyFileIDs(ctx, keys)
Expand All @@ -238,8 +237,8 @@ func (m Middleware) fetchScenesFileIDs(ctx context.Context) func(keys []int) ([]
}
}

func (m Middleware) fetchImagesFileIDs(ctx context.Context) func(keys []int) ([][]file.ID, []error) {
return func(keys []int) (ret [][]file.ID, errs []error) {
func (m Middleware) fetchImagesFileIDs(ctx context.Context) func(keys []int) ([][]models.FileID, []error) {
return func(keys []int) (ret [][]models.FileID, errs []error) {
err := m.withTxn(ctx, func(ctx context.Context) error {
var err error
ret, err = m.Repository.Image.GetManyFileIDs(ctx, keys)
Expand All @@ -249,8 +248,8 @@ func (m Middleware) fetchImagesFileIDs(ctx context.Context) func(keys []int) ([]
}
}

func (m Middleware) fetchGalleriesFileIDs(ctx context.Context) func(keys []int) ([][]file.ID, []error) {
return func(keys []int) (ret [][]file.ID, errs []error) {
func (m Middleware) fetchGalleriesFileIDs(ctx context.Context) func(keys []int) ([][]models.FileID, []error) {
return func(keys []int) (ret [][]models.FileID, errs []error) {
err := m.withTxn(ctx, func(ctx context.Context) error {
var err error
ret, err = m.Repository.Gallery.GetManyFileIDs(ctx, keys)
Expand Down
Loading

0 comments on commit 6bd8959

Please sign in to comment.