diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-09-21 09:57:14 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-09-21 09:57:14 +0530 |
commit | 244ec0a84c969454bfa05f66dedb22f2b1172323 (patch) | |
tree | ddcaf211d04f42e778bd8fe0cbf8daf53ca6fd4b /lib | |
parent | cc3adcd4bffe262f8581354b8190869f94ef17f2 (diff) | |
download | gitlab-ce-244ec0a84c969454bfa05f66dedb22f2b1172323.tar.gz |
Implement fourth round of comments from @DouweM.
- Pluralize summary titles
- Remove the `run_query` method - always return sql strings from the
`date_time_sql` methods
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/database/median.rb | 9 | ||||
-rw-r--r-- | lib/gitlab/database/util.rb | 12 |
2 files changed, 6 insertions, 15 deletions
diff --git a/lib/gitlab/database/median.rb b/lib/gitlab/database/median.rb index 5db05b98d5a..1444d25ebc7 100644 --- a/lib/gitlab/database/median.rb +++ b/lib/gitlab/database/median.rb @@ -10,7 +10,9 @@ module Gitlab mysql_median_datetime_sql(arel_table, query_so_far, column_sym) end - results = Array.wrap(median_queries).map { |query| Util.run_query(query) } + results = Array.wrap(median_queries).map do |query| + ActiveRecord::Base.connection.execute(query) + end extract_median(results).presence end @@ -46,7 +48,7 @@ module Gitlab Arel.sql("CREATE TEMPORARY TABLE IF NOT EXISTS #{query_so_far.to_sql}"), Arel.sql("set @ct := (select count(1) from #{arel_table.table_name});"), Arel.sql("set @row_id := 0;"), - query, + query.to_sql, Arel.sql("DROP TEMPORARY TABLE IF EXISTS #{arel_table.table_name};") ] end @@ -87,7 +89,8 @@ module Gitlab ) ) ). - with(query_so_far, cte) + with(query_so_far, cte). + to_sql end private diff --git a/lib/gitlab/database/util.rb b/lib/gitlab/database/util.rb deleted file mode 100644 index 12b68deae89..00000000000 --- a/lib/gitlab/database/util.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Gitlab - module Database - module Util - class << self - def run_query(query) - query = query.to_sql unless query.is_a?(String) - ActiveRecord::Base.connection.execute(query) - end - end - end - end -end |