Merge master

This commit is contained in:
Michael Ball 2020-06-29 13:18:19 -07:00
commit a56a0e7547
2 changed files with 13 additions and 11 deletions

View file

@ -376,8 +376,8 @@ GEM
method_source (~> 0.8.1)
slop (~> 3.4)
public_suffix (3.1.1)
puma (3.12.4)
rack (2.0.8)
puma (3.12.6)
rack (2.1.4)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
@ -599,7 +599,7 @@ GEM
hashdiff
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
websocket-extensions (0.1.5)
whenever (0.10.0)
chronic (>= 0.6.3)
xpath (3.2.0)

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class UserDatatable < AjaxDatatablesRails::Base
@ -40,20 +41,21 @@ class UserDatatable < AjaxDatatablesRails::Base
# rubocop:disable Naming/AccessorMethodName
def get_raw_records
User.left_outer_joins(:registrations, :roles).select(
"DISTINCT users.id, users.name, users.email, users.confirmed_at, COUNT(CASE WHEN registrations.attended = 't' THEN 1 END) AS attended_count"
).group(
'users.id, users.name, users.email, users.confirmed_at'
)
User.left_outer_joins(:registrations, :roles)
.distinct
.select("users.*, COUNT(CASE WHEN registrations.attended = 't' THEN 1 END) AS attended_count")
.group('users.id')
end
# rubocop:enable Naming/AccessorMethodName
# Workaround for jbox-web/ajax-datatables-rails#293
def records_total_count
fetch_records.unscoped.count(:id)
fetch_records.unscope(:group, :select).count(:all)
end
# Workaround for jbox-web/ajax-datatables-rails#293
def records_filtered_count
filter_records(fetch_records).unscoped.count
filter_records(fetch_records).unscope(:group, :select).count(:all)
end
# ==== These methods represent the basic operations to perform on records