rework some mysql-specific stuff, closes #4090

Change-Id: I6791f124aae5caf2c5a3d5cd2b36dce60657d7ca
Reviewed-on: https://gerrit.instructure.com/2843
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
This commit is contained in:
Jon Jensen 2011-03-28 12:26:12 -06:00
parent 3f7057e251
commit 471267deb9
2 changed files with 5 additions and 11 deletions

View File

@ -160,12 +160,10 @@ class CoursesController < ApplicationController
@range_end = Date.tomorrow
query = "SELECT COUNT(id), SUM(size) FROM attachments WHERE context_id=%s AND context_type='Course' AND root_attachment_id IS NULL AND file_state != 'deleted'"
res = ActiveRecord::Base.connection.execute(query % [@context.id])
row = res.fetch_row
row = ActiveRecord::Base.connection.select_rows(query % [@context.id]).first
@file_count, @files_size = [row[0].to_i, row[1].to_i]
query = "SELECT COUNT(id), SUM(max_size) FROM media_objects WHERE context_id=%s AND context_type='Course' AND attachment_id IS NULL AND workflow_state != 'deleted'"
res = ActiveRecord::Base.connection.execute(query % [@context.id])
row = res.fetch_row
row = ActiveRecord::Base.connection.select_rows(query % [@context.id]).first
@media_file_count, @media_files_size = [row[0].to_i, row[1].to_i]
if params[:range] && params[:date]

View File

@ -222,8 +222,7 @@ class CountsReport
def last_activity(account_id)
query = "SELECT max(created_at) FROM #{PageView.table_name} WHERE account_id = #{account_id}"
res = ActiveRecord::Base.connection.execute(query)
res.fetch_row[0] rescue nil
ActiveRecord::Base.connection.select_value(query)
end
def get_course_ids(account, course_ids)
@ -237,14 +236,11 @@ class CountsReport
end
def get_count_from_query(query)
res = ActiveRecord::Base.connection.execute(query)
res.fetch_row[0].to_i
ActiveRecord::Base.connection.select_value(query).to_i
end
def get_count_and_size_from_query(query)
res = ActiveRecord::Base.connection.execute(query)
row = res.fetch_row
[row[0].to_i, row[1].to_i]
ActiveRecord::Base.connection.select_rows(query).first.map(&:to_i)
end
def should_use_default_account_course(course)