From 94529553ac724a11b6821dd1374c98b0f51b4f14 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Tue, 8 Mar 2016 23:22:03 -0500 Subject: initial page rendering --- src/guff/models/post.cr | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/guff/models') diff --git a/src/guff/models/post.cr b/src/guff/models/post.cr index 580a9b7..3c4212b 100644 --- a/src/guff/models/post.cr +++ b/src/guff/models/post.cr @@ -96,6 +96,12 @@ module Guff clause: "a.post_id", }, + "slug": { + default: true, + sortable: true, + clause: "a.slug", + }, + "name": { default: true, sortable: true, @@ -103,7 +109,7 @@ module Guff }, "body": { - default: false, + default: true, sortable: true, clause: "a.body", }, @@ -215,6 +221,10 @@ module Guff strftime('%s', a.posted_at) + 0 = %d )" + SLUG_FILTER_CLAUSE = "( + a.slug = '%s' + )" + private def get_filter_clause( filters : Hash(Symbol, String) ) : String @@ -236,6 +246,11 @@ module Guff # TODO end + # add slug filter + if filters.has_key?(:slug) + r << SLUG_FILTER_CLAUSE % [@db.quote(filters[:slug])] + end + # return result r.join(" AND ") end -- cgit v1.2.3