Skip to content

Commit

Permalink
Free Trials: Add comment about calculating progress in the trial
Browse files Browse the repository at this point in the history
  • Loading branch information
Tug authored and drewblaisdell committed Dec 22, 2015
1 parent 5a122ae commit f4eb05f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/lib/plans/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function getCurrentTrialPeriodInDays( plan ) {
}

return userFacingExpiryMoment.diff( subscribedMoment, 'days' );
}
};

export function getDaysUntilUserFacingExpiry( plan ) {
const { userFacingExpiryMoment } = plan;
Expand Down
18 changes: 17 additions & 1 deletion client/my-sites/plans/plan-overview/plan-status/progress.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,29 @@ const PlanStatusProgress = React.createClass( {
plan: React.PropTypes.object.isRequired
},

/*
* |------------------------trialPeriodInDays (17 days)-------------------|
* plan.subscribedDate (datetime) plan.userFacingExpiry (day) plan.expiry (day)
* |-----------------------------------------|----gracePeriod (3 days)----|
* | | |
* -> Today before user facing expiry:
* today
* | |-----timeUntilExpiryInDays-----| |
* -> Today is in grace period:
* today
* | | |-timeUntilExpiryInDays-|
* -> Today is after trial period in days:
* today
* | | |
* timeUntilExpiryInDays = 0
*/
renderProgressBar() {
const { plan } = this.props,
// we strip the hour/minute/second/millisecond data here from `subscribed_date` to match `expiry`
trialPeriodInDays = getCurrentTrialPeriodInDays( plan ),
timeUntilExpiryInDays = isInGracePeriod( plan )
? Math.max( getDaysUntilExpiry( plan ), 0 )
: getDaysUntilUserFacingExpiry( plan ),
// set minimum progress to 0.5 to show that the trial started immediately
progress = Math.max( 0.5, trialPeriodInDays - timeUntilExpiryInDays );

return (
Expand Down

0 comments on commit f4eb05f

Please sign in to comment.