Use exec_query for custom SQL execution

Also align how we use query Postgres from controllers.

The change is mainly due to regular (but not reproducible) issues with the `intervalstyle` defaulting to `postgres` (instead of `iso8601`) and thereby causing issues. We're just experimenting to see whether this change resolves the issue.
This commit is contained in:
Sebastian Serth
2022-12-06 22:41:00 +01:00
parent 65c95a1f1c
commit bc5baed05e
6 changed files with 12 additions and 12 deletions

View File

@ -107,7 +107,7 @@ class ExecutionEnvironmentsController < ApplicationController
working_time_statistics = {}
user_statistics = {}
ApplicationRecord.connection.execute(working_time_query).each do |tuple|
ApplicationRecord.connection.exec_query(working_time_query).each do |tuple|
tuple = tuple.merge({
'average_time' => format_time_difference(tuple['average_time']),
'stddev_time' => format_time_difference(tuple['stddev_time']),
@ -115,7 +115,7 @@ class ExecutionEnvironmentsController < ApplicationController
working_time_statistics[tuple['exercise_id'].to_i] = tuple
end
ApplicationRecord.connection.execute(user_query).each do |tuple|
ApplicationRecord.connection.exec_query(user_query).each do |tuple|
user_statistics[tuple['exercise_id'].to_i] = tuple
end