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

Add a one billing period free trial #149

Merged
merged 2 commits into from
Apr 17, 2024
Merged

Add a one billing period free trial #149

merged 2 commits into from
Apr 17, 2024

Conversation

smarlowucf
Copy link
Collaborator

This will run a empty metering on the first bill and archive the usage records. After the first billing period the adapter will begin billing usage as normal.

This will run a empty metering on the first bill and archive the
usage records. After the first billing period the adapter will
begin billing usage as normal.
Copy link
Contributor

@rtamalin rtamalin left a comment

Choose a reason for hiding this comment

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

LGTM

@smarlowucf
Copy link
Collaborator Author

This is hard coded to one billing period but could be easily extended to allow for a configurable trial period length.

@rtamalin
Copy link
Contributor

This is hard coded to one billing period but could be easily extended to allow for a configurable trial period length.

Yeah I noticed that. Would just have to have a means for passing in the value for the initialisation of the cache settings to pick it up...

Of course if the cache ever gets deleted and then recreated, it would result in an additional trial period, right?

@smarlowucf
Copy link
Collaborator Author

Of course if the cache ever gets deleted and then recreated, it would result in an additional trial period, right?

Yes. It would be the same issue even if the trial period were calculated from the adapter start date though. Since the start date is stored in the cache. It would get reset as well.

@smarlowucf smarlowucf changed the base branch from main to staging April 15, 2024 14:44
@smarlowucf
Copy link
Collaborator Author

Updated base to staging branch.

@rjschwei
Copy link
Contributor

I think we can add a second check on the length of the billing record history.

if cache.get('trial_remaining', 0) and len(get_metering_archive()) > 1:
   liar_liar_pants_on_fire()

where liar_liar_pants_on_fire, with a nicer name of course, propagates some message to the UI. We already have the UI propagation facility in place if I recall correctly.

@smarlowucf
Copy link
Collaborator Author

I think we can add a second check on the length of the billing record history.

if cache.get('trial_remaining', 0) and len(get_metering_archive()) > 1:
   liar_liar_pants_on_fire()

where liar_liar_pants_on_fire, with a nicer name of course, propagates some message to the UI. We already have the UI propagation facility in place if I recall correctly.

It would work as it is now with a trial period of 1. However, if the period was configurable we'd need another value trial_period_length to calculate archive > trial_period_length. For now it's fine though.

Do we want to mark the adapter status as "not compliant"? or only post a warning message?

@rjschwei
Copy link
Contributor

I think we can add a second check on the length of the billing record history.

if cache.get('trial_remaining', 0) and len(get_metering_archive()) > 1:
   liar_liar_pants_on_fire()

where liar_liar_pants_on_fire, with a nicer name of course, propagates some message to the UI. We already have the UI propagation facility in place if I recall correctly.

It would work as it is now with a trial period of 1. However, if the period was configurable we'd need another value trial_period_length to calculate archive > trial_period_length. For now it's fine though.

Do we want to mark the adapter status as "not compliant"? or only post a warning message?

We want "not compliant".

If archive exists raise error as free trial should be disabled.
Error is added to csp config to propagate adapter error to product.
@smarlowucf
Copy link
Collaborator Author

Added archive comparison. Adds error to csp config if archive exists and free trial is still active. In this case the adapter will ignore the free trial flag and bill as normal. The error will be available to products via csp config.

@rjschwei
Copy link
Contributor

Added archive comparison. Adds error to csp config if archive exists and free trial is still active. In this case the adapter will ignore the free trial flag and bill as normal. The error will be available to products via csp config.

Thanks, LGTM

@smarlowucf smarlowucf merged commit fd45bd8 into staging Apr 17, 2024
6 checks passed
@smarlowucf smarlowucf deleted the free-trial branch April 17, 2024 13:20
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.

3 participants