diff --git a/app/controllers/data_controller.rb b/app/controllers/data_controller.rb index ac5737f4..f42eef7e 100644 --- a/app/controllers/data_controller.rb +++ b/app/controllers/data_controller.rb @@ -140,6 +140,9 @@ class DataController < ApplicationController @share_link = "https://www.notebook.ai/?referral=#{current_user.referral_code.code}" end + def green + end + private def set_sidenav_expansion diff --git a/app/services/green_service.rb b/app/services/green_service.rb index e6e39fea..73440ba9 100644 --- a/app/services/green_service.rb +++ b/app/services/green_service.rb @@ -1,53 +1,54 @@ class GreenService < Service AVERAGE_WORDS_PER_PAGE = 500 AVERAGE_TIMELINE_EVENTS_PER_PAGE = 3 + SHEETS_OF_PAPER_PER_TREE = 15_000 - def physical_pages_equivalent_for(worldbuilding_page_type) + def self.physical_pages_equivalent_for(worldbuilding_page_type) # TODO: This would be better estimated with [average] word counts from pages (or a real total), # but we don't have that data computed (and definitely don't want to do so on each page load). # Until we have a better solution, these page counts come from printing out notebook pages - # from http://www.notebook-paper.com/ + # from http://www.notebook-paper.com/ case worldbuilding_page_type - when "Universe" then 2 * Universe.last.id - when "Character" then 8 * Character.last.id - when "Location" then 4 * Location.last.id - when "Item" then 2 * Item.last.id - when "Building" then 8 * Building.last.id - when "Condition" then 4 * Condition.last.id - when "Continent" then 6 * Continent.last.id - when "Country" then 5 * Country.last.id - when "Creature" then 8 * Creature.last.id - when "Deity" then 5 * Deity.last.id - when "Flora" then 4 * Flora.last.id - when "Food" then 5 * Food.last.id - when "Government" then 6 * Government.last.id - when "Group" then 4 * Group.last.id - when "Job" then 4 * Job.last.id - when "Landmark" then 3 * Landmark.last.id - when "Language" then 5 * Language.last.id - when "Lore" then 10 * Lore.last.id - when "Magic" then 4 * Magic.last.id - when "Planet" then 6 * Planet.last.id - when "Race" then 4 * Race.last.id - when "Religion" then 3 * Religion.last.id - when "Scene" then 2 * Scene.last.id - when "School" then 6 * School.last.id - when "Sport" then 4 * Sport.last.id - when "Technology" then 4 * Technology.last.id - when "Town" then 4 * Town.last.id - when "Tradition" then 3 * Tradition.last.id - when "Vehicle" then 4 * Vehicle.last.id + when "Universe" then 2 + when "Character" then 8 + when "Location" then 4 + when "Item" then 2 + when "Building" then 8 + when "Condition" then 4 + when "Continent" then 6 + when "Country" then 5 + when "Creature" then 8 + when "Deity" then 5 + when "Flora" then 4 + when "Food" then 5 + when "Government" then 6 + when "Group" then 4 + when "Job" then 4 + when "Landmark" then 3 + when "Language" then 5 + when "Lore" then 10 + when "Magic" then 4 + when "Planet" then 6 + when "Race" then 4 + when "Religion" then 3 + when "Scene" then 2 + when "School" then 6 + when "Sport" then 4 + when "Technology" then 4 + when "Town" then 4 + when "Tradition" then 3 + when "Vehicle" then 4 else raise "Unknown green estimate: #{worldbuilding_page_type}" end end - def total_document_pages_equivalent + def self.total_document_pages_equivalent (Document.with_deleted.sum(:cached_word_count) / AVERAGE_WORDS_PER_PAGE.to_f).to_i end - def total_timeline_pages_equivalent + def self.total_timeline_pages_equivalent (TimelineEvent.last.id / AVERAGE_TIMELINE_EVENTS_PER_PAGE.to_f).to_i end end \ No newline at end of file diff --git a/app/views/data/green.html.erb b/app/views/data/green.html.erb new file mode 100644 index 00000000..4169a552 --- /dev/null +++ b/app/views/data/green.html.erb @@ -0,0 +1,176 @@ +
| Digital content | +Equivalent physical pages | +Equivalent trees | +
|---|---|---|
| + + <%= content_class_from_name(content_type).icon %> + + <%= pluralize content_list_count, content_type.pluralize %> + | ++ copy_all + <%= pluralize physical_page_equivalent, 'page' %> + | ++ park + <%= pluralize tree_equivalent.round(5), 'tree' %> + | +
| Totals | ++ + copy_all + <%= pluralize total_pages_equivalent, 'page' %> + + | ++ + park + <%= pluralize total_pages_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE.round(5), 'tree' %> + saved + + | +
Across all Notebook.ai pages...
+| Digital content | +Equivalent physical pages | +Equivalent trees | +
|---|---|---|
| + + <%= content_class_from_name(content_type).icon %> + + <%= pluralize content_list_count, content_type.pluralize %> + | ++ copy_all + <%= pluralize physical_page_equivalent, 'page' %> + | ++ park + <%= pluralize tree_equivalent.round(5), 'tree' %> + | +
| Totals | ++ + copy_all + <%= pluralize total_pages_equivalent, 'page' %> + + | ++ + park + <%= pluralize total_pages_equivalent.to_f / GreenService::SHEETS_OF_PAPER_PER_TREE.round(5), 'tree' %> + saved + + | +
+ How many trees have you saved by switching to digital? +
+