1 class UsersController < ApplicationController
2 skip_before_filter :find_object_by_uuid, :only => [:welcome, :activity]
3 skip_around_filter :thread_with_mandatory_api_token, :only => :welcome
7 params[:action] = 'home'
13 @breadcrumb_page_name = nil
19 pipeline_instances: {}
21 @spans = [['This week', Time.now.beginning_of_week, Time.now],
23 Time.now.beginning_of_week.advance(weeks:-1),
24 Time.now.beginning_of_week],
25 ['This month', Time.now.beginning_of_month, Time.now],
27 1.month.ago.beginning_of_month,
28 Time.now.beginning_of_month]]
29 @spans.each do |span, threshold_start, threshold_end|
30 @activity[:logins][span] = Log.
31 filter([[:event_type, '=', 'login'],
32 [:object_kind, '=', 'arvados#user'],
33 [:created_at, '>=', threshold_start],
34 [:created_at, '<', threshold_end]])
35 @activity[:jobs][span] = Job.
36 filter([[:created_at, '>=', threshold_start],
37 [:created_at, '<', threshold_end]])
38 @activity[:pipeline_instances][span] = PipelineInstance.
39 filter([[:created_at, '>=', threshold_start],
40 [:created_at, '<', threshold_end]])
41 @activity.each do |type, act|
44 @user_activity[u.uuid] ||= {}
45 @user_activity[u.uuid][span + ' ' + type.to_s] ||= 0
47 records.each do |record|
48 @user_activity[record.modified_by_user_uuid] ||= {}
49 @user_activity[record.modified_by_user_uuid][span + ' ' + type.to_s] ||= 0
50 @user_activity[record.modified_by_user_uuid][span + ' ' + type.to_s] += 1
54 @users = @users.sort_by do |a|
55 [-@user_activity[a.uuid].values.inject(:+), a.full_name]
60 @showallalerts = false
61 @my_ssh_keys = AuthorizedKey.where(authorized_user_uuid: current_user.uuid)
62 # @my_vm_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#virtual_machine', link_class: 'permission', name: 'can_login')
63 # @my_repo_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#repository', link_class: 'permission', name: 'can_write')
69 order('created_at desc').
70 where(created_by: current_user.uuid)
72 @my_collections = Collection.
74 order('created_at desc').
75 where(created_by: current_user.uuid)
77 Link.limit(1000).where(head_uuid: @my_collections.collect(&:uuid),
78 link_class: 'tag').each do |link|
79 (@my_tag_links[link.head_uuid] ||= []) << link
82 @my_pipelines = PipelineInstance.
84 order('created_at desc').
85 where(created_by: current_user.uuid)
88 # A Tutorial is a Link which has link_class "resources" and name
89 # "wants", and is owned by the Tutorials Group (i.e., named
90 # "Arvados Tutorials" and owned by the system user).
91 @tutorial_group = Group.where(owner_uuid: User.system.uuid,
92 name: 'Arvados Tutorials').first
94 @tutorial_links = Link.where(tail_uuid: @tutorial_group.uuid,
95 link_class: 'resources',
100 @tutorial_complete = {
101 'Run a job' => @my_last_job
104 f.js { render template: 'users/home.js' }
105 f.html { render template: 'users/home' }