Use proper duration instead of seconds since midnight
This commit is contained in:
@ -354,12 +354,7 @@ class Exercise < ApplicationRecord
|
|||||||
"'')
|
"'')
|
||||||
if result.count > 0
|
if result.count > 0
|
||||||
begin
|
begin
|
||||||
quantiles.each_with_index.map { |_q, i| Time.parse(result[i]['unnest']).seconds_since_midnight }
|
quantiles.each_with_index.map { |_q, i| ActiveSupport::Duration.parse(result[i]['unnest']).to_f }
|
||||||
rescue ArgumentError => e
|
|
||||||
# result[i]['unnest'] might be an invalid time, but I don't know which
|
|
||||||
Raven.extra_context({quantiles: quantiles, result: result.to_json})
|
|
||||||
Raven.capture_exception(e)
|
|
||||||
quantiles.map { |_q| 0 }
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
quantiles.map { |_q| 0 }
|
quantiles.map { |_q| 0 }
|
||||||
@ -389,7 +384,7 @@ class Exercise < ApplicationRecord
|
|||||||
def accumulated_working_time_for_only(user)
|
def accumulated_working_time_for_only(user)
|
||||||
user_type = user.external_user? ? 'ExternalUser' : 'InternalUser'
|
user_type = user.external_user? ? 'ExternalUser' : 'InternalUser'
|
||||||
begin
|
begin
|
||||||
Time.parse(self.class.connection.execute(''"
|
ActiveSupport::Duration.parse(self.class.connection.execute(''"
|
||||||
WITH WORKING_TIME AS
|
WITH WORKING_TIME AS
|
||||||
(SELECT user_id,
|
(SELECT user_id,
|
||||||
id,
|
id,
|
||||||
@ -438,7 +433,7 @@ class Exercise < ApplicationRecord
|
|||||||
SELECT e.external_id AS external_user_id, f.user_id, exercise_id, MAX(max_score) AS max_score, sum(working_time_new) AS working_time
|
SELECT e.external_id AS external_user_id, f.user_id, exercise_id, MAX(max_score) AS max_score, sum(working_time_new) AS working_time
|
||||||
FROM FILTERED_TIMES_UNTIL_MAX f, EXTERNAL_USERS e
|
FROM FILTERED_TIMES_UNTIL_MAX f, EXTERNAL_USERS e
|
||||||
WHERE f.user_id = e.id GROUP BY e.external_id, f.user_id, exercise_id
|
WHERE f.user_id = e.id GROUP BY e.external_id, f.user_id, exercise_id
|
||||||
"'').first['working_time']).seconds_since_midnight
|
"'').first['working_time']).to_f
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user