lint: uses sql keys on upcase

main
Washington Botelho 2018-01-14 22:30:31 -02:00
parent d163c74bcb
commit 4919da1f52
No known key found for this signature in database
GPG Key ID: BECE10A8106CC7A0
1 changed files with 6 additions and 6 deletions

View File

@ -23,7 +23,7 @@ module Rating
(#{total_count} / CAST(#{distinct_count} AS float)) count_avg, (#{total_count} / CAST(#{distinct_count} AS float)) count_avg,
COALESCE(AVG(value), 0) rating_avg COALESCE(AVG(value), 0) rating_avg
FROM #{rate_table_name} FROM #{rate_table_name}
WHERE resource_type = :resource_type and #{scope_type_query(scopeable)} WHERE resource_type = :resource_type AND #{scope_type_query(scopeable)}
).squish ).squish
execute_sql [sql, values] execute_sql [sql, values]
@ -43,9 +43,9 @@ module Rating
def values_data(resource, scopeable) def values_data(resource, scopeable)
scope_query = if scopeable.nil? scope_query = if scopeable.nil?
'scopeable_type is NULL and scopeable_id is NULL' 'scopeable_type is NULL AND scopeable_id is NULL'
else else
'scopeable_type = ? and scopeable_id = ?' 'scopeable_type = ? AND scopeable_id = ?'
end end
sql = %( sql = %(
@ -54,7 +54,7 @@ module Rating
COALESCE(SUM(value), 0) rating_sum, COALESCE(SUM(value), 0) rating_sum,
COUNT(1) rating_count COUNT(1) rating_count
FROM #{rate_table_name} FROM #{rate_table_name}
WHERE resource_type = ? and resource_id = ? and #{scope_query} WHERE resource_type = ? AND resource_id = ? AND #{scope_query}
).squish ).squish
values = [sql, resource.class.base_class.name, resource.id] values = [sql, resource.class.base_class.name, resource.id]
@ -97,7 +97,7 @@ module Rating
%(( %((
SELECT #{count} SELECT #{count}
FROM #{rate_table_name} FROM #{rate_table_name}
WHERE resource_type = :resource_type and #{scope_type_query(scopeable)} WHERE resource_type = :resource_type AND #{scope_type_query(scopeable)}
)) ))
end end