bible270 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7867bb4de49fe177447a5f7b1cfa9fa031e1926cdb8c4c73f2071eb8a7620c82
4
- data.tar.gz: '0499e0931abdd3890f07945f7fc82f6de8dc5da1a156fbb8147e1b5b2be79596'
3
+ metadata.gz: f8c170757c087fab1698cb43ef5251e28c4e7c4f08187cb33b0ac3962f41fc28
4
+ data.tar.gz: 5e803ddf4f8d77b56c2c7c91859b7ea0f8222341162790f39fb2cc7abbc1f517
5
5
  SHA512:
6
- metadata.gz: 422848afb4e96f1a94cbfc26078f7c343afdb519e431c25aa6f2de10be0578d51fa65aa6d04683490b792685d5888474b8f711f0e1839ccd6ccaeb45c52c26d0
7
- data.tar.gz: 81cd1f5df1028fa4064bc77ec5ee20866406d21c1ae5d4d992e8137bde59e5c6d6c505c7fc92b85111c931b7450da60b125692cb0bacbe63652e63012f9257da
6
+ metadata.gz: 3ff3dcde674bf0be28d1baec700a39d8db3a26a199c72fc467dd6864020d1608a1667e9feecb2e530706cf1a92b3a653cd7b904dd883cc4f495dc9027145c6c8
7
+ data.tar.gz: 4e3566d9c90076d1a9c4c46ee99e9d2415320fcfeb8be0d2acc1a03ac9168278362a8cfe1dd93b108e4db312c292f3436a4061e24b5cb211ec217445a942a254
data/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ All notable changes to bible270. Format follows [Keep a Changelog](https://keepa
7
7
  ### Added
8
8
 
9
9
  - add an on-demand Markdown formatting drawer and separate server-rendered Preview control for reflections and replies, with safe rendering, formatted notification emails, mention and browser-draft compatibility, and literal display of existing plain-text reflections; upgrading hosts must copy and run the new `body_format` comment migration
10
+ - add `bible270:notifications:enable_all` to opt every existing reader into emails for each new reflection and reply
11
+ - add `bible270:readers:list` to print an aligned, progress-sorted reader report with schedule status
12
+
13
+ ### Changed
14
+
15
+ - default new readers to emails for every new reflection and reply; existing reader preferences remain unchanged by the migration
10
16
 
11
17
  ### Fixed
12
18
 
data/README.md CHANGED
@@ -295,7 +295,8 @@ plain text or Markdown; until then, the composer safely falls back to plain text
295
295
  When `config.mention_notifications` is enabled, each reader can request email for every new reflection
296
296
  and reply, only replies to their reflections and mentions of them, or none. Administrators can change
297
297
  the same preference from the reader's Admin page. Migration
298
- `20260101000018` adds the broad opt-in without changing any existing reader's choice. Migration
298
+ `20260101000018` adds the broad opt-in without changing any existing reader's choice, while migration
299
+ `20260101000022` makes that broad option the default for readers created afterward. Migration
299
300
  `20260101000017` stores each reader's last visit to the Reflections page. After upgrading, install and
300
301
  run the current migrations:
301
302
 
@@ -304,6 +305,27 @@ bin/rails bible270:install:migrations
304
305
  bin/rails db:migrate
305
306
  ```
306
307
 
308
+ To change every existing reader to **Every new reflection and reply**, run:
309
+
310
+ ```bash
311
+ bin/rails bible270:notifications:enable_all
312
+ ```
313
+
314
+ With Docker Compose:
315
+
316
+ ```bash
317
+ docker compose exec -e RAILS_ENV=production rails bin/rails bible270:notifications:enable_all
318
+ ```
319
+
320
+ To print an aligned progress report ordered by completed days, run:
321
+
322
+ ```bash
323
+ docker compose exec -e RAILS_ENV=production rails bin/rails bible270:readers:list
324
+ ```
325
+
326
+ The report compares completed days with the calendar day implied by each reader's effective start date
327
+ and shows `on track`, days ahead or behind, or `undated` when no calendar applies.
328
+
307
329
  Break points can also live in your app rather than the gem, and be changed without a restart:
308
330
 
309
331
  ```ruby
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ChangeAllCommentNoticesDefaultToTrue < ActiveRecord::Migration[7.0]
4
+ def up
5
+ change_column_default :bible270_readers, :notify_on_all_comments, from: false, to: true
6
+ end
7
+
8
+ def down
9
+ change_column_default :bible270_readers, :notify_on_all_comments, from: true, to: false
10
+ end
11
+ end
@@ -31,6 +31,7 @@ module Bible270
31
31
  'ChangePassageSourceDefaultToBibleCom' => :check_passage_source_default,
32
32
  'AddCompletionDoveDisabledToBible270Readers' => :check_completion_dove_disabled,
33
33
  'AddBodyFormatToBible270Comments' => :check_comment_body_format,
34
+ 'ChangeAllCommentNoticesDefaultToTrue' => :check_all_comment_notices_default,
34
35
  'CreateActiveStorageTables' => :check_active_storage
35
36
  }.freeze
36
37
 
@@ -221,6 +222,14 @@ module Bible270
221
222
  missing
222
223
  end
223
224
 
225
+ def check_all_comment_notices_default
226
+ missing = table_missing(:bible270_readers, columns: %i[notify_on_all_comments])
227
+ return missing if missing.any?
228
+
229
+ column = connection.columns(:bible270_readers).find { |candidate| candidate.name == 'notify_on_all_comments' }
230
+ column&.default == true ? [] : ['column bible270_readers.notify_on_all_comments default true']
231
+ end
232
+
224
233
  # The Bible270 installer can install Active Storage for reader avatars. A
225
234
  # copied database can therefore have the same timestamp mismatch for Rails'
226
235
  # generated Active Storage migration as it has for the engine migrations.
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bible270
4
+ # Builds the plain-text reader progress table used by administrative tasks.
5
+ class ReaderProgressReport
6
+ HEADERS = ['Name', 'Days Read', 'Status'].freeze
7
+ Row = Struct.new(:name, :days_read, :status, keyword_init: true)
8
+
9
+ def initialize(readers: Reader.all, completed_days: Reader.completed_days_by_id)
10
+ @readers = readers
11
+ @completed_days = completed_days
12
+ end
13
+
14
+ def rows
15
+ @rows ||= begin
16
+ report_rows = readers.map do |reader|
17
+ days_read = completed_days.fetch(reader.id, 0)
18
+ Row.new(name: reader.display_name, days_read: days_read, status: status(reader, days_read))
19
+ end
20
+ report_rows.sort_by { |row| [-row.days_read, row.name.downcase, row.name] }
21
+ end
22
+ end
23
+
24
+ def empty? = rows.empty?
25
+
26
+ def to_table
27
+ values = rows.map { |row| [row.name, row.days_read.to_s, row.status] }
28
+ widths = HEADERS.each_index.map do |index|
29
+ ([HEADERS[index].length] + values.map { |value| value[index].length }).max
30
+ end
31
+ format = "%-#{widths[0]}s %#{widths[1]}s %-#{widths[2]}s"
32
+ lines = [format % HEADERS, format % widths.map { |width| '-' * width }].map(&:rstrip)
33
+ lines.concat(values.map { |value| (format % value).rstrip })
34
+ lines.join("\n")
35
+ end
36
+
37
+ private
38
+
39
+ attr_reader :readers, :completed_days
40
+
41
+ def status(reader, days_read)
42
+ calendar_day = reader.calendar_day
43
+ return 'undated' unless calendar_day
44
+
45
+ difference = days_read - calendar_day
46
+ return 'on track' if difference.zero?
47
+
48
+ amount = difference.abs
49
+ "#{amount} #{amount == 1 ? 'day' : 'days'} #{difference.positive? ? 'ahead' : 'behind'}"
50
+ end
51
+ end
52
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bible270
4
- VERSION = '1.5.0'
4
+ VERSION = '1.5.1'
5
5
  end
data/lib/bible270.rb CHANGED
@@ -13,6 +13,7 @@ require 'bible270/translations'
13
13
  require 'bible270/favicon'
14
14
  require 'bible270/configuration'
15
15
  require 'bible270/daily_reminders'
16
+ require 'bible270/reader_progress_report'
16
17
  require 'bible270/engine' if defined?(Rails::Engine)
17
18
 
18
19
  module Bible270
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :bible270 do
4
+ namespace :notifications do
5
+ desc 'Email every existing reader about each new reflection and reply'
6
+ task enable_all: :environment do
7
+ unless Bible270::Reader.comment_notification_columns?
8
+ abort 'Reflection email columns are missing. Run bin/rails bible270:install:migrations and bin/rails db:migrate.'
9
+ end
10
+
11
+ total = Bible270::Reader.count
12
+ puts "Found #{total} Bible270 #{'reader'.pluralize(total)} in the #{Rails.env} environment."
13
+ if total.zero?
14
+ puts 'No reader settings were changed.'
15
+ puts 'Rerun with RAILS_ENV=production if that is where your readers are stored.' unless Rails.env.production?
16
+ next
17
+ end
18
+
19
+ readers = Bible270::Reader.where(notify_on_mention: false)
20
+ .or(Bible270::Reader.where(notify_on_all_comments: false))
21
+ updated = 0
22
+
23
+ Bible270::Reader.transaction do
24
+ readers.find_each do |reader|
25
+ reader.update_comment_notification_level!('all')
26
+ updated += 1
27
+ end
28
+ end
29
+
30
+ if updated.zero?
31
+ puts "All #{total} #{'reader'.pluralize(total)} already receive every new reflection and reply."
32
+ else
33
+ puts "Updated #{updated} #{'reader'.pluralize(updated)}. " \
34
+ "All #{total} #{'reader'.pluralize(total)} now receive every new reflection and reply."
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bible270/reader_progress_report'
4
+
5
+ namespace :bible270 do
6
+ namespace :readers do
7
+ desc 'List readers by completed days with their schedule status'
8
+ task list: :environment do
9
+ report = Bible270::ReaderProgressReport.new
10
+ if report.empty?
11
+ puts "No Bible270 readers found in the #{Rails.env} environment."
12
+ else
13
+ puts report.to_table
14
+ end
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bible270
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew vonderLuft
@@ -214,6 +214,7 @@ files:
214
214
  - db/migrate/20260101000019_change_passage_source_default_to_bible_com.rb
215
215
  - db/migrate/20260101000020_add_completion_dove_disabled_to_bible270_readers.rb
216
216
  - db/migrate/20260101000021_add_body_format_to_bible270_comments.rb
217
+ - db/migrate/20260101000022_change_all_comment_notices_default_to_true.rb
217
218
  - lib/bible270.rb
218
219
  - lib/bible270/avatars.rb
219
220
  - lib/bible270/comment_formatter.rb
@@ -226,6 +227,7 @@ files:
226
227
  - lib/bible270/migration_reconciler.rb
227
228
  - lib/bible270/names.rb
228
229
  - lib/bible270/plan.rb
230
+ - lib/bible270/reader_progress_report.rb
229
231
  - lib/bible270/translations.rb
230
232
  - lib/bible270/versification.rb
231
233
  - lib/bible270/version.rb
@@ -233,6 +235,8 @@ files:
233
235
  - lib/generators/bible270/install/templates/bible270.rb.tt
234
236
  - lib/generators/bible270/install/templates/omniauth.rb.tt
235
237
  - lib/tasks/bible270_migrations.rake
238
+ - lib/tasks/bible270_notifications.rake
239
+ - lib/tasks/bible270_readers.rake
236
240
  - lib/tasks/bible270_reminders.rake
237
241
  homepage: https://github.com/avonderluft/bible270
238
242
  licenses: