29 lines
750 B
Ruby
29 lines
750 B
Ruby
class Admin::InvitationsController < Admin::BaseController
|
|
before_action :set_current_section
|
|
|
|
def index
|
|
@username = params[:username].presence
|
|
accepted_scope = Invitation.used.order('used_at desc')
|
|
unused_scope = Invitation.unused
|
|
|
|
if @username
|
|
accepted_scope = accepted_scope.joins(:user).where(users: { cn: @username })
|
|
unused_scope = unused_scope.joins(:user).where(users: { cn: @username })
|
|
end
|
|
|
|
@pagy, @invitations_used = pagy(accepted_scope)
|
|
|
|
@stats = {
|
|
available: unused_scope.count,
|
|
accepted: accepted_scope.count,
|
|
users_with_referrals: accepted_scope.distinct.count(:user_id)
|
|
}
|
|
end
|
|
|
|
private
|
|
|
|
def set_current_section
|
|
@current_section = :invitations
|
|
end
|
|
end
|