Skip to content

Commit e9ff138

Browse files
committed
Additional reports from AWS
1 parent fe5a439 commit e9ff138

8 files changed

Lines changed: 146 additions & 0 deletions
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Daily New Subscriptions Report
2+
3+
Compute the total amount of new subscriptions created per day for each tenant.
4+
5+
The snapshot view is: `v_report_new_subscriptions_daily`
6+
7+
## Report Creation
8+
9+
```
10+
curl -v \
11+
-X POST \
12+
-u admin:password \
13+
-H "X-Killbill-ApiKey:bob" \
14+
-H "X-Killbill-ApiSecret:lazar" \
15+
-H 'Content-Type: application/json' \
16+
-d '{"reportName": "report_new_subscriptions_daily",
17+
"reportType": "TIMELINE",
18+
"reportPrettyName": "Daily New Subscriptions",
19+
"sourceTableName": "report_new_subscriptions_daily",
20+
"refreshProcedureName": "refresh_report_new_subscriptions_daily",
21+
"refreshFrequency": "HOURLY"}' \
22+
"http://127.0.0.1:8080/plugins/killbill-analytics/reports"
23+
```
24+
25+
26+
## Sample Data
27+
28+
| Tenant Record Id | Slug | Day | Count |
29+
|------------------|------------------------------------|------------|-------|
30+
| 1 | blowdart-monthly-notrial-evergreen | 2025-08-20 | 9 |
31+
| 1 | pistol-monthly-notrial-evergreen | 2025-08-20 | 2 |
32+
| 1 | pistol-monthly-notrial-evergreen | 2025-09-01 | 5 |
33+
| 1 | blowdart-monthly-notrial-evergreen | 2025-09-02 | 6 |
34+
| 25 | gold-monthly-notrial-evergreen | 2025-09-02 | 5 |
35+
| 25 | silver-monthly-notrial-evergreen | 2025-09-03 | 6 |
36+
37+
38+
The first row in the above table indicates that on the date `2025-08-20`, the tenant with record id=1 had 9 new subscriptions created.
39+
40+
41+
## Report UI:
42+
43+
44+
![daily-new-subscriptions.png](daily-new-subscriptions.png)
143 KB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
create table report_new_subscriptions_daily as select * from v_report_new_subscriptions_daily limit 0;
2+
3+
drop procedure if exists refresh_report_new_subscriptions_daily;
4+
DELIMITER //
5+
CREATE PROCEDURE refresh_report_report_new_subscriptions_daily()
6+
BEGIN
7+
8+
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
9+
DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;
10+
11+
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
12+
START TRANSACTION;
13+
delete from report_new_subscriptions_daily;
14+
insert into report_new_subscriptions_daily select * from v_report_new_subscriptions_daily;
15+
COMMIT;
16+
17+
END;
18+
//
19+
DELIMITER ;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
create or replace view v_report_new_subscriptions_daily AS
2+
select ast.tenant_record_id AS tenant_record_id,
3+
ast.next_slug AS slug,
4+
date_format(ast.next_start_date,'%Y-%m-%d') AS day,
5+
count(0) AS count
6+
from analytics_subscription_transitions ast
7+
where ((1 = 1) and
8+
(ast.event = 'START_BILLING_BASE') and
9+
(ast.report_group = 'default')) group by
10+
ast.tenant_record_id,ast.next_slug,
11+
date_format(ast.next_start_date,'%Y-%m-%d')
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Overdue Accounts Summary Report
2+
3+
Breakdown of current vs. overdue accounts by tenant.
4+
5+
The snapshot view is: [v_report_overdue_account_summary](v_report_overdue_account_summary.ddl)
6+
7+
## Report Creation
8+
9+
```
10+
curl -v \
11+
-X POST \
12+
-u admin:password \
13+
-H "X-Killbill-ApiKey:bob" \
14+
-H "X-Killbill-ApiSecret:lazar" \
15+
-H 'Content-Type: application/json' \
16+
-d '{"reportName": "report_overdue_accounts_summary",
17+
"reportType": "COUNTERS",
18+
"reportPrettyName": "Overdue Accounts Summary",
19+
"sourceTableName": "report_overdue_accounts_summary",
20+
"refreshProcedureName": "refresh_report_overdue_accounts_summary",
21+
"refreshFrequency": "HOURLY"}' \
22+
"http://127.0.0.1:8080/plugins/killbill-analytics/reports"
23+
```
24+
25+
## Sample Data
26+
27+
| Tenant Record Id | Label | Count |
28+
|------------------|---------|-------|
29+
| 515 | Overdue | 5 |
30+
| 518 | Overdue | 1 |
31+
| 1 | Overdue | 74 |
32+
| 1 | Current | 23 |
33+
| 256 | Overdue | 3 |
34+
35+
36+
The first row in the above table indicates that the tenant with record id=1 had 5 accounts in the `Overdue` state.
37+
38+
## Report UI:
39+
40+
![overdue-accounts-summary.png](overdue-accounts-summary.png)
41+
42+
43+
104 KB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
create table report_overdue_accounts_summary as select * from v_report_overdue_accounts_summary limit 0;
2+
3+
drop procedure if exists refresh_report_overdue_accounts_summary;
4+
DELIMITER //
5+
CREATE PROCEDURE refresh_report_overdue_accounts_summary()
6+
BEGIN
7+
8+
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
9+
DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;
10+
11+
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
12+
START TRANSACTION;
13+
delete from report_overdue_accounts_summary;
14+
insert into report_overdue_accounts_summary select * from v_report_overdue_accounts_summary;
15+
COMMIT;
16+
17+
END;
18+
//
19+
DELIMITER ;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
create or replace view v_report_overdue_accounts_summary AS
2+
select a.tenant_record_id AS tenant_record_id,
3+
(case when (a.balance <= 0) then 'Current' else 'Overdue' end) AS label,
4+
count(0) AS count
5+
from analytics_accounts a
6+
where
7+
((1 = 1) and
8+
(a.report_group = 'default'))
9+
group by a.tenant_record_id,
10+
(case when (a.balance <= 0) then 'Current' else 'Overdue' end)

0 commit comments

Comments
 (0)