summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-09-21 09:57:14 +0530
committerTimothy Andrew <mail@timothyandrew.net>2016-09-21 09:57:14 +0530
commit244ec0a84c969454bfa05f66dedb22f2b1172323 (patch)
treeddcaf211d04f42e778bd8fe0cbf8daf53ca6fd4b /lib
parentcc3adcd4bffe262f8581354b8190869f94ef17f2 (diff)
downloadgitlab-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.rb9
-rw-r--r--lib/gitlab/database/util.rb12
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