Skip to content

Commit

Permalink
Fixed some linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mengyewgau committed Oct 9, 2023
1 parent 931f6dd commit f06b9ea
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/controllers/api/v1/submission_similarities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,20 @@ def render_submission_similarities
render json: { status: 'processing' }, status: :ok
return
when SubmissionSimilarityProcess::STATUS_ERRONEOUS
render json: { status: 'error', message: 'SSID is busy or under maintenance. Please try again later.' }, status: :service_unavailable
render json: { status: 'error', message: 'SSID is busy or under maintenance. Please try again later.' },
status: :service_unavailable
return
end

submission_similarities = assignment.submission_similarities

### Filtering Code
### Filtering Code
# Apply the threshold filter
if params[:threshold].present?
threshold_value = params[:threshold].to_f
submission_similarities = submission_similarities.where('similarity >= ?', threshold_value)
end

# Apply the limit filter
if params[:limit].present?
limit_value = params[:limit].to_i
Expand All @@ -91,15 +92,14 @@ def render_submission_similarities

# Apply the page filter
if params[:page].present?
per_page = params[:limit].present? ?limit_value : 20 # Default per page value is 20, limit to use a page size
per_page = params[:limit].present? ? limit_value : 20 # Default per page value is 20, limit to use a page size
page_number = params[:page].to_i
submission_similarities = submission_similarities.offset(per_page * (page_number - 1))
end


render json: { status: "processed", submissionSimilarities: submission_similarities }, status: :ok
render json: { status: 'processed', submissionSimilarities: submission_similarities }, status: :ok
end

def render_pair_of_flagged_submissions
submission_similarity = SubmissionSimilarity.find_by(
assignment_id: params[:assignment_id],
Expand Down

0 comments on commit f06b9ea

Please sign in to comment.