Added Items and Dashboard
This commit is contained in:
15
app/controllers/dashboard_controller.rb
Normal file
15
app/controllers/dashboard_controller.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class DashboardController < ApplicationController
|
||||
def index
|
||||
# 1. Zählt alle registrierten Hardware-Unikate
|
||||
@total_items = Item.count
|
||||
|
||||
# 2. Berechnet den Gesamtwert aller Geräte (summiert das Feld :price)
|
||||
@total_value = Item.sum(:price)
|
||||
|
||||
# 3. Zählt die Artikel, die weder einem User noch einem Raum gehören (= im Lager liegen)
|
||||
@items_in_storage = Item.where(user_id: nil, room_id: nil).count
|
||||
|
||||
# 4. Holt die letzten 10 registrierten Artikel für die Aktivitätenanzeige
|
||||
@recent_items = Item.order(created_at: :desc).limit(10).includes(:category, :user, :room)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user