36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'app/services/lesli_audit/user_service.rb', line 36
def registrations
group = query[:group]
group = "month"
period = group unless group.blank?
group_by = "DATE_TRUNC('month', created_at)" if group == 'month'
group_by = "DATE_TRUNC('week', created_at)" if group == 'week'
group_by = "DATE_TRUNC('day', created_at)" if group == 'day'
if ActiveRecord::Base.connection.adapter_name == "SQLite"
group_by = "strftime('%Y-%m', created_at)"
end
registrations = []
if ["day", "week", "month", "year"].include?(period)
registrations = current_user.account.users
.group(group_by)
.count.map do |request|
{
:date => request[0],
:count => request[1]
}
end
end
registrations
end
|