Class: Users::RoleServices

Inherits:
Lesli::ApplicationLesliService
  • Object
show all
Defined in:
app/services/lesli_audit/users/role_services.rb

Instance Method Summary collapse

Instance Method Details

#indexHash

Returns Paginated list of the records.

Parameters:

  • Has (query)

    of the formated queries/filters that will be applied to filter data

Returns:

  • (Hash)

    Paginated list of the records



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/services/lesli_audit/users/role_services.rb', line 41

def index 
    current_user..roles
    .joins("
        inner join (
            select 
                role_id, 
                count(1) as users 
            from user_roles ur 
            group by role_id
        ) ur
        on ur.role_id = roles.id "
    ).select(
        "roles.id",
        "roles.name",
        "roles.active",
        "roles.object_level_permission",
        "ur.users"
    )
end