mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
(feat) add deleted_user param for open api users
This commit is contained in:
parent
0803eb0833
commit
614abec39e
@ -5,6 +5,7 @@
|
||||
- Fix a bug: fix all failing tasks of rake task file chain.rake
|
||||
- Fix a bug: file_size_validator.rb was broken since ruby v3, see https://github.com/rails/rails/issues/41270
|
||||
- improvement: pre-registration event reservations ilimit places
|
||||
- improvement: add deleted_user param for open api users
|
||||
- decreases sidekiq concurrency from 25 to 5, 25 is too much and consumes memory for nothing
|
||||
- do not log Notifications#polling action anymore, by default, can be enable via env variable ENABLE_NOTIFICATIONS_POLLING_LOGGING=true
|
||||
|
||||
|
@ -7,7 +7,9 @@ class OpenAPI::V1::UsersController < OpenAPI::V1::BaseController
|
||||
expose_doc
|
||||
|
||||
def index
|
||||
@users = User.order(created_at: :desc).includes(:group, :profile, :invoicing_profile)
|
||||
@users = InvoicingProfile.order(created_at: :desc).includes(user: %i[group profile statistic_profile])
|
||||
|
||||
@users = @users.where.not(user_id: nil) if params[:deleted_user].blank?
|
||||
|
||||
if params[:email].present?
|
||||
email_param = params[:email].is_a?(String) ? params[:email].downcase : params[:email].map(&:downcase)
|
||||
|
@ -18,6 +18,7 @@ class OpenAPI::V1::UsersDoc < OpenAPI::V1::BaseDoc
|
||||
param :email, [String, Array], optional: true, desc: 'Filter users by *email* using strict matching.'
|
||||
param :user_id, [Integer, Array], optional: true, desc: 'Filter users by *id* using strict matching.'
|
||||
param :created_after, DateTime, optional: true, desc: 'Filter users to accounts created after the given date.'
|
||||
param :deleted_user, [true, false], optional: true, desc: 'Filter users to accounts deleted or not.'
|
||||
example <<-USERS
|
||||
# /open_api/v1/users?page=1&per_page=4
|
||||
{
|
||||
|
@ -1,20 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
json.extract! user, :id, :email, :created_at
|
||||
json.extract! user.profile, :full_name, :first_name, :last_name if user.association(:profile).loaded?
|
||||
json.gender user.statistic_profile.gender ? 'man' : 'woman'
|
||||
|
||||
if user.association(:invoicing_profile).loaded?
|
||||
json.invoicing_profile_id user.invoicing_profile.id
|
||||
json.external_id user.invoicing_profile.external_id
|
||||
json.organization !user.invoicing_profile.organization.nil?
|
||||
json.address user.invoicing_profile.invoicing_address
|
||||
json.id user.user_id || user.id
|
||||
json.extract! user, :email, :full_name, :first_name, :last_name, :created_at
|
||||
if user.user
|
||||
json.gender user.user.statistic_profile.gender ? 'man' : 'woman'
|
||||
else
|
||||
json.gender 'man'
|
||||
end
|
||||
|
||||
if user.association(:group).loaded?
|
||||
json.invoicing_profile_id user.id
|
||||
json.external_id user.external_id
|
||||
json.organization !user.organization.nil?
|
||||
json.address user.invoicing_address
|
||||
|
||||
if user&.user&.group
|
||||
json.group do
|
||||
if user.group_id?
|
||||
json.extract! user.group, :id, :name, :slug
|
||||
if user.user.group_id?
|
||||
json.extract! user.user.group, :id, :name, :slug
|
||||
else
|
||||
json.nil!
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user