mirror of
https://github.com/ryankazokas/turbovault-app.git
synced 2026-04-16 23:22:53 +00:00
Moving to github
This commit is contained in:
26
app/controllers/dashboard_controller.rb
Normal file
26
app/controllers/dashboard_controller.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
class DashboardController < ApplicationController
|
||||
before_action :require_authentication
|
||||
|
||||
def index
|
||||
@recently_added_games = current_user.games.recent.limit(5)
|
||||
@currently_playing_games = current_user.games.currently_playing.limit(5)
|
||||
@total_games = current_user.games.count
|
||||
@physical_games = current_user.games.physical_games.count
|
||||
@digital_games = current_user.games.digital_games.count
|
||||
@completed_games = current_user.games.completed.count
|
||||
@backlog_games = current_user.games.backlog.count
|
||||
@total_spent = current_user.games.sum(:price_paid) || 0
|
||||
|
||||
@games_by_platform = current_user.games.joins(:platform)
|
||||
.group("platforms.name")
|
||||
.count
|
||||
.sort_by { |_, count| -count }
|
||||
.first(5)
|
||||
|
||||
@games_by_genre = current_user.games.joins(:genres)
|
||||
.group("genres.name")
|
||||
.count
|
||||
.sort_by { |_, count| -count }
|
||||
.first(5)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user