Passed
Push — master ( 23b088...27bc68 )
by Ahmad
06:31
created

Queries.created_at_text()   A

Complexity

Conditions 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
dl 0
loc 9
rs 9.95
c 1
b 0
f 0
1
# frozen_string_literal: true
2
3
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
4
#
5
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
6
#
7
# This program is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU Lesser General Public License as published by the Free Software
9
# Foundation; either version 3.0 of the License, or (at your option) any later
10
# version.
11
#
12
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15
#
16
# You should have received a copy of the GNU Lesser General Public License along
17
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
18
19
module Queries
20
  extend ActiveSupport::Concern
21
22
  def created_at_text
23
    active_database = Rails.configuration.database_configuration[Rails.env]["adapter"]
24
    # Postgres requires created_at to be cast to a string
25
    if active_database == "postgresql"
26
      "created_at::text"
27
    else
28
      "created_at"
29
    end
30
  end
31
32
  def like_text
33
    active_database = Rails.configuration.database_configuration[Rails.env]["adapter"]
34
    # Use postgres case insensitive like
35
    if active_database == "postgresql"
36
      "ILIKE"
37
    else
38
      "LIKE"
39
    end
40
  end
41
end
42