New subscriptions per month
<%=
line_chart [
{ name: "Early Adopters", data: Subscription.where(billing_plan_id: 3).group_by_month(:start_date) },
{ name: "Monthly", data: Subscription.where(billing_plan_id: 4).group_by_month(:start_date) },
{ name: "Tri-monthly", data: Subscription.where(billing_plan_id: 5).group_by_month(:start_date) },
{ name: "Yearly", data: Subscription.where(billing_plan_id: 6).group_by_month(:start_date) },
]
%>
Cancelled subscriptions per month
<%=
line_chart [
{ name: "Early Adopters", data: Subscription.where(billing_plan_id: 3).where('end_date < ?', Date.current).group_by_month(:end_date) },
{ name: "Monthly", data: Subscription.where(billing_plan_id: 4).where('end_date < ?', Date.current).group_by_month(:end_date) },
{ name: "Tri-monthly", data: Subscription.where(billing_plan_id: 5).where('end_date < ?', Date.current).group_by_month(:end_date) },
{ name: "Yearly", data: Subscription.where(billing_plan_id: 6).where('end_date < ?', Date.current).group_by_month(:end_date) },
]
%>
Per plan
Early adopters
<%=
line_chart [
{ name: "Started", data: Subscription.where(billing_plan_id: 3).group_by_month(:start_date) },
{ name: "Cancelled", data: Subscription.where(billing_plan_id: 3).where('end_date < ?', Date.current).group_by_month(:end_date) }
]
%>
Monthly
<%=
line_chart [
{ name: "Started", data: Subscription.where(billing_plan_id: 4).group_by_month(:start_date) },
{ name: "Cancelled", data: Subscription.where(billing_plan_id: 4).where('end_date < ?', Date.current).group_by_month(:end_date) }
]
%>
Tri-monthly
<%=
line_chart [
{ name: "Started", data: Subscription.where(billing_plan_id: 5).group_by_month(:start_date) },
{ name: "Cancelled", data: Subscription.where(billing_plan_id: 5).where('end_date < ?', Date.current).group_by_month(:end_date) }
]
%>
Yearly
<%=
line_chart [
{ name: "Started", data: Subscription.where(billing_plan_id: 6).group_by_month(:start_date) },
{ name: "Cancelled", data: Subscription.where(billing_plan_id: 6).where('end_date < ?', Date.current).group_by_month(:end_date) }
]
%>