Skip to content

Instantly share code, notes, and snippets.

@wbotelhos
Created February 8, 2018 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wbotelhos/f0378fbeab67ca9fe7c53b65734c9603 to your computer and use it in GitHub Desktop.
Save wbotelhos/f0378fbeab67ca9fe7c53b65734c9603 to your computer and use it in GitHub Desktop.
Rating Debug Queries
total_count = "SELECT COUNT(DISTINCT resource_id) FROM reviews WHERE resource_type = 'Article' AND scopeable_type is NULL"
distinct_count = "SELECT COUNT(1) FROM reviews WHERE resource_type = 'Article' AND scopeable_type is NULL"
Review.find_by_sql("#{distinct_count}").as_json
Review.find_by_sql("#{total_count}").as_json
Review.find_by_sql("SELECT (CAST(0 AS DECIMAL(17, 14)) / 0) count_avg").as_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment