Enhance Job Management, Optimize Queries, and Introduce Thread-Safe Features #512
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New Features
Thread Safety Enhancements
concurrently
method inApplicationWorker
to limit concurrent jobs (e.g.,UploadWorker
is limited to 2 concurrent jobs).Backgrounder
for managing jobs, providing a centralized job management approach.Serialization and Scope Addition
serialize :segment_map
inDiskTitle
to store structured data as JSON.scope :sort_by_segment_map
to sortDiskTitle
by itssegment_map
.Enhanced Listeners
MkvDiskLoadListener
and integrated it into services likeCreateDisksService
and workers such asLoadDiskWorker
.Service Layer Enhancements
listener
option inCreateDisksService
for flexible subscription handling.Improvements
Database Query Optimizations
.includes
in multiple components and controllers to reduce N+1 query issues:Video
,DiskTitles
, andEpisodes
.MoviesController
,SeasonsController
, andTvsController
to use.includes
for related associations.uploaded_recently_video_blobs
anduploadable_video_blobs
inUploadProcessComponent
.Job Handling
Job.sort_by_created_at.active.find_by
calls withBackgrounder.managers.find
for better job lookup performance.Cleaner Code
find_or_initalize_disk
withfind_or_initialize_disk
.job:
tolistener:
in service calls).Improved UX
.compact_blank
forDiskTitle#to_label
.Consistent Duration Display
distance_of_time_in_words
with explicit options for better readability in views.Bug Fixes
Typographical Errors
segement_map
tosegment_map
.Corrected Scopes and Relations
episode.video_blobs.any?
corrected toepisode.uploaded_video_blobs.any?
).Initialization and Caching Issues
@episode_numbers
inVideoBlob
).Job#name_constant
to avoid redundant constantization.Concurrency Bugs
@@threads
) inApplicationWorker
and replaced them with centralized job handling inBackgrounder
.Job Argument Handling
Job#worker
are consistently symbolized to avoid errors during initialization.