MCPcopy Index your code
hub / github.com/codecombat/codecombat / premiumEndDate

Method premiumEndDate

app/models/User.js:555–576  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

553 }
554
555 premiumEndDate () {
556 if (!this.isPremium()) { return null }
557 let stripeEnd
558 const stripe = this.get('stripe')
559 if (stripe) {
560 if (stripe.free === true) { return $.t('subscribe.forever') }
561 if (stripe.sponsorID) { return $.t('subscribe.forever') }
562 if (stripe.subscriptionID) { return $.t('subscribe.forever') }
563 if (_.isString(stripe.free)) { stripeEnd = moment(stripe.free) }
564 }
565
566 const products = this.get('products')
567 if (products) {
568 const homeProducts = this.activeProducts('basic_subscription')
569 const {
570 endDate,
571 } = _.max(homeProducts, p => new Date(p.endDate))
572 const productsEnd = moment(endDate)
573 if (stripeEnd && stripeEnd.isAfter(productsEnd)) { return stripeEnd.utc().format('ll') }
574 return productsEnd.utc().format('ll')
575 }
576 }
577
578 isPremium () {
579 if (this.isInGodMode()) { return true }

Callers

nothing calls this directly

Calls 3

isPremiumMethod · 0.95
getMethod · 0.95
activeProductsMethod · 0.95

Tested by

no test coverage detected