added interventions back to code. added post method to be able to save interventions

This commit is contained in:
Thomas Hille
2017-02-28 15:26:36 +01:00
parent 3d7f5bdf1a
commit bfc96328c4
5 changed files with 30 additions and 10 deletions

View File

@ -126,7 +126,8 @@ class Exercise < ActiveRecord::Base
@working_time_statistics[user_id]["working_time"]
end
def accumulated_working_time_for_only(user_id)
def accumulated_working_time_for_only(user)
user_type = user.external_user? ? "ExternalUser" : "InternalUser"
Time.parse(self.class.connection.execute("""
SELECT sum(working_time_new) AS working_time
FROM
@ -136,7 +137,7 @@ class Exercise < ActiveRecord::Base
(created_at - lag(created_at) over (PARTITION BY user_id, exercise_id
ORDER BY created_at)) AS working_time
FROM submissions
WHERE exercise_id=#{id} and user_id=#{user_id} and user_type='ExternalUser') AS foo) AS bar
WHERE exercise_id=#{id} and user_id=#{user.id} and user_type='#{user_type}') AS foo) AS bar
""").first["working_time"] || "00:00:00").seconds_since_midnight
end