Skip to content

Commit

Permalink
🚧 Grabbing some low hanging fruit
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyf committed Apr 5, 2024
1 parent e720484 commit 97912b2
Show file tree
Hide file tree
Showing 21 changed files with 2,389 additions and 0 deletions.
Binary file added app/assets/images/loading-progress.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions app/controllers/api/sushi_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# frozen_string_literal: true

module API
class SushiController < ApplicationController
private

##
# We have encountered an error in their request, this might be an invalid date or a missing
# required parameter. The end user can adjust the request and try again.
#
# @param [Exception]
def render_sushi_exception(error)
render json: error, status: 422
end
rescue_from Sushi::Error::Exception, with: :render_sushi_exception

public

##
# needs to include the following filters: begin & end date, item ID
#
#
# When given an item_id parameter, filter the results to only that item_id.
#
# @note We should not need to find the record in ActiveFedora; hopefully we have all we need in
# the stats database.
def item_report
@report = Sushi::ItemReport.new(params, account: current_account)
render json: @report
end

def platform_report
@report = Sushi::PlatformReport.new(params, account: current_account)
render json: @report
end

def platform_usage
@report = Sushi::PlatformUsageReport.new(params, account: current_account)
render json: @report
end

def server_status
@status = Sushi::ServerStatus.new(account: current_account).server_status
render json: @status
end

def report_list
@report = Sushi::ReportList.new
render json: @report
end
end
end
17 changes: 17 additions & 0 deletions app/jobs/create_derivatives_job_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

# OVERRIDE Hyrax v3.6.0
# @see CreateLargeDerivativesJob
module CreateDerivativesJobDecorator
# OVERRIDE: Divert audio and video derivative
# creation to CreateLargeDerivativesJob.
def perform(file_set, file_id, filepath = nil)
return super if is_a?(CreateLargeDerivativesJob)
return super unless file_set.video? || file_set.audio?

CreateLargeDerivativesJob.perform_later(*arguments)
true
end
end

CreateDerivativesJob.prepend(CreateDerivativesJobDecorator)
16 changes: 16 additions & 0 deletions app/jobs/create_large_derivatives_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# CreateLargeDerivativesJob is intended to be used for resource-intensive derivative
# generation (e.g. video processing). It is functionally similar to CreateDerivativesJob,
# except that it queues jobs in the :auxiliary queue.
#
# The worker responsible for processing jobs in the :auxiliary queue should be
# configured to have more resources dedicated to it, especially CPU. Otherwise, the
# `ffmpeg` commands that this job class eventually triggers could be throttled.
#
# @see CreateDerivativesJobDecorator
# @see Hydra::Derivatives::Processors::Ffmpeg
# @see https://github.com/scientist-softserv/palni-palci/issues/852
class CreateLargeDerivativesJob < CreateDerivativesJob
queue_as :auxiliary
end
10 changes: 10 additions & 0 deletions app/jobs/prune_stale_guest_users_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

class PruneStaleGuestUsersJob < ApplicationJob
non_tenant_job
repeat 'every week at 8am' # midnight PST

def perform
RolesService.prune_stale_guest_users
end
end
Loading

0 comments on commit 97912b2

Please sign in to comment.