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],
22 ['Last week', 1.week.ago.beginning_of_week, nil],
23 ['This month', Time.now.beginning_of_month, Time.now],
24 ['Last month', 1.month.ago.beginning_of_month, nil]].
26 span[2] ||= span[1].advance(months: 1) if span[0].match /month/
27 span[2] ||= span[1].advance(weeks: 1) if span[0].match /week/
30 @spans.each do |span, threshold_start, threshold_end|
31 @activity[:logins][span] = Log.
32 filter([[:event_type, '=', 'login'],
33 [:object_kind, '=', 'arvados#user'],
34 [:created_at, '>=', threshold_start],
35 [:created_at, '<', threshold_end]])
36 @activity[:jobs][span] = Job.
37 filter([[:created_at, '>=', threshold_start],
38 [:created_at, '<', threshold_end]])
39 @activity[:pipeline_instances][span] = PipelineInstance.
40 filter([[:created_at, '>=', threshold_start],
41 [:created_at, '<', threshold_end]])
42 @activity.each do |type, act|
45 @user_activity[u.uuid] ||= {}
46 @user_activity[u.uuid][span + ' ' + type.to_s] ||= 0
48 records.each do |record|
49 @user_activity[record.modified_by_user_uuid] ||= {}
50 @user_activity[record.modified_by_user_uuid][span + ' ' + type.to_s] ||= 0
51 @user_activity[record.modified_by_user_uuid][span + ' ' + type.to_s] += 1
55 @users = @users.sort_by do |a|
56 [-@user_activity[a.uuid].values.inject(:+), a.full_name]
61 @showallalerts = false
62 @my_ssh_keys = AuthorizedKey.where(authorized_user_uuid: current_user.uuid)
63 # @my_vm_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#virtual_machine', link_class: 'permission', name: 'can_login')
64 # @my_repo_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#repository', link_class: 'permission', name: 'can_write')
70 order('created_at desc').
71 where(created_by: current_user.uuid)
73 @my_collections = Collection.
75 order('created_at desc').
76 where(created_by: current_user.uuid)
78 Link.limit(1000).where(head_uuid: @my_collections.collect(&:uuid),
79 link_class: 'tag').each do |link|
80 (@my_tag_links[link.head_uuid] ||= []) << link
83 @my_pipelines = PipelineInstance.
85 order('created_at desc').
86 where(created_by: current_user.uuid)
89 # A Tutorial is a Link which has link_class "resources" and name
90 # "wants", and is owned by the Tutorials Group (i.e., named
91 # "Arvados Tutorials" and owned by the system user).
92 @tutorial_group = Group.where(owner_uuid: User.system.uuid,
93 name: 'Arvados Tutorials').first
95 @tutorial_links = Link.where(tail_uuid: @tutorial_group.uuid,
96 link_class: 'resources',
101 @tutorial_complete = {
102 'Run a job' => @my_last_job
105 f.js { render template: 'users/home.js' }
106 f.html { render template: 'users/home' }