Created
November 25, 2008 18:41
-
-
Save tongueroo/29023 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
Article.find_by_sql("SELECT DISTINCT articles.* FROM articles INNER JOIN taggings ON taggings.taggable_id = articles.id WHERE taggings.tag_id = #{id} AND taggings.taggable_type = 'Article' AND articles.deleted_at IS NULL ORDER BY articles.id DESC LIMIT 5;") | |
## | |
Article.find_by_sql("SELECT DISTINCT articles.* FROM articles INNER JOIN taggings ON taggings.taggable_id = articles.id WHERE taggings.tag_id = #{id} AND taggings.taggable_type = 'Article' AND articles.deleted_at IS NULL ORDER BY articles.score DESC LIMIT 5;") | |
## | |
Article.find_by_sql(["SELECT DISTINCT articles.* FROM articles INNER JOIN taggings ON taggings.taggable_id = articles.id WHERE taggings.tag_id = #{id} AND taggings.taggable_type = 'Article' AND articles.deleted_at IS NULL AND articles.created_at > ? ORDER BY articles.comments_count DESC LIMIT 5;", 5.days.ago]) | |
## | |
Article.find_by_sql(["SELECT DISTINCT articles.* FROM articles INNER JOIN taggings ON taggings.taggable_id = articles.id WHERE taggings.tag_id = #{id} AND taggings.taggable_type = 'Article' AND articles.deleted_at IS NULL AND articles.created_at > ? ORDER BY articles.hit_count DESC LIMIT 5;", 5.days.ago]) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment