VRFS-5690 - tag jamtrack and jammers separetly on admin report
This commit is contained in:
parent
9b17546082
commit
c0031cfe3d
|
|
@ -25,13 +25,12 @@ from users where users.created_at >= '2024-11-01' AND users.created_at < '2025-0
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
ActiveAdmin.register_page "Subscription Cohorts" do
|
ActiveAdmin.register_page "Jammers Subscription Cohorts" do
|
||||||
menu :parent => 'Reports'
|
menu :parent => 'Reports'
|
||||||
|
|
||||||
|
content :title => "Jammers Subscription Cohorts" do
|
||||||
content :title => "Subscription Cohorts" do
|
|
||||||
h2 "Users Grouped By Month as Paying Subscribers"
|
h2 "Users Grouped By Month as Paying Subscribers"
|
||||||
table_for User.select(%Q{date_trunc('month', created_at) as month,
|
table_for User.select(%Q{date_trunc('month', users.created_at) as month,
|
||||||
count(id) as total,
|
count(id) as total,
|
||||||
count(first_downloaded_client_at) as downloaded,
|
count(first_downloaded_client_at) as downloaded,
|
||||||
count(first_ran_client_at) as ran_client,
|
count(first_ran_client_at) as ran_client,
|
||||||
|
|
@ -42,7 +41,19 @@ ActiveAdmin.register_page "Subscription Cohorts" do
|
||||||
count(first_invited_at) as invited,
|
count(first_invited_at) as invited,
|
||||||
count(first_friended_at) as friended,
|
count(first_friended_at) as friended,
|
||||||
count(first_subscribed_at) as subscribed
|
count(first_subscribed_at) as subscribed
|
||||||
}).group("date_trunc('month', created_at)").order("date_trunc('month', created_at) DESC") do |row|
|
})
|
||||||
|
.joins(%Q{LEFT JOIN LATERAL (
|
||||||
|
SELECT
|
||||||
|
j.created_at
|
||||||
|
FROM
|
||||||
|
jam_track_rights as j
|
||||||
|
WHERE
|
||||||
|
j.user_id = users.id
|
||||||
|
ORDER BY
|
||||||
|
j.created_at
|
||||||
|
LIMIT 1 -- Select only that single row
|
||||||
|
) j ON (j.created_at - users.created_at) >= INTERVAL '2 hours' })
|
||||||
|
.group("date_trunc('month', users.created_at)").order("date_trunc('month', users.created_at) DESC") do |row|
|
||||||
column "Month", Proc.new { |user| user.month.strftime('%B %Y') }
|
column "Month", Proc.new { |user| user.month.strftime('%B %Y') }
|
||||||
column "Total", :total
|
column "Total", :total
|
||||||
column "Subscribed", Proc.new { |user| raw(Spacer.spacer(user.subscribed, user)) }
|
column "Subscribed", Proc.new { |user| raw(Spacer.spacer(user.subscribed, user)) }
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
class Spacer
|
||||||
|
def self.spacer(val, row)
|
||||||
|
|
||||||
|
percentage = ((val * 100) / row.total.to_f).round(1).to_s
|
||||||
|
('%-5.5s' % percentage).gsub(' ', ' ') + '% - ' + val.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
=begin
|
||||||
|
select
|
||||||
|
count(id) as total,
|
||||||
|
count(first_downloaded_client_at) as downloaded,
|
||||||
|
count(first_ran_client_at) as ran_client,
|
||||||
|
count(first_certified_gear_at) as ftue,
|
||||||
|
count(first_music_session_at) as any_session,
|
||||||
|
count(first_real_music_session_at) as real_session,
|
||||||
|
count(first_good_music_session_at) as good_session,
|
||||||
|
count(first_invited_at) as invited,
|
||||||
|
count(first_friended_at) as friended,
|
||||||
|
count(first_subscribed_at) as subscribed
|
||||||
|
from users where users.created_at >= '2024-11-01' AND users.created_at < '2025-04-01'
|
||||||
|
|
||||||
|
select first_name, last_name, email
|
||||||
|
from users where users.created_at >= '2024-11-01' AND users.created_at < '2025-04-01'
|
||||||
|
AND first_music_session_at is NULL;
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
ActiveAdmin.register_page "JamTrack Subscription Cohorts" do
|
||||||
|
menu :parent => 'Reports'
|
||||||
|
|
||||||
|
content :title => "JamTrack Subscription Cohorts" do
|
||||||
|
h2 "Users Grouped By Month as Paying Subscribers"
|
||||||
|
table_for User.select(%Q{date_trunc('month', users.created_at) as month,
|
||||||
|
count(id) as total,
|
||||||
|
count(first_downloaded_client_at) as downloaded,
|
||||||
|
count(first_ran_client_at) as ran_client,
|
||||||
|
count(first_certified_gear_at) as ftue,
|
||||||
|
count(first_music_session_at) as any_session,
|
||||||
|
count(first_real_music_session_at) as real_session,
|
||||||
|
count(first_good_music_session_at) as good_session,
|
||||||
|
count(first_invited_at) as invited,
|
||||||
|
count(first_friended_at) as friended,
|
||||||
|
count(first_subscribed_at) as subscribed
|
||||||
|
})
|
||||||
|
.joins(%Q{INNER JOIN LATERAL (
|
||||||
|
SELECT
|
||||||
|
j.created_at
|
||||||
|
FROM
|
||||||
|
jam_track_rights as j
|
||||||
|
WHERE
|
||||||
|
j.user_id = users.id
|
||||||
|
ORDER BY
|
||||||
|
j.created_at
|
||||||
|
LIMIT 1 -- Select only that single row
|
||||||
|
) j ON (j.created_at - users.created_at) < INTERVAL '2 hours' })
|
||||||
|
.group("date_trunc('month', users.created_at)").order("date_trunc('month', users.created_at) DESC") do |row|
|
||||||
|
column "Month", Proc.new { |user| user.month.strftime('%B %Y') }
|
||||||
|
column "Total", :total
|
||||||
|
column "Subscribed", Proc.new { |user| raw(Spacer.spacer(user.subscribed, user)) }
|
||||||
|
column "Downloaded", Proc.new { |user| raw(Spacer.spacer(user.downloaded, user)) }
|
||||||
|
column "Ran Client", Proc.new { |user| raw(Spacer.spacer(user.ran_client, user)) }
|
||||||
|
column "FTUE", Proc.new { |user| raw(Spacer.spacer(user.ftue, user)) }
|
||||||
|
column "Any Session", Proc.new { |user| raw(Spacer.spacer(user.any_session, user)) }
|
||||||
|
column "2+ Session", Proc.new { |user| raw(Spacer.spacer(user.real_session, user)) }
|
||||||
|
column "Good Session", Proc.new { |user| raw(Spacer.spacer(user.good_session, user)) }
|
||||||
|
column "Invited", Proc.new { |user| raw(Spacer.spacer(user.invited, user)) }
|
||||||
|
column "Friended", Proc.new { |user| raw(Spacer.spacer(user.friended, user)) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue