Skip to content

Commit

Permalink
291 | Reduce arguments initialized in sort and filter service
Browse files Browse the repository at this point in the history
  • Loading branch information
emmabjj committed Jan 7, 2025
1 parent b4a06ee commit 8515494
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
8 changes: 5 additions & 3 deletions app/controllers/phases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ def submissions
@submissions = SortAndFilterService.new(
@submissions,
params,
@not_started,
@in_progress,
@completed
{
not_started: @not_started,
in_progress: @in_progress,
completed: @completed
}
).sort_and_filter

@filtered_count = @submissions.unscope(:group).distinct.count(:id)
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/evaluations_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
module EvaluationsHelper
Score = Struct.new(:raw_score, :formatted_score, :display_score)

def evaluator_score(assignment) # individual evaluator score
# individual evaluator score
def evaluator_score(assignment)
score = display_score(assignment)
return Score.new(0, "0", "N/A") if score == 'N/A'

Expand Down
8 changes: 4 additions & 4 deletions app/services/sort_and_filter_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

# This service handles sort and filtering submissions.
class SortAndFilterService
def initialize(submissions, params, not_started, in_progress, completed)
def initialize(submissions, params, submission_statuses = {})
@submissions = submissions
@params = params
@not_started = not_started
@in_progress = in_progress
@completed = completed
@not_started = submission_statuses[:not_started]
@in_progress = submission_statuses[:in_progress]
@completed = submission_statuses[:completed]
end

def sort_and_filter
Expand Down

0 comments on commit 8515494

Please sign in to comment.