From 097dbd11dd2842a3e3af5365a6174eacc3344876 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Thu, 5 Feb 2015 15:24:59 -0800 Subject: [PATCH 1/2] Added a script for getting some subscription data more easily. --- scripts/analytics/subscriptionStats.js | 69 ++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 scripts/analytics/subscriptionStats.js diff --git a/scripts/analytics/subscriptionStats.js b/scripts/analytics/subscriptionStats.js new file mode 100644 index 000000000..ddc3c3697 --- /dev/null +++ b/scripts/analytics/subscriptionStats.js @@ -0,0 +1,69 @@ +// To use: set the range you want below, make sure your environment has the stripe key, then run: +// node scripts/analytics/subscriptions.js + +require('coffee-script'); +require('coffee-script/register'); +config = require('../../server_config'); +if(config.stripe.secretKey.indexOf('sk_test_')==0) { + throw new Error('You should not run this on the test data... Get your environment in gear.'); +} + +stripe = require('stripe')(config.stripe.secretKey); + +var range = { + gt: ''+(new Date('2015-01-01').getTime()/1000), + lt: ''+(new Date('2015-02-01').getTime()/1000) +}; + +begin = function(starting_after) { + var query = {date: range, limit: 100}; + if(starting_after) { + query.starting_after = starting_after; + } + stripe.invoices.list(query, onInvoicesReceived); +} + +customersPaid = [] + +onInvoicesReceived = function(err, invoices) { + for(var i in invoices.data) { + var invoice = invoices.data[i]; + if(!invoice.paid) { continue; } + customersPaid.push(invoice.customer); + } + if(invoices.has_more) { + console.log('Loaded', customersPaid.length, 'invoices.') + begin(invoices.data[i].id); + } + else { + console.log('How many customers paid for a subscription:', customersPaid.length); + loadNewCustomers(); + } +} + +loadNewCustomers = function(starting_after) { + query = {created: range, limit: 100}; + if(starting_after) { + query.starting_after = starting_after; + } + stripe.customers.list(query, onCustomersReceived); +} + +newCustomersPaid = []; + +onCustomersReceived = function(err, customers) { + for(var i in customers.data) { + var customer = customers.data[i]; + if(customersPaid.indexOf(customer.id) == -1) { continue; } + newCustomersPaid.push(customer.id); + } + if(customers.has_more) { + console.log('Loaded', newCustomersPaid.length, 'new customers.'); + loadNewCustomers(customers.data[i].id); + } + else { + console.log('How many new customers paid for a subscription:', newCustomersPaid.length); + } +} + +begin(); \ No newline at end of file From 3cbf11d404617604ebadbb6b65644032ceea4122 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Thu, 5 Feb 2015 15:40:33 -0800 Subject: [PATCH 2/2] Added a back button to hit campaign selector view. --- app/styles/play/campaign-view.sass | 19 ++++++++++++++++--- app/templates/play/campaign-view.jade | 4 ++++ app/views/play/CampaignView.coffee | 7 +++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/styles/play/campaign-view.sass b/app/styles/play/campaign-view.sass index a01a9a9d5..66e9ad6ef 100644 --- a/app/styles/play/campaign-view.sass +++ b/app/styles/play/campaign-view.sass @@ -448,6 +448,21 @@ $gameControlMargin: 30px &.vol-down .glyphicon.glyphicon-volume-down display: inline-block + #back-button + position: absolute + left: 70px + left: -webkit-calc(1% + 55px) + left: calc(1% + 55px) + top: 1% + padding: 3px 8px + @include opacity(0.75) + + &:hover + @include opacity(1.0) + + .glyphicon + font-size: 32px + #campaign-status position: absolute left: 0 @@ -539,10 +554,8 @@ $gameControlMargin: 30px .campaign-name, .levels-completed, .campaign-locked margin: 0 - color: rgb(232, 217, 87) + color: white text-shadow: black 2px 2px 0, black -2px -2px 0, black 2px -2px 0, black -2px 2px 0, black 2px 0px 0, black 0px -2px 0, black -2px 0px 0, black 0px 2px 0 - z-index: 30 - pointer-events: none .levels-completed font-size: 22px diff --git a/app/templates/play/campaign-view.jade b/app/templates/play/campaign-view.jade index 7b8a0c3fd..ee679fabc 100644 --- a/app/templates/play/campaign-view.jade +++ b/app/templates/play/campaign-view.jade @@ -108,6 +108,10 @@ button.btn.btn-lg.btn-inverse#volume-button(data-i18n="[title]play.adjust_volume .glyphicon.glyphicon-volume-down .glyphicon.glyphicon-volume-up +if campaign + .btn.btn-lg.btn-inverse#back-button(data-i18n="[title]resources.campaigns", title="Campaigns") + .glyphicon.glyphicon-globe + if campaign && campaign.loaded h1#campaign-status .campaign-status-background diff --git a/app/views/play/CampaignView.coffee b/app/views/play/CampaignView.coffee index cf64953ff..ad9dac8aa 100644 --- a/app/views/play/CampaignView.coffee +++ b/app/views/play/CampaignView.coffee @@ -46,6 +46,7 @@ module.exports = class CampaignView extends RootView 'click .level-info-container .start-level': 'onClickStartLevel' 'click .level-info-container .view-solutions': 'onClickViewSolutions' 'click #volume-button': 'onToggleVolume' + 'click #back-button': 'onClickBack' 'click .portal .campaign': 'onClickPortalCampaign' 'mouseenter .portals': 'onMouseEnterPortals' 'mouseleave .portals': 'onMouseLeavePortals' @@ -516,6 +517,12 @@ module.exports = class CampaignView extends RootView newI = 2 @updateVolume volumes[newI] + onClickBack: (e) -> + Backbone.Mediator.publish 'router:navigate', + route: "/play" + viewClass: CampaignView + viewArgs: [{supermodel: @supermodel}] + updateHero: -> return unless hero = me.get('heroConfig')?.thangType for slug, original of ThangType.heroes when original is hero