aboutsummaryrefslogtreecommitdiff
path: root/src/guff/models
diff options
context:
space:
mode:
Diffstat (limited to 'src/guff/models')
-rw-r--r--src/guff/models/post.cr17
1 files changed, 16 insertions, 1 deletions
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