Sha256: 78d66ae431a0edefc3a2710f7c5273e09c319904dc6cda4bc99078c33f4610a9

Contents?: true

Size: 891 Bytes

Versions: 4

Compression:

Stored size: 891 Bytes

Contents

require_dependency "apidae/application_controller"

module Apidae
  class DashboardController < ApplicationController
    def index
      if user_is_admin?
        @objects = Obj.count
        @selections = Selection.count
        @projects = Project.count
        @last_imports = FileImport.order(id: :desc).take(100)
      else
        projects = Project.where(apidae_id: apidae_user.apidae_projects_ids)
        selections = Selection.where(apidae_project_id: projects.select(:id).map {|p| p.id})
        @projects = projects.count
        @selections = selections.uniq.count
        @objects = SelectionObject.where(apidae_selection_id: selections.map {|s| s.id}.uniq).map {|so| so.apidae_object_id}.uniq.count
        @last_imports = FileImport.where(apidae_id: apidae_user.apidae_projects_ids).order(id: :desc).take(100)
      end
      @references = Reference.count
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
apidae-1.0.4 app/controllers/apidae/dashboard_controller.rb
apidae-1.0.3 app/controllers/apidae/dashboard_controller.rb
apidae-1.0.2 app/controllers/apidae/dashboard_controller.rb
apidae-1.0.0 app/controllers/apidae/dashboard_controller.rb