app/views/data/green.html.erb
<h4 class="white-text">
<%= link_to data_vault_path, class: 'grey-text tooltipped', style: 'position: relative; top: 4px;', data: {
position: 'bottom',
enterDelay: '500',
tooltip: "Back to your Data Vault"
} do %>
<i class="material-icons blue-text text-lighten-3">arrow_back</i>
<% end %>
Your paper footprint
</h4>
<%
total_pages_equivalent = 0
%>
<div class="row">
<div class="col s12">
<div class="card-panel">
All of the added functionality of Notebook.ai over a traditional paper notebook isn't the only benefit of going digital. Backing your ideas up in the cloud
instead of on paper also saves trees!
</div>
</div>
<div class="col s12">
<div class="card">
<div class="card-content">
<div class="card-title">Your personal paper footprint</div>
<table>
<thead>
<tr>
<th>Digital content</th>
<th>Equivalent physical pages</th>
<th>Equivalent trees</th>
</tr>
</thead>
<tbody>
<% @current_user_content.each do |content_type, content_list| %>
<%
content_list_count = content_list.count
physical_page_equivalent = case content_type
when 'Timeline'
GreenService::AVERAGE_TIMELINE_EVENTS_PER_PAGE * TimelineEvent.where(timeline_id: content_list.map(&:id)).count
when 'Document'
[
content_list.inject(0) { |sum, doc| sum + (doc.cached_word_count || 0) } / GreenService::AVERAGE_WORDS_PER_PAGE.to_f,
content_list_count
].max
else
GreenService.physical_pages_equivalent_for(content_type) * content_list_count
end
tree_equivalent = physical_page_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE
total_pages_equivalent += physical_page_equivalent
%>
<tr>
<td>
<i class="material-icons left <%= content_class_from_name(content_type).color %>-text">
<%= content_class_from_name(content_type).icon %>
</i>
<%= pluralize content_list_count, content_type.pluralize %>
</td>
<td>
<i class="material-icons left grey-text">copy_all</i>
<%= number_with_delimiter physical_page_equivalent %>
<%= 'page'.pluralize physical_page_equivalent %>
</td>
<td>
<i class="material-icons left green-text">park</i>
<%= pluralize tree_equivalent.round(5), 'tree' %>
</td>
</tr>
<% end %>
<tr>
<td>Totals</td>
<td>
<strong>
<i class="material-icons left grey-text">copy_all</i>
<%= number_with_delimiter total_pages_equivalent.round %>
<%= 'page'.pluralize total_pages_equivalent %>
</strong>
</td>
<td>
<strong>
<i class="material-icons left green-text">park</i>
<% trees_saved = total_pages_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE %>
<%= number_with_delimiter trees_saved.round(5) %>
<%= 'tree'.pluralize trees_saved %>
saved
</strong>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<%
total_pages_equivalent = 0
%>
<div class="row">
<div class="col s12">
<div class="card">
<div class="card-content">
<div class="card-title">Our community paper footprint</div>
<p>Across all Notebook.ai pages...</p>
<table>
<thead>
<tr>
<th>Digital content</th>
<th>Equivalent physical pages</th>
<th>Equivalent trees</th>
</tr>
</thead>
<tbody>
<% (Rails.application.config.content_type_names[:all] + ["Timeline", "Document"]).each do |content_type| %>
<%
content_list_count = content_class_from_name(content_type).last.try(:id) || 0
physical_page_equivalent = case content_type
when 'Timeline'
GreenService.total_timeline_pages_equivalent
when 'Document'
GreenService.total_document_pages_equivalent
else
GreenService.physical_pages_equivalent_for(content_type) * content_list_count
end
tree_equivalent = physical_page_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE
total_pages_equivalent += physical_page_equivalent
%>
<tr>
<td>
<i class="material-icons left <%= content_class_from_name(content_type).color %>-text">
<%= content_class_from_name(content_type).icon %>
</i>
<%= number_with_delimiter content_list_count %>
<%= content_type.pluralize content_list_count %>
</td>
<td>
<i class="material-icons left grey-text">copy_all</i>
<%= number_with_delimiter physical_page_equivalent %>
<%= 'page'.pluralize physical_page_equivalent %>
</td>
<td>
<i class="material-icons left green-text">park</i>
<%= number_with_delimiter tree_equivalent.round(5) %>
<%= 'tree'.pluralize tree_equivalent %>
</td>
</tr>
<% end %>
<tr>
<td>Totals</td>
<td>
<strong>
<i class="material-icons left grey-text">copy_all</i>
<%= number_with_delimiter total_pages_equivalent %>
<%= 'page'.pluralize total_pages_equivalent %>
</strong>
</td>
<td>
<strong>
<i class="material-icons left green-text">park</i>
<% trees_saved = total_pages_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE %>
<%= number_with_delimiter trees_saved.round(5) %>
<%= 'tree'.pluralize trees_saved %>
saved
</strong>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>