From b208dd63c1b9165711e6bbca587ba41d0281d7cf Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 1 Apr 2025 13:08:23 -0700 Subject: [PATCH] add cached word count to revision index --- Gemfile | 2 ++ Gemfile.lock | 2 ++ app/views/document_revisions/index.html.erb | 4 +++- db/schema.rb | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 9fea571b..7242b4dc 100644 --- a/Gemfile +++ b/Gemfile @@ -88,6 +88,8 @@ gem 'discordrb' # Smarts gem 'word_count_analyzer' +gem 'will_paginate', '~> 4.0' + # Workers gem 'sidekiq' gem 'redis' diff --git a/Gemfile.lock b/Gemfile.lock index df905df4..83233ed7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1682,6 +1682,7 @@ GEM websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + will_paginate (4.0.1) word_count_analyzer (1.0.1) engtagger zeitwerk (2.6.16) @@ -1760,6 +1761,7 @@ DEPENDENCIES uglifier (>= 1.3.0) web-console webpacker + will_paginate (~> 4.0) word_count_analyzer RUBY VERSION diff --git a/app/views/document_revisions/index.html.erb b/app/views/document_revisions/index.html.erb index 5a097563..8ca80ed2 100644 --- a/app/views/document_revisions/index.html.erb +++ b/app/views/document_revisions/index.html.erb @@ -10,6 +10,7 @@ Title Backed up + Word Count Actions @@ -18,13 +19,14 @@ <%= @document.title %> Latest version + <%= @document.cached_word_count %> <%= link_to 'Edit document', edit_document_path(@document), class: 'btn' %> <% @document_revisions.each do |document_revision| %> <%= document_revision.title %> <%= time_ago_in_words document_revision.created_at %> ago - + <%= document_revision.cached_word_count %> <%= link_to 'View', document_document_revision_path(id: document_revision.id), class: 'btn' %> <%= link_to 'Delete', document_document_revision_path(document: @document, id: document_revision.id), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn red lighten-5 red-text' %> diff --git a/db/schema.rb b/db/schema.rb index 974213c0..140c02de 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1938,6 +1938,7 @@ ActiveRecord::Schema.define(version: 2023_05_12_222601) do t.string "name", null: false t.string "type_of" t.text "description" + t.string "map" t.string "population" t.string "language" t.string "currency"