model_driven_api 3.2.9 → 3.2.10
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fbc1608cd8d9b131868990f8944579ebb29c38b741eb7ccd5a9648dec3778e2
|
4
|
+
data.tar.gz: f01fd64b659acd78457d1b1ff437739172dd5d79ca4cd5f236e0e9fd8bc7323d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8809fca597c152adaa6e1c78cb5d6c9866bc912dcd38bc66245af6bce78210d6c409d9bc028b3d01a9c0bd1fbe801af8ee88811c81adb01a59aa9878564070f
|
7
|
+
data.tar.gz: 33809d4606db5d854df3f1381b1639391df88813e7a377a59adcd17aeba6b9110cbd12bc2b62883a63d9792cd8df4bb2a29056b45a6ca7a3ca61eef5c7c07704
|
@@ -23,28 +23,27 @@ class Api::V2::ApplicationController < ActionController::API
|
|
23
23
|
# Keeping this automation can be too dangerous and lead to unpredicted results
|
24
24
|
# TODO: Remove it
|
25
25
|
# @q = (@model.column_names.include?("user_id") ? @model.where(user_id: current_user.id) : @model).ransack(@query.presence|| params[:q])
|
26
|
+
Rails.logger.debug("Querying for #{@model} with #{@query}: #{@query.presence || params[:q]}")
|
26
27
|
@q = @model.ransack(@query.presence || params[:q])
|
27
|
-
@records_all = @q.result # (distinct: true) Removing, but I'm not sure, with it I cannot sort in postgres for associated records (throws an exception on misuse of sort with distinct)
|
28
28
|
page = (@page.presence || params[:page])
|
29
29
|
per = (@per.presence || params[:per])
|
30
30
|
# pages_info = (@pages_info.presence || params[:pages_info])
|
31
31
|
count = (@count.presence || params[:count])
|
32
|
+
@records_count = @q.result.count
|
33
|
+
@records_all = @q.result
|
32
34
|
# Pagination
|
33
|
-
@records = @
|
35
|
+
@records = @q.result.page(page).per(per) # (distinct: true) Removing, but I'm not sure, with it I cannot sort in postgres for associated records (throws an exception on misuse of sort with distinct)
|
34
36
|
# Content-Range: posts 0-4/27
|
35
37
|
range_start = [(page.to_i - 1) * per.to_i, 0].max
|
36
38
|
range_end = [0, page.to_i * per.to_i - 1].max
|
37
39
|
response.set_header("Content-Range", "#{@model.table_name} #{range_start}-#{range_end}/#{@records.total_count}")
|
38
40
|
|
39
|
-
# If there's the keyword pagination_info, then return a pagination info object
|
40
|
-
# return render json: {count: @records_all.count,current_page_count: @records.count,next_page: @records.next_page,prev_page: @records.prev_page,is_first_page: @records.first_page?,is_last_page: @records.last_page?,is_out_of_range: @records.out_of_range?,pages_count: @records.total_pages,current_page_number: @records.current_page } if !pages_info.blank?
|
41
|
-
|
42
41
|
# puts "ALL RECORDS FOUND: #{@records_all.inspect}"
|
43
|
-
status = @
|
42
|
+
status = @records_count.zero? ? 404 : 200
|
44
43
|
# puts "If it's asked for page number, then paginate"
|
45
44
|
return render json: @records.as_json(json_attrs), status: status if !page.blank? # (@json_attrs || {})
|
46
45
|
#puts "if you ask for count, then return a json object with just the number of objects"
|
47
|
-
return render json: { count: @
|
46
|
+
return render json: { count: @records_count } if !count.blank?
|
48
47
|
#puts "Default"
|
49
48
|
json_out = @records_all.as_json(json_attrs)
|
50
49
|
#puts "JSON ATTRS: #{json_attrs}"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_driven_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-04 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: thecore_backend_commons
|