diff options
author | Jack Davison <jack.davison@student.manchester.ac.uk> | 2016-06-22 01:22:03 +0300 |
---|---|---|
committer | Jack Davison <jack.davison@student.manchester.ac.uk> | 2016-08-17 15:33:51 +0300 |
commit | 4fbbb8e76550fcb8103cc1bf5c8536cf598db829 (patch) | |
tree | 9ef1af3d5e16ec428cb9a60353e0675723db24d7 /app/helpers/issues_helper.rb | |
parent | bcdc3694919f6cc9777dd982325469fb87468835 (diff) |
Truncates 9-10 users with current user in front
* If the current user is not in the list output will have 1-9 users
* If the current user is in the list output will be "me, " + 0-9 users
Diffstat (limited to 'app/helpers/issues_helper.rb')
-rw-r--r-- | app/helpers/issues_helper.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 15f08fd5918..e8081d452c4 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -114,10 +114,14 @@ module IssuesHelper end def award_user_list(awards, current_user) - names = awards.first(10).map do |award| + names = awards.map do |award| award.user == current_user ? 'me' : award.user.name end + # Take first 9 OR current user + first 9 + current_user_name = names.delete('me') + names = names.first(9).insert(0, current_user_name).compact + names << "and #{awards.size - names.size} more." if awards.size > names.size names.join(', ') |