Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model refactor, part 2 #4092

Merged
merged 11 commits into from
Sep 11, 2023
Merged

Conversation

DingDongSoLong4
Copy link
Collaborator

This is some more refactoring and minor improvements, following on from my earlier model refactoring. I'm trying to be a bit better with sending through smaller PRs, so there's more to come - expect a part 3 :)

The commit messages are for the most part fairly self-expanatory:

  • 4bec851 adds a bunch of conversion methods to the changesetTranslator, which allows for a lot of duplicated hasField checking and type conversions to be moved out of the various resolver functions.
  • f74252b ensures that every error resulting from a conversion is wrapped in a suitable message - an invalid ID will no longer just give a strconv.Atoi: ... error, but rather converting id: strconv.Atoi: ....
  • 8b33f95 adds New and NewPartial functions and ensures they are used everywhere, to avoid forgetting to set/update CreatedAt and UpdatedAt. While making this change, I indeed found, and fixed, a few places where this had been forgotten.
  • 27016aa replaces getStashIDsForStudio and getStashIDsForPerformer with calling the GetStashIDs method directly - this is cleaner and reduces overhead vs LoadStashIDs.
  • e6d865d just fixes a few tests broken by 8b33f95.
  • c594f7d removes ImageCreateInput in favour of just passing in the fileIDs directly to Create. This is consistent with how Create works for both scenes and galleries.

Copy link
Collaborator

@WithoutPants WithoutPants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor stuff.

internal/api/changeset_translator.go Outdated Show resolved Hide resolved
internal/api/resolver_mutation_performer.go Outdated Show resolved Hide resolved
internal/autotag/gallery_test.go Outdated Show resolved Hide resolved
pkg/gallery/scan.go Show resolved Hide resolved
pkg/image/scan.go Show resolved Hide resolved
@WithoutPants WithoutPants added the chore Pull requests for refactoring and admin work label Sep 8, 2023
@WithoutPants WithoutPants added this to the Version 0.23.0 milestone Sep 8, 2023
DingDongSoLong4 and others added 5 commits September 8, 2023 11:26
Matching functions were calling assert functions. Rewrote the assert functions to be internal matching functions for now.
@WithoutPants
Copy link
Collaborator

I've rewritten the assert functions into internal matching functions for the moment. The existing functions were sometimes returning false, and sometimes asserting and returning false and an assert was incorrect for a matching function. We can move them into a public location if the need arises.

@WithoutPants WithoutPants merged commit 24e4719 into stashapp:develop Sep 11, 2023
2 checks passed
@DingDongSoLong4 DingDongSoLong4 deleted the model-refactor2 branch September 11, 2023 14:55
This was referenced Sep 15, 2023
Dankonite added a commit to Dankonite/stash that referenced this pull request Sep 25, 2023
commit 165528f
Author: Maista <131594657+Maista6969@users.noreply.github.com>
Date:   Mon Sep 25 05:05:24 2023 +0200

    Fix false positive mismatch in Movie Scrape dialog (stashapp#4144)

    * Fix false positive mismatch in Movie Scrape dialog

    Scraping a movie by URL would show a difference in duration because the
    persisted value of duration was converted to HH:MM:SS while the newly
    scraped value was displayed without formatting: this makes sense because
    the newly scraped value is just a string and so could be anything

    This adds a check to see if the string is a number and converts it to
    HH:MM:SS format if possible

    * Fallback to original value if not a number

    ---------

    Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>

commit 9577600
Author: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
Date:   Mon Sep 25 12:27:20 2023 +1000

    Gallery URLs (stashapp#4114)

    * Initial backend changes
    * Fix unit tests
    * UI changes
    * Fix missing URL filters

commit a369e39
Author: Maista <131594657+Maista6969@users.noreply.github.com>
Date:   Mon Sep 25 04:25:24 2023 +0200

    Allow scene scrapers to return full movie data (stashapp#4147)

    Movies scraped from the scene scrape dialog can now create full movies
    just like the movie scrape dialog albeit without the helpful preview

commit bba60cc
Author: Flashy78 <90150289+Flashy78@users.noreply.github.com>
Date:   Sun Sep 24 19:24:08 2023 -0700

    Fix width of image selection arrow div (stashapp#4142)

commit ce55392
Author: DingDongSoLong4 <99329275+DingDongSoLong4@users.noreply.github.com>
Date:   Mon Sep 25 03:55:36 2023 +0200

    PerformerSelect Tagger bugfixes (stashapp#4148)

    * Fix Tagger PerformerSelect active highlight
    * Clear select on skip
    * Add back react-select className

commit 22350d3
Author: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
Date:   Mon Sep 25 11:53:47 2023 +1000

    Filter migration fix (stashapp#4151)

    * Exclude value for is null/not null

    Also includes changes to the error message in the migration to include the filter string.

    * Ignore null when setting from encoded criterion

commit 9f5bcca
Author: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
Date:   Mon Sep 25 09:35:55 2023 +1000

    Fix lightbox fullscreen issues (stashapp#4149)

    * Improve lightbox context hook
    * Prevent fullscreen drop while loading
    * Fix close not working from fullscreen

commit 462943a
Author: Flashy78 <90150289+Flashy78@users.noreply.github.com>
Date:   Thu Sep 21 14:24:06 2023 -0700

    Help text for animated image previews (stashapp#4139)

commit 636b0a3
Author: elkorol <57588838+elkorol@users.noreply.github.com>
Date:   Wed Sep 20 05:08:00 2023 +0100

    Add Icons to tags if they have parent/child tags (stashapp#3931)

    * Add Icons to tags if they have parent/child tags
    * Refactor TagLink
    ---------
    Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>

commit 36e9ed7
Author: DingDongSoLong4 <99329275+DingDongSoLong4@users.noreply.github.com>
Date:   Wed Sep 20 03:15:48 2023 +0200

    Fix bulk tagger again (stashapp#4133)

    * Add ForEndpoint method
    * Fix typo in schema 48 migration

commit 7ba7df0
Author: DingDongSoLong4 <99329275+DingDongSoLong4@users.noreply.github.com>
Date:   Wed Sep 20 03:11:27 2023 +0200

    Fix bulk movie update (stashapp#4130)

commit 3aa3515
Author: yoshnopa <40072150+yoshnopa@users.noreply.github.com>
Date:   Tue Sep 19 01:32:59 2023 +0200

    Allow Autoplay when loading the site first time (stashapp#4131)

commit 81f39bc
Author: DingDongSoLong4 <99329275+DingDongSoLong4@users.noreply.github.com>
Date:   Tue Sep 19 01:31:34 2023 +0200

    Lightbox infinite scrolling improvements (stashapp#3894)

commit 62173a9
Author: DingDongSoLong4 <99329275+DingDongSoLong4@users.noreply.github.com>
Date:   Mon Sep 18 01:39:56 2023 +0200

    Fix scene merge nil dereference (stashapp#4119)

commit 0b7dcbe
Author: Maista <131594657+Maista6969@users.noreply.github.com>
Date:   Fri Sep 15 01:08:55 2023 +0200

    Update htmlquery dependency (stashapp#4126)

commit f51ac81
Author: DrDaveUK <dr-dave@outlook.com>
Date:   Tue Sep 12 07:46:36 2023 +0100

    Scene Duplicate Checker UI & Feature Improvement (stashapp#4006)

    * UI Update to show which file is being deleted
    Added Selection dropwdown
    Added checkbox to ensure that the codecs are the same within the group

    * Refactor size options
    * Convert select box to dropdown
    * Internationalisation
    ---------
    Co-authored-by: Steve Enderby <vpn-enderbys@capitatflpp.onmicrosoft.com>
    Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>

commit a25286b
Author: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
Date:   Tue Sep 12 13:31:53 2023 +1000

    Multiple image URLs (stashapp#4000)

    * Backend changes - ported from scene impl
    * Front end changes
    * Refactor URL mutation code

commit 9f4d0af
Author: DingDongSoLong4 <99329275+DingDongSoLong4@users.noreply.github.com>
Date:   Tue Sep 12 02:53:32 2023 +0200

    Filter criterion fixes (stashapp#4090)

    * Reorder
    * Remove PhashDuplicateCriterion
    * Improve DurationInput
    * Register abloop outside of player init function
    * Remove none criterion
    * Typing improvements
    * Move makeCriteria to ListFilterModel
    * Separate PathCriterionOption
    * Add makeCriterion arg to StringCriterionOption
    * Remove unused options args
    * Add DurationCriterionOption
    * Use createNumberCriterionOption
    * Add StringBooleanCriterion

commit 0d13eec
Author: MrX292 <42774880+MrX292@users.noreply.github.com>
Date:   Tue Sep 12 02:37:49 2023 +0200

    Update Configuration.md (stashapp#4108)

commit 4a9fdc8
Author: its-josh4 <74079536+its-josh4@users.noreply.github.com>
Date:   Mon Sep 11 17:36:48 2023 -0700

    Remove vendored dependencies (stashapp#4110)

commit b36aa74
Author: its-josh4 <74079536+its-josh4@users.noreply.github.com>
Date:   Sun Sep 10 21:43:42 2023 -0700

    Fixed: CopyFile not working (stashapp#4104)

commit da38ec0
Author: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
Date:   Mon Sep 11 14:41:13 2023 +1000

    Fix rating and country filters (stashapp#4105)

    * Fix country criterion
    * Fixing rating criterion

commit 798db1a
Author: its-josh4 <74079536+its-josh4@users.noreply.github.com>
Date:   Sun Sep 10 19:48:39 2023 -0700

    Improve error reporting when moving a transcoded file fails (stashapp#4101)

commit 06d7630
Author: its-josh4 <74079536+its-josh4@users.noreply.github.com>
Date:   Sun Sep 10 19:46:21 2023 -0700

    Do not log ECONNRESET errors when serving transcoded video files (stashapp#4099)

commit 953867f
Author: CJ <72030708+Teda1@users.noreply.github.com>
Date:   Sun Sep 10 21:45:58 2023 -0500

    Adjust compact details (stashapp#4098)

commit f237a58
Author: yoshnopa <40072150+yoshnopa@users.noreply.github.com>
Date:   Mon Sep 11 04:39:55 2023 +0200

    Frontpage Mobile Fix (stashapp#4057)

    Change CSS To show Correct dimensions on Mobile

commit 24e4719
Author: DingDongSoLong4 <99329275+DingDongSoLong4@users.noreply.github.com>
Date:   Mon Sep 11 04:24:15 2023 +0200

    Model refactor, part 2 (stashapp#4092)

    * Move conversions into changesetTranslator
    * Improve mutation error messages
    * Use models.New and models.NewPartial everywhere
    * Replace getStashIDsFor functions
    * Remove ImageCreateInput
    * Remove unused parameters
    * Refactor matching functions
    ---------
    Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>

commit cf3301c
Author: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
Date:   Mon Sep 11 10:50:24 2023 +1000

    Handle equality when scraping scene performers (stashapp#4094)

commit 50c4ac9
Author: DingDongSoLong4 <99329275+DingDongSoLong4@users.noreply.github.com>
Date:   Fri Sep 8 03:33:16 2023 +0200

    Thumbnail scrubber improvements (stashapp#4081)

    * Remove deps from useDebounce hook
    * Add useThrottle hook
    * Throttle preview scrubber
    * Scrubber improvements
halkeye pushed a commit to halkeye/stash that referenced this pull request Sep 1, 2024
* Move conversions into changesetTranslator
* Improve mutation error messages
* Use models.New and models.NewPartial everywhere
* Replace getStashIDsFor functions
* Remove ImageCreateInput
* Remove unused parameters
* Refactor matching functions
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Pull requests for refactoring and admin work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants