updated interface

This commit is contained in:
2026-07-28 11:34:00 -06:00
parent 7ebf6dbf41
commit f55348f0b9
2 changed files with 131 additions and 57 deletions
+8 -10
View File
@@ -1,27 +1,25 @@
class DashboardController < ApplicationController
def index
joint_column = 'joint'
# Grab distinct values for dropdown filters
@available_joints = Joint.distinct.pluck(joint_column)
# Fetch initial records
@available_data
@records = filter_records
respond_to do |format|
format.html # Renders app/views/dashboards/index.html.erb
format.json { render json: @records } # Returns filtered data as JSON for JS
format.html
format.json { render json: @records }
end
end
private
def filter_records
if params.include?(:joint)
records = Joint.all
records = records.where(joint: params[:joint])
records
# Using .where(joint: params[:joint]) handles both present and nil values gracefully
if params[:joint].present?
Joint.where(joint: params[:joint])
else
[]
# Return empty array if no joint selected to avoid loading thousands of records
[]
end
end
end