Class: UserDashboardInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/user_dashboard_info.rb

Overview

Provides information to user dashboard

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ UserDashboardInfo

Returns a new instance of UserDashboardInfo.



32
33
34
35
# File 'lib/user_dashboard_info.rb', line 32

def initialize(user)
  @user=user
  @sr_active=user.systematic_reviews.where(:active=>true)
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



31
32
33
# File 'lib/user_dashboard_info.rb', line 31

def user
  @user
end

Instance Method Details

#adu_for_sr(sr, stage) ⇒ Object



47
48
49
# File 'lib/user_dashboard_info.rb', line 47

def adu_for_sr(sr,stage)
  AnalysisUserDecision.new(sr[:id], @user[:id], stage)
end

#is_administrator_sr?(sr) ⇒ Boolean

The user is the administrator of a specific systematic review

Returns:

  • (Boolean)


51
52
53
# File 'lib/user_dashboard_info.rb', line 51

def is_administrator_sr?(sr)
  user[:id]==sr[:sr_administrator]
end

#is_member?(sr) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/user_dashboard_info.rb', line 55

def is_member?(sr)
  sr.group_users.nil? ? false : sr.group_users.include?(user)
end

#searches_not_ready(sr_id) ⇒ Object

Return the searches not ready for review



44
45
46
# File 'lib/user_dashboard_info.rb', line 44

def searches_not_ready(sr_id)
  Search.where(:user_id=>user[:id], :valid=>nil, :systematic_review_id=>sr_id)
end

#unread_personal_messagesObject



36
37
38
# File 'lib/user_dashboard_info.rb', line 36

def unread_personal_messages
  Message.where(:user_to=>@user[:id]).exclude(:viewed=>true)
end

#unread_sr_messages(sr_id) ⇒ Object



39
40
41
42
# File 'lib/user_dashboard_info.rb', line 39

def unread_sr_messages(sr_id)
  ids=$db["SELECT mr.id FROM message_srs mr LEFT JOIN message_sr_seens mrv ON mr.id=mrv.m_rs_id WHERE mr.systematic_review_id=? AND ( user_id IS NULL OR (user_id=? AND viewed!=1))",sr_id, @user[:id]].map(:id)
  MessageSr.where(:id=>ids)
end