Class: UserDashboardInfo
- Inherits:
-
Object
- Object
- UserDashboardInfo
- Defined in:
- lib/user_dashboard_info.rb
Overview
Provides information to user dashboard
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #adu_for_sr(sr, stage) ⇒ Object
-
#initialize(user) ⇒ UserDashboardInfo
constructor
A new instance of UserDashboardInfo.
-
#is_administrator_sr?(sr) ⇒ Boolean
The user is the administrator of a specific systematic review.
- #is_member?(sr) ⇒ Boolean
-
#searches_not_ready(sr_id) ⇒ Object
Return the searches not ready for review.
- #unread_personal_messages ⇒ Object
- #unread_sr_messages(sr_id) ⇒ Object
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
#user ⇒ Object (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
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
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_messages ⇒ Object
36 37 38 |
# File 'lib/user_dashboard_info.rb', line 36 def 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 (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 |