Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix remaining trial days calculation #15470

Merged
merged 11 commits into from
Feb 12, 2020
Merged

Conversation

gonzaloriestra
Copy link
Contributor

@gonzaloriestra gonzaloriestra commented Feb 10, 2020

Related to https://github.com/CartoDB/support/issues/1997, #15046

  • Do not show the banner with the trial reminder the supposed end date is over
    (the account should be locked or paying in that case)
  • Keep remaining_trial_days as 0 when the trial ends (it was showing negative numbers)
  • Round up the remaining days as we do in Central in order to be consistent with the billing page
  • Small refactor and removed old MAGELLAN/PERSONAL30 logic, as we don't have any active trials with those plans

@alrocar alrocar self-assigned this Feb 10, 2020
Copy link
Contributor

@alrocar alrocar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One doubt and one comment. Let's discuss if we tackle them as part of this PR or what :)

app/models/carto/user.rb Show resolved Hide resolved
app/models/user.rb Show resolved Hide resolved
@alrocar alrocar assigned gonzaloriestra and unassigned alrocar Feb 10, 2020
@alrocar
Copy link
Contributor

alrocar commented Feb 11, 2020

I still see some weird numbers, i.e. gonzalor-individual-test in staging:

  • Main page: 5 days
  • Profile page: -5 days
  • Billing page: 0 days (this comes from central so I assume it can't be wrong in staging)

@alrocar alrocar assigned gonzaloriestra and unassigned alrocar Feb 11, 2020
@gonzaloriestra
Copy link
Contributor Author

@alrocar I think it was missing the bump in package.json. I've also added some other improvements I made in the free plan branch. It's already deployed in staging.

@alrocar
Copy link
Contributor

alrocar commented Feb 12, 2020

Tested in staging with the owayss user I can see:

  • 7 hours remaining in the main page
  • 0 days remaining in the profile page
  • 1 day remaining in the billing page

😅

@gonzaloriestra
Copy link
Contributor Author

@alrocar the problem is that there were many ways to calculate the difference in days... I've updated the frontend views to do it the same way as in backend (ceil). It's deployed in Staging.

@@ -14,7 +14,7 @@

<script>
import { mapState } from 'vuex';
import distanceInWordsStrict from 'date-fns/distance_in_words_strict';
import moment from 'moment';
import WelcomeCompact from './WelcomeCompact';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that you can use differenceInCalendarDays from date-fns instead of importing the whole moment library. I think it does the ceiling for you https://date-fns.org/v1.29.0/docs/differenceInCalendarDays Can you try it out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've tested it, but it's doing round instead of ceil, and it's not configurable... So I'm leaving it with moment for the moment :D

> differenceInCalendarDays('2020-02-12T22:00:00', '2020-02-12T08:00:00');
0

@@ -1,4 +1,4 @@
<% if current_user.trial_user? %>
<% if current_user.show_trial_reminder? %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much clearer this way!!

@alrocar
Copy link
Contributor

alrocar commented Feb 12, 2020

I tested it in staging and it works like a charm ✨

@gonzaloriestra I leave it assigned to you, deploy when you consider.

@gonzaloriestra gonzaloriestra merged commit 4da9ce8 into master Feb 12, 2020
@gonzaloriestra gonzaloriestra deleted the fix-remaining-trial-days branch February 12, 2020 13:01
@gonzaloriestra gonzaloriestra restored the fix-remaining-trial-days branch February 12, 2020 13:48
@gonzaloriestra gonzaloriestra deleted the fix-remaining-trial-days branch February 12, 2020 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants