aboutsummaryrefslogtreecommitdiff
path: root/src/guff/models/site.cr
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-03-08 17:12:46 -0500
committerPaul Duncan <pabs@pablotron.org>2016-03-08 17:12:46 -0500
commitd5f49eee6c08bda1dad31bc906f54e44737e843f (patch)
tree0aa984fb37197112c396de10ffbf4a05dc8ee041 /src/guff/models/site.cr
parent8989c5b2601028f575211d7443c7c082b122079e (diff)
downloadold-guff-d5f49eee6c08bda1dad31bc906f54e44737e843f.tar.bz2
old-guff-d5f49eee6c08bda1dad31bc906f54e44737e843f.zip
mv src/guff/{,models/}*-model.cr
Diffstat (limited to 'src/guff/models/site.cr')
-rw-r--r--src/guff/models/site.cr27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/guff/models/site.cr b/src/guff/models/site.cr
new file mode 100644
index 0000000..9c8899a
--- /dev/null
+++ b/src/guff/models/site.cr
@@ -0,0 +1,27 @@
+module Guff
+ class SiteModel < Model
+ SQL = TemplateCache.new({
+ get_default: "
+ SELECT site_id
+ FROM sites
+ WHERE is_default
+ LIMIT 1
+ ",
+ })
+
+ def initialize(models : Models)
+ super(models, SQL)
+ end
+
+ def get_default : Int
+ r = one(:get_default, nil, {} of String => String)
+ raise "no default site" unless r
+ r.to_i
+ end
+
+ def to_site(host : String?) : Int
+ # TODO
+ get_default
+ end
+ end
+end