1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-07 01:54:16 +01:00

(feat) add deleted_user param for open api users

This commit is contained in:
Du Peng 2023-10-30 08:08:35 +01:00
parent 0803eb0833
commit 614abec39e
4 changed files with 19 additions and 13 deletions

View File

@ -5,6 +5,7 @@
- Fix a bug: fix all failing tasks of rake task file chain.rake - 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 - 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: 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 - 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 - do not log Notifications#polling action anymore, by default, can be enable via env variable ENABLE_NOTIFICATIONS_POLLING_LOGGING=true

View File

@ -7,7 +7,9 @@ class OpenAPI::V1::UsersController < OpenAPI::V1::BaseController
expose_doc expose_doc
def index 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? if params[:email].present?
email_param = params[:email].is_a?(String) ? params[:email].downcase : params[:email].map(&:downcase) email_param = params[:email].is_a?(String) ? params[:email].downcase : params[:email].map(&:downcase)

View File

@ -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 :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 :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 :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 example <<-USERS
# /open_api/v1/users?page=1&per_page=4 # /open_api/v1/users?page=1&per_page=4
{ {

View File

@ -1,20 +1,22 @@
# frozen_string_literal: true # frozen_string_literal: true
json.extract! user, :id, :email, :created_at json.id user.user_id || user.id
json.extract! user.profile, :full_name, :first_name, :last_name if user.association(:profile).loaded? json.extract! user, :email, :full_name, :first_name, :last_name, :created_at
json.gender user.statistic_profile.gender ? 'man' : 'woman' if user.user
json.gender user.user.statistic_profile.gender ? 'man' : 'woman'
if user.association(:invoicing_profile).loaded? else
json.invoicing_profile_id user.invoicing_profile.id json.gender 'man'
json.external_id user.invoicing_profile.external_id
json.organization !user.invoicing_profile.organization.nil?
json.address user.invoicing_profile.invoicing_address
end 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 json.group do
if user.group_id? if user.user.group_id?
json.extract! user.group, :id, :name, :slug json.extract! user.user.group, :id, :name, :slug
else else
json.nil! json.nil!
end end