show bandwidth on dashboard, fix extra stats one_to_many, clarify stats retainent and fix typo

This commit is contained in:
Kyle Drake 2025-02-04 19:57:28 -06:00
parent 2dd1f55119
commit a81a708be5
5 changed files with 29 additions and 11 deletions

View file

@ -205,8 +205,6 @@ class Site < Sequel::Model
one_to_many :reports one_to_many :reports
one_to_many :reportings, key: :reporting_site_id, class: :Report one_to_many :reportings, key: :reporting_site_id, class: :Report
one_to_many :stats
one_to_many :events one_to_many :events
one_to_many :site_changes one_to_many :site_changes
@ -1903,6 +1901,16 @@ class Site < Sequel::Model
true true
end end
def maximum_monthly_bandwidth
PLAN_FEATURES[(parent? ? self : parent).plan_type.to_sym][:bandwidth].to_i
end
def monthly_bandwidth_used
stat = stats_dataset.order(:created_at.desc).select(:bandwidth).first
return 0 if stat.nil?
stat[:bandwidth]
end
private private
def store_file(path, uploaded, opts={}) def store_file(path, uploaded, opts={})

View file

@ -33,13 +33,16 @@
<a href="#" id="shareButton" class="btn-Action" data-container="body" data-toggle="popover" data-placement="bottom" data-content='<%== erb :'_share', layout: false, locals: {site: current_site} %>'><i class="fa fa-share-alt"></i> <span>Share</span></a> <a href="#" id="shareButton" class="btn-Action" data-container="body" data-toggle="popover" data-placement="bottom" data-content='<%== erb :'_share', layout: false, locals: {site: current_site} %>'><i class="fa fa-share-alt"></i> <span>Share</span></a>
</p> </p>
<ul> <ul>
<% if current_site.site_updated_at %> <% if current_site.site_updated_at %>
<li>Last updated <strong class="local-date-title" data-timestamp="<%= current_site.site_updated_at.to_i %>"><%= current_site.site_updated_at.ago.downcase %></strong></li> <li>Last updated <strong class="local-date-title" data-timestamp="<%= current_site.site_updated_at.to_i %>"><%= current_site.site_updated_at.ago.downcase %></strong></li>
<% end %> <% end %>
<li>Using <strong><%= current_site.space_percentage_used %>% (<%= current_site.total_space_used.to_space_pretty %>) of your <%= current_site.maximum_space.to_space_pretty %></strong>. <li>Using <strong><%= current_site.space_percentage_used %>% (<%= current_site.total_space_used.to_space_pretty %>)</strong> of your <strong><%= current_site.maximum_space.to_space_pretty %></strong> storage.
<br> <br>
<% unless current_site.is_education || current_site.supporter? %>Need more space? <a href="/supporter">Become a Supporter!</a><% end %></li> <li>
<li><strong><%= current_site.views.format_large_number %></strong> views</li> Used <strong><%= current_site.monthly_bandwidth_used.to_bytes_pretty %></strong> of bandwidth this month.
<br>
<% unless current_site.is_education || current_site.supporter? %>Need more space? <a href="/supporter">Become a Supporter!</a><% end %>
</li>
</ul> </ul>
</div> </div>

View file

@ -160,7 +160,7 @@
<li><a href="?days=sincethebigbang">All time</a></li> <li><a href="?days=sincethebigbang">All time</a></li>
</ul> </ul>
<% else %> <% else %>
<p>(<a href="/supporter">Upgrade</a> to see up to see stats for all time)</p> <p>Stats for free sites are retained for <%= Stat::FREE_RETAINMENT_DAYS %> days. <a href="/supporter">Become a supporter</a> to start retaining stats for all time.</p>
<% end %> <% end %>
<% end %> <% end %>

View file

@ -114,6 +114,13 @@
<td><i class="fa fa-check"></i></td> <td><i class="fa fa-check"></i></td>
</tr> </tr>
--> -->
<tr>
<td class="feature-column">
<span data-original-title="How long views and hits are tracked for your site. Free sites are limited to <%= Stat::FREE_RETAINMENT_DAYS %> days.">Site Stats History</span>
</td>
<td></td>
<td><i class="fa fa-check"></i></td>
</tr>
<tr> <tr>
<td class="feature-column"> <td class="feature-column">
<span data-original-title="You can mount your Neocities site to your computer as a hard drive, making it easy to update with your favorite HTML editor.">WebDAV Uploading</span> <span data-original-title="You can mount your Neocities site to your computer as a hard drive, making it easy to update with your favorite HTML editor.">WebDAV Uploading</span>

View file

@ -78,7 +78,7 @@
Upgrade for $<%= Site::PLAN_FEATURES[:supporter][:price] %>/mo Upgrade for $<%= Site::PLAN_FEATURES[:supporter][:price] %>/mo
</a> </a>
<br> <br>
or pay with <strong><a href="/supporter/paypal" style="color: #00308a; text-decoration: underline;"><span style="color: #00308a">Pay</span><span style="color: #029be1">Pal</span></a></strong> or <strong><a href="/supporter/bitcoin" style="color: #f79319; text-decoration: underline;">Bitcoin</a></strong> or pay with <strong><a href="/supporter/paypal" style="color: #00308a; text-decoration: underline;"><span style="color: #00308a">Pay</span><span style="color: #029be1">Pal</span></a></strong>
</div> </div>
</form> </form>
</div> </div>