grape-listing 1.4.4 → 1.4.6

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: 8d68023502cf4ff8d9d97d33f5d9d1ec539244fe15b5705302e865b97b6bb309
4
- data.tar.gz: da6aab0fbd6e24a3f7339761df1d84e7b0a8515a92bc6078594b6ed93cd0ff61
3
+ metadata.gz: c6edf5f40b3f9e87da8699d958cc6938f681a9f0b0383ced05d067cbc9703176
4
+ data.tar.gz: 1e0038d81fd51dd43fc7c9443568d4d12fa52b24f39fad1aa7ec045f27611691
5
5
  SHA512:
6
- metadata.gz: 5e0e21aa3440b7c03bab828ea4733b90e11925c1831d72c26fa1f402a6c487ed902ba72c8a6aa1cd854d20a271bf969629d0be456c5cfa7ef8a5c3675752b551
7
- data.tar.gz: 25118b2d164d61e0233046ad06e47795a104e7e70b916f9d33430db4146bcf65f31569dbb7e86b77029236388c60e4f6344b84973f37206f377e34d4e2bec01f
6
+ metadata.gz: 936556382a09a06bd0450cb2808ae13893554d905a5ceb9a3b361817192f447b06190a7c2429611c19f117e252c421c4b497ef6167952cdb91ef61a890299086
7
+ data.tar.gz: ab714fcfbeef853743da5c3d200a3ac2f93ebf3f690f323ade42fafaaa8e4f97e0acc888e15a43043e97f521a559d2fe8ac905b5b3d06b5837501165cdfcc6e8
@@ -1,3 +1,3 @@
1
1
  module GrapeListing
2
- VERSION = '1.4.4'.freeze
2
+ VERSION = '1.4.6'.freeze
3
3
  end
@@ -33,7 +33,7 @@ module GrapeListing
33
33
  @limit = @params['limit'] || 20
34
34
 
35
35
  # проверка максимального значения лимита
36
- if @limit.to_i > 100
36
+ if @limit.to_i > 500
37
37
  raise StandardError.new('Лимит слишком большой')
38
38
  end
39
39
 
@@ -6,7 +6,7 @@ module GrapeListing
6
6
  def sort_proc
7
7
  # проверка необходимости нестандартной сортировки
8
8
  if !@sortable.is_a?(Array) || @sortable.empty? || custom_sorting_field.blank?
9
- return proc { order('id DESC NULLS LAST') }
9
+ return proc { order('id desc') }
10
10
  end
11
11
 
12
12
  @sort_order = @params['sort_order'] || 'desc'
@@ -16,7 +16,8 @@ module GrapeListing
16
16
  direction = @sort_order
17
17
  proc { send(sorting_scope, direction) }
18
18
  else
19
- query = Arel.sql("#{custom_sorting_field} #{@sort_order} NULLS LAST")
19
+ nulls_order = @sort_order.to_s.downcase == 'desc' ? 'LAST' : 'FIRST'
20
+ query = Arel.sql("#{custom_sorting_field} #{@sort_order} NULLS #{nulls_order}")
20
21
  proc { order(query) }
21
22
  end
22
23
  end
@@ -100,10 +100,9 @@ module GrapeListing
100
100
  model_cols = @model.columns_hash
101
101
 
102
102
  spreadsheet_cols.each do |column|
103
- # поиск описания среди комментариев к таблице БД
104
- db_col = model_cols[column.to_s]
105
- if db_col&.comment&.present?
106
- values << db_col.comment
103
+ # исключение: колонка с ИД
104
+ if column.to_s == 'id'
105
+ values << 'ИД'
107
106
  next
108
107
  end
109
108
 
@@ -114,6 +113,13 @@ module GrapeListing
114
113
  next
115
114
  end
116
115
 
116
+ # поиск описания среди комментариев к таблице БД
117
+ db_col = model_cols[column.to_s]
118
+ if db_col&.comment&.present?
119
+ values << db_col.comment
120
+ next
121
+ end
122
+
117
123
  # ничего из вышеперечисленного не найдено, заголовок - название самой колонки
118
124
  values << column.upcase
119
125
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-listing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Павел Бабин
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-24 00:00:00.000000000 Z
11
+ date: 2025-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack