aboutsummaryrefslogtreecommitdiff
path: root/src/guff/models/site.cr
blob: 9c8899a9b818bb727942507d8412b3d61568b293 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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