Class: Solidstats::DashboardController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Solidstats::DashboardController
- Defined in:
- app/controllers/solidstats/dashboard_controller.rb
Constant Summary collapse
- TODO_CACHE_FILE =
Rails.root.join("tmp", "solidstats_todos.json")
- AUDIT_CACHE_HOURS =
Configure how many hours before refreshing
12
Instance Method Summary collapse
- #index ⇒ Object
-
#refresh ⇒ Object
Force refresh all dashboard data.
Instance Method Details
#index ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/solidstats/dashboard_controller.rb', line 6 def index # Use new services for data collection audit_service = AuditService.new todo_service = TodoService.new # Get full data for detailed views @audit_output = audit_service.fetch @todo_items = todo_service.fetch # Get summary data for dashboard cards @audit_summary = audit_service.summary @todo_summary = todo_service.summary # TODO: Refactor these to use services as well @rubocop_output = "JSON.parse(`rubocop --format json`)" @coverage = "100" end |
#refresh ⇒ Object
Force refresh all dashboard data
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/solidstats/dashboard_controller.rb', line 25 def refresh # Create services audit_service = AuditService.new todo_service = TodoService.new # Force refresh of data audit_output = audit_service.fetch(true) # Force refresh todo_items = todo_service.fetch(true) # Force refresh # Get updated summaries audit_summary = audit_service.summary todo_summary = todo_service.summary # Get current time for last updated display last_updated = Time.now.strftime("%B %d, %Y at %H:%M") # Return JSON response with refreshed data render json: { audit_output: audit_output, todo_items: todo_items, audit_summary: audit_summary, todo_summary: todo_summary, last_updated: last_updated, status: "success" } rescue StandardError => e # Return error information render json: { status: "error", message: "Failed to refresh data: #{e.message}" }, status: :internal_server_error end |