diff --git a/app/models/users/user.rb b/app/models/users/user.rb index db14d393..12ca3c8b 100644 --- a/app/models/users/user.rb +++ b/app/models/users/user.rb @@ -184,6 +184,10 @@ class User < ApplicationRecord Rails.application.config.content_types[:all].select { |c| can_create? c } end + def words_written_today + word_count_updates.where(created_at: Time.current.beginning_of_day..Time.current.end_of_day).sum(:word_count) + end + # as_json creates a hash structure, which you then pass to ActiveSupport::json.encode to actually encode the object as a JSON string. # This is different from to_json, which converts it straight to an escaped JSON string, # which is undesireable in a case like this, when we want to modify it diff --git a/app/views/main/components/_create_new_page_list.html.erb b/app/views/main/components/_create_new_page_list.html.erb index a66b7dc2..b467d60e 100644 --- a/app/views/main/components/_create_new_page_list.html.erb +++ b/app/views/main/components/_create_new_page_list.html.erb @@ -2,10 +2,10 @@ <% (@activated_content_types + ["Timeline", "Document"]).each do |content_type| %> <% klass = content_class_from_name(content_type) %> <%= link_to send("new_#{content_type.downcase}_path") do %> -