Cached displaynames of users

Added solved state and #comments to index of request_for_comments
Added translations
This commit is contained in:
Ralf Teusner
2016-06-27 16:46:26 +02:00
parent 2a52b66daa
commit 2ff12dbeb6
7 changed files with 39 additions and 6 deletions

View File

@@ -35,6 +35,7 @@ module CodeOcean
has_many :files
has_many :testruns
has_many :comments
alias_method :descendants, :files
mount_uploader :native_file, FileUploader

View File

@@ -6,8 +6,10 @@ class ExternalUser < ActiveRecord::Base
def displayname
result = name
if(consumer.name == 'openHPI')
result = Xikolo::UserClient.get(external_id.to_s)[:display_name]
Rails.cache.fetch("#{cache_key}/displayname", expires_in: 12.hours) do
if(consumer.name == 'openHPI')
result = Xikolo::UserClient.get(external_id.to_s)[:display_name]
end
end
result
end

View File

@@ -25,12 +25,16 @@ class RequestForComment < ActiveRecord::Base
limit 1").first
end
def comments_count
submission.files.map { |file| file.comments.size}.sum
end
def to_s
"RFC-" + self.id.to_s
end
private
def self.row_number_user_sql
select("id, user_id, exercise_id, file_id, question, requested_at, created_at, updated_at, user_type, row_number() OVER (PARTITION BY user_id ORDER BY created_at DESC) as row_number").to_sql
select("id, user_id, exercise_id, file_id, question, requested_at, created_at, updated_at, user_type, solved, row_number() OVER (PARTITION BY user_id ORDER BY created_at DESC) as row_number").to_sql
end
end