53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'app/controllers/concerns/queryable.rb', line 53
def apply_query_with_meta(scope)
config = query_config
meta = {}
base_scope = scope
base_scope = apply_filtering(base_scope) if config[:filtering][:enabled]
base_scope = apply_searching(base_scope) if config[:searching][:enabled]
base_scope = apply_sorting(base_scope) if config[:sorting][:enabled]
if config[:meta][:enabled]
meta[config[:meta][:total_key]] = base_scope.count
end
paginated_scope = base_scope
if config[:pagination][:enabled]
paginated_scope = (base_scope)
end
{
collection: paginated_scope,
meta: config[:meta][:enabled] ? meta : nil
}
end
|