mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
add goals to stats
This commit is contained in:
parent
d112290b3b
commit
1d9c71b9f8
2 changed files with 42 additions and 4 deletions
21
app/stats.rb
21
app/stats.rb
|
@ -1,5 +1,5 @@
|
||||||
get '/stats/?' do
|
get '/stats/?' do
|
||||||
expires 14400, :public, :must_revalidate # 4 hours
|
expires 14400, :public, :must_revalidate if self.class.production? # 4 hours
|
||||||
|
|
||||||
@stats = {
|
@stats = {
|
||||||
total_sites: Site.count,
|
total_sites: Site.count,
|
||||||
|
@ -38,7 +38,7 @@ get '/stats/?' do
|
||||||
|
|
||||||
customers = Stripe::Customer.all limit: 100000
|
customers = Stripe::Customer.all limit: 100000
|
||||||
|
|
||||||
@stats[:total_recurring_revenue] = 0.0
|
@stats[:monthly_revenue] = 0.0
|
||||||
|
|
||||||
subscriptions = []
|
subscriptions = []
|
||||||
@stats[:cancelled_subscriptions] = 0
|
@stats[:cancelled_subscriptions] = 0
|
||||||
|
@ -62,11 +62,26 @@ get '/stats/?' do
|
||||||
sub[:amount] = (sub[:amount] / 12).round(2)
|
sub[:amount] = (sub[:amount] / 12).round(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
@stats[:total_recurring_revenue] += sub[:amount]
|
@stats[:monthly_revenue] += sub[:amount]
|
||||||
|
|
||||||
subscriptions.push sub
|
subscriptions.push sub
|
||||||
end
|
end
|
||||||
|
|
||||||
@stats[:subscriptions] = subscriptions
|
@stats[:subscriptions] = subscriptions
|
||||||
|
|
||||||
|
# Hotwired for now
|
||||||
|
@stats[:expenses] = 300.0 #/mo
|
||||||
|
@stats[:percent_until_profit] = (
|
||||||
|
(@stats[:monthly_revenue].to_f / @stats[:expenses]) * 100
|
||||||
|
)
|
||||||
|
|
||||||
|
@stats[:poverty_threshold] = 11_945
|
||||||
|
@stats[:poverty_threshold_percent] = (@stats[:monthly_revenue].to_f / (@stats[:poverty_threshold] + @stats[:expenses])) * 100
|
||||||
|
|
||||||
|
# http://en.wikipedia.org/wiki/Poverty_threshold
|
||||||
|
|
||||||
|
@stats[:average_developer_salary] = 93_280.00 # google "average developer salary"
|
||||||
|
@stats[:percent_until_developer_salary] = (@stats[:monthly_revenue].to_f / (@stats[:average_developer_salary] + @stats[:expenses])) * 100
|
||||||
|
|
||||||
erb :'stats'
|
erb :'stats'
|
||||||
end
|
end
|
|
@ -68,7 +68,7 @@
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h2>Supporters</h2>
|
<h2>Supporters</h2>
|
||||||
<h3>Current Recurring Monthly Revenue: <strong><%= format("$%.2f", @stats[:total_recurring_revenue]) %> (<%= format("$%.2f", @stats[:total_recurring_revenue]*12) %>/year)</strong>
|
<h3>Current Recurring Monthly Revenue: <strong><%= format("$%.2f", @stats[:monthly_revenue]) %> (<%= format("$%.2f", @stats[:monthly_revenue]*12) %>/year)</strong>
|
||||||
<br>
|
<br>
|
||||||
Active Supporters: <strong><%= @stats[:subscriptions].select {|s| s[:status] == 'active' }.length %></strong>
|
Active Supporters: <strong><%= @stats[:subscriptions].select {|s| s[:status] == 'active' }.length %></strong>
|
||||||
<br>
|
<br>
|
||||||
|
@ -91,7 +91,30 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<h2>Burn Rate</h2>
|
||||||
<p>
|
<p>
|
||||||
|
Approximate server expenses (burn rate): <strong><%= format("$%.2f", @stats[:expenses]) %>/mo</strong>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h1>Revenue Goals</h1>
|
||||||
|
|
||||||
|
<p>Neocities pays for itself:</p>
|
||||||
|
<p><strong><%= format '%.2f', @stats[:percent_until_profit] %>% of goal</strong> ($<%= format('%.2f', @stats[:monthly_revenue]) %> / $<%= format('%.2f', @stats[:expenses]) %>)</p>
|
||||||
|
<div class="progress progress-striped">
|
||||||
|
<div class="bar" style="width: <%= @stats[:percent_until_profit].round %>%;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>Neocities earnings rise above <a href="http://en.wikipedia.org/wiki/Poverty_threshold">US poverty threshold</a>:</p>
|
||||||
|
<p><strong><%= format '%.2f', @stats[:poverty_threshold_percent] %>% of goal</strong> ($<%= format('%.2f', @stats[:monthly_revenue]) %> / $<%= format('%.2f', @stats[:poverty_threshold]) %> + $<%= @stats[:expenses] %>)</p>
|
||||||
|
<div class="progress progress-striped">
|
||||||
|
<div class="bar" style="width: <%= format('%.2f', @stats[:poverty_threshold_percent]) %>%;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>Neocities earns average US developer salary:</p>
|
||||||
|
<p><strong><%= format '%.2f', @stats[:percent_until_developer_salary] %>% of goal</strong> ($<%= format('%.2f', @stats[:monthly_revenue]) %> / $<%= format('%.2f', @stats[:average_developer_salary]) %> + $<%= @stats[:expenses] %>)</p>
|
||||||
|
<div class="progress progress-striped">
|
||||||
|
<div class="bar" style="width: <%= format('%.2f', @stats[:percent_until_developer_salary]) %>%;"></div>
|
||||||
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
Loading…
Add table
Reference in a new issue