istox 0.1.98 → 0.1.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b20425ff9b96da28ae9fdf1c6b47c7159df66d16b67d8e2fff99d8ed1d750312
4
- data.tar.gz: a04b8779b0fa907bb8c58fcba28d26089836c1bfd6b055570d9222e57ebd530c
3
+ metadata.gz: 2485877c8909c883204a97adf7363c3c7a4448b2f6f8f1c057034164c9ffa0e3
4
+ data.tar.gz: 4f8a5c0c01e8023f52b0d14bf5022b04ed4d475919e9c1f0a81510e78e15948b
5
5
  SHA512:
6
- metadata.gz: f44c23b065a529e8403bae9317316e34d2c41b91a33356b60cc816c5b25ce04b7096a3c1bbffae58097b4995541622011014f826c5c6c1a2515cf774b4613347
7
- data.tar.gz: 8838d137671e85a48f18cd4b1d919bdd391f177e66ffcc64f97108dd014134a6d006e74bae944e1f2450b063225c7e71c2e66f5615741aa344d7ec6d705e2c73
6
+ metadata.gz: a113bf5ada59c04108ebd95c46b4d60bf24bbaa4f864dde10bf1a99c0c61d90e5ea528b163260bf074c2d684553ed60c7acb4d0319859ecf4edd00708c463b21
7
+ data.tar.gz: 86b2a11cc400ee880e0cf80c980f747a38928fbb400db37437fa4436eb993ac970da45c7351b9b1a91f5d217af808547d8c75996c3e771d1e0caed58f6ec5d79
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- istox (0.1.97)
4
+ istox (0.1.99)
5
5
  binding_of_caller
6
6
  bunny (>= 2.12.0)
7
7
  graphlient
@@ -13,6 +13,10 @@ module Istox
13
13
  is_numeric ? Time.at(input.to_i).to_datetime : Time.parse(input)
14
14
  end
15
15
 
16
+ def self.to_boolean(input)
17
+ !(input.blank? || input.to_s.downcase == 'false' || input.to_s.downcase == '0')
18
+ end
19
+
16
20
  def self.to_open_struct(model)
17
21
  return nil if model.blank?
18
22
 
@@ -5,6 +5,9 @@ module Istox
5
5
  query = filter(query: query, meta: meta) unless exclude_filter
6
6
  query = order(query: query, meta: meta) unless exclude_order
7
7
 
8
+ # if never set limit, means no pagination is needed
9
+ return OpenStruct.new(data: query.all, pagination: nil) if meta.limit.blank? || meta.limit.zero?
10
+
8
11
  return paginate(query: query, meta: meta) unless exclude_paginate
9
12
 
10
13
  query
@@ -15,7 +18,8 @@ module Istox
15
18
 
16
19
  meta.filters.each do |filter|
17
20
  # chain the query with AND conditions
18
- if filter.field.present?
21
+ # skip if there is no compare present, mean it is for inner filters
22
+ if filter.compare.present?
19
23
  validate_filter(filter)
20
24
  query = query.where("#{filter.field} #{transform_compare(filter.type, filter.compare)} ?",
21
25
  transform_value(filter.type, filter.value))
@@ -23,7 +27,7 @@ module Istox
23
27
 
24
28
  next if filter.filters.blank?
25
29
 
26
- # contains inner filters, chain the query with OR conditions
30
+ # contains inner filters, chain the query with AND condition but internally with OR condition
27
31
  columns = []
28
32
  values = []
29
33
  filter.filters.each do |inner_filter|
@@ -66,11 +70,11 @@ module Istox
66
70
  pagination: OpenStruct.new(
67
71
  page: current_page,
68
72
  limit: meta.limit,
69
- previous_page: current_page - 1,
70
- current_page: current_page,
71
- next_page: current_page < page_count ? current_page + 1 : 0,
72
- page_count: page_count,
73
- total_count: total
73
+ previousPage: current_page - 1,
74
+ currentPage: current_page,
75
+ nextPage: current_page < page_count ? current_page + 1 : 0,
76
+ pageCount: page_count,
77
+ totalCount: total
74
78
  )
75
79
  )
76
80
  end
@@ -108,7 +112,9 @@ module Istox
108
112
  compare
109
113
  end
110
114
 
115
+ # rubocop:disable Metrics/PerceivedComplexity
111
116
  def self.transform_value(type, value)
117
+ # rubocop:enable Metrics/PerceivedComplexity
112
118
  return value if value.blank? || type.blank? || type.downcase == 'string'
113
119
 
114
120
  return 'NULL' if type.downcase == 'nullable' && %w[null true yes].include?(type.downcase)
@@ -119,6 +125,8 @@ module Istox
119
125
 
120
126
  return value.to_f if type.downcase == 'float'
121
127
 
128
+ return ::Istox::CommonHelper.to_boolean(value) if type.downcase == 'boolean'
129
+
122
130
  return ::Istox::CommonHelper.to_datetime(value) if type.downcase == 'date' || type.downcase == 'datetime'
123
131
  end
124
132
 
data/lib/istox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.1.98'.freeze
2
+ VERSION = '0.1.100'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: istox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.98
4
+ version: 0.1.100
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-01 00:00:00.000000000 Z
11
+ date: 2019-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny