profitable 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3487fdc62384e3d5900e96c7642b10d44a2d701406677702b8608585f1fd3a5
4
- data.tar.gz: e455302bf61fc7aa7aa0f0f369406bb3fd24ebc3e9b13e56516eb89fb5508990
3
+ metadata.gz: 506d907bbcbaa811d4986d49fffdc7f1874c77528fb99996f49621834a15e263
4
+ data.tar.gz: 6e37aaa616a3238b85cacfd4d3b9373781b4632fb4e4e36ad7946a8d71fa066e
5
5
  SHA512:
6
- metadata.gz: b0b107c91d16eabd6867b6bb4eafc0392272a41e6380f4c1f02be690f97f994fa4cb6a17d900ab930316ec0e682b391b6d36807d041387680e81e92a8150d774
7
- data.tar.gz: 3116c70c4ba0257c59939da5ac83a10a841df147eaba9d8a1980bb7a2e7b1103ab4cbc15317461809ad3927cf5ffd612151a7538e3cfa34bdb47364c0f96bf60
6
+ metadata.gz: aafa273d6430cd1e4c30dada038bdc83a9ecacec8c2d9be0f9f6bad642dc818399dbb494876244eb50c96c1aa3af7932ef43f56e839ab11a8b8f036a375f822f
7
+ data.tar.gz: 7dca54330874ae397c77b2400364429509dffc5de96a2096fe963984455ff4c46e67849c5305218086684beb7b1d5300815f49af252ba9e875c028c42b717c1a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # `profitable`
2
2
 
3
+ ## [0.2.3] - 2024-09-01
4
+
5
+ - Fix the `time_to_next_mrr_milestone` estimation and make it accurate to the day
6
+
3
7
  ## [0.2.2] - 2024-09-01
4
8
 
5
9
  - Improve MRR calculations with prorated churned and new MRR (hopefully fixes bad churned MRR calculations)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Profitable
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
data/lib/profitable.rb CHANGED
@@ -104,13 +104,18 @@ module Profitable
104
104
  next_milestone = MRR_MILESTONES.find { |milestone| milestone > current_mrr }
105
105
  return "Congratulations! You've reached the highest milestone." unless next_milestone
106
106
 
107
- growth_rate = calculate_mrr_growth_rate
108
- return "Unable to calculate. Need more data or positive growth." if growth_rate <= 0
107
+ monthly_growth_rate = calculate_mrr_growth_rate / 100
108
+ return "Unable to calculate. Need more data or positive growth." if monthly_growth_rate <= 0
109
109
 
110
- months_to_milestone = (Math.log(next_milestone.to_f / current_mrr) / Math.log(1 + growth_rate)).ceil
111
- days_to_milestone = months_to_milestone * 30
110
+ # Convert monthly growth rate to daily growth rate
111
+ daily_growth_rate = (1 + monthly_growth_rate) ** (1.0 / 30) - 1
112
112
 
113
- return "#{days_to_milestone} days left to $#{number_with_delimiter(next_milestone)} MRR (#{(Time.current + days_to_milestone.days).strftime('%b %d, %Y')})"
113
+ # Calculate the number of days to reach the next milestone
114
+ days_to_milestone = (Math.log(next_milestone.to_f / current_mrr) / Math.log(1 + daily_growth_rate)).ceil
115
+
116
+ target_date = Time.current + days_to_milestone.days
117
+
118
+ "#{days_to_milestone} days left to $#{number_with_delimiter(next_milestone)} MRR (#{target_date.strftime('%b %d, %Y')})"
114
119
  end
115
120
 
116
121
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: profitable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - rameerez