Updated subscriptionStats.js, to March and to skip over teacher subscriptions.
This commit is contained in:
parent
6f3f6d66ab
commit
77cc89a825
1 changed files with 10 additions and 8 deletions
|
@ -13,8 +13,8 @@ if(config.stripe.secretKey.indexOf('sk_test_')==0) {
|
||||||
stripe = require('stripe')(config.stripe.secretKey);
|
stripe = require('stripe')(config.stripe.secretKey);
|
||||||
|
|
||||||
var range = {
|
var range = {
|
||||||
gt: ''+(new Date('2015-02-01').getTime()/1000),
|
gt: ''+(new Date('2015-03-01').getTime()/1000),
|
||||||
lt: ''+(new Date('2015-03-01').getTime()/1000)
|
lt: ''+(new Date('2015-04-01').getTime()/1000)
|
||||||
};
|
};
|
||||||
|
|
||||||
begin = function(starting_after) {
|
begin = function(starting_after) {
|
||||||
|
@ -25,12 +25,14 @@ begin = function(starting_after) {
|
||||||
stripe.invoices.list(query, onInvoicesReceived);
|
stripe.invoices.list(query, onInvoicesReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
customersPaid = []
|
customersPaid = [];
|
||||||
|
|
||||||
onInvoicesReceived = function(err, invoices) {
|
onInvoicesReceived = function(err, invoices) {
|
||||||
for(var i in invoices.data) {
|
for(var i in invoices.data) {
|
||||||
var invoice = invoices.data[i];
|
var invoice = invoices.data[i];
|
||||||
if(!invoice.paid) { continue; }
|
if(!invoice.paid) { continue; }
|
||||||
|
if(!invoice.total) { continue; } // not paying anything!
|
||||||
|
//console.log(invoice);
|
||||||
customersPaid.push(invoice.customer);
|
customersPaid.push(invoice.customer);
|
||||||
}
|
}
|
||||||
if(invoices.has_more) {
|
if(invoices.has_more) {
|
||||||
|
@ -38,10 +40,10 @@ onInvoicesReceived = function(err, invoices) {
|
||||||
begin(invoices.data[i].id);
|
begin(invoices.data[i].id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log('How many customers paid for a subscription:', _.unique(customersPaid).length);
|
console.log('--- Actual active total customers:', _.unique(customersPaid).length);
|
||||||
loadNewCustomers();
|
loadNewCustomers();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
loadNewCustomers = function(starting_after) {
|
loadNewCustomers = function(starting_after) {
|
||||||
query = {created: range, limit: 100};
|
query = {created: range, limit: 100};
|
||||||
|
@ -49,7 +51,7 @@ loadNewCustomers = function(starting_after) {
|
||||||
query.starting_after = starting_after;
|
query.starting_after = starting_after;
|
||||||
}
|
}
|
||||||
stripe.customers.list(query, onCustomersReceived);
|
stripe.customers.list(query, onCustomersReceived);
|
||||||
}
|
};
|
||||||
|
|
||||||
newCustomersPaid = [];
|
newCustomersPaid = [];
|
||||||
|
|
||||||
|
@ -64,8 +66,8 @@ onCustomersReceived = function(err, customers) {
|
||||||
loadNewCustomers(customers.data[i].id);
|
loadNewCustomers(customers.data[i].id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log('How many new customers paid for a subscription:', newCustomersPaid.length);
|
console.log('--- Actual new customers:', newCustomersPaid.length);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
begin();
|
begin();
|
Reference in a new issue