diff --git a/Gemfile.lock b/Gemfile.lock index 3debe73..15873e4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,70 +16,71 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (7.1.1) - actionpack (= 7.1.1) - activesupport (= 7.1.1) + actioncable (7.1.2) + actionpack (= 7.1.2) + activesupport (= 7.1.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.1) - actionpack (= 7.1.1) - activejob (= 7.1.1) - activerecord (= 7.1.1) - activestorage (= 7.1.1) - activesupport (= 7.1.1) + actionmailbox (7.1.2) + actionpack (= 7.1.2) + activejob (= 7.1.2) + activerecord (= 7.1.2) + activestorage (= 7.1.2) + activesupport (= 7.1.2) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.1.1) - actionpack (= 7.1.1) - actionview (= 7.1.1) - activejob (= 7.1.1) - activesupport (= 7.1.1) + actionmailer (7.1.2) + actionpack (= 7.1.2) + actionview (= 7.1.2) + activejob (= 7.1.2) + activesupport (= 7.1.2) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.2) - actionpack (7.1.1) - actionview (= 7.1.1) - activesupport (= 7.1.1) + actionpack (7.1.2) + actionview (= 7.1.2) + activesupport (= 7.1.2) nokogiri (>= 1.8.5) + racc rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.1) - actionpack (= 7.1.1) - activerecord (= 7.1.1) - activestorage (= 7.1.1) - activesupport (= 7.1.1) + actiontext (7.1.2) + actionpack (= 7.1.2) + activerecord (= 7.1.2) + activestorage (= 7.1.2) + activesupport (= 7.1.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.1) - activesupport (= 7.1.1) + actionview (7.1.2) + activesupport (= 7.1.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.1.1) - activesupport (= 7.1.1) + activejob (7.1.2) + activesupport (= 7.1.2) globalid (>= 0.3.6) - activemodel (7.1.1) - activesupport (= 7.1.1) - activerecord (7.1.1) - activemodel (= 7.1.1) - activesupport (= 7.1.1) + activemodel (7.1.2) + activesupport (= 7.1.2) + activerecord (7.1.2) + activemodel (= 7.1.2) + activesupport (= 7.1.2) timeout (>= 0.4.0) - activestorage (7.1.1) - actionpack (= 7.1.1) - activejob (= 7.1.1) - activerecord (= 7.1.1) - activesupport (= 7.1.1) + activestorage (7.1.2) + actionpack (= 7.1.2) + activejob (= 7.1.2) + activerecord (= 7.1.2) + activesupport (= 7.1.2) marcel (~> 1.0) - activesupport (7.1.1) + activesupport (7.1.2) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -89,14 +90,15 @@ GEM minitest (>= 5.1) mutex_m tzinfo (~> 2.0) - addressable (2.8.5) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) airbrussh (1.5.0) sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) - base64 (0.1.1) - bigdecimal (3.1.4) - brakeman (6.0.1) + base64 (0.2.0) + bigdecimal (3.1.5) + brakeman (6.1.1) + racc builder (3.2.4) bundler-audit (0.9.1) bundler (>= 1.2.0, < 3) @@ -130,21 +132,21 @@ GEM crack (0.4.5) rexml crass (1.0.6) - date (3.3.3) + date (3.3.4) diff-lcs (1.5.0) docile (1.4.0) dotenv (2.8.1) dotenv-rails (2.8.1) dotenv (= 2.8.1) railties (>= 3.2) - drb (2.1.1) + drb (2.2.0) ruby2_keywords erubi (1.12.0) execjs (2.9.1) - factory_bot (6.2.1) + factory_bot (6.4.5) activesupport (>= 5.0.0) - factory_bot_rails (6.2.0) - factory_bot (~> 6.2.0) + factory_bot_rails (6.4.3) + factory_bot (~> 6.4) railties (>= 5.0.0) ffi (1.16.3) formatador (1.1.0) @@ -164,21 +166,21 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - hashdiff (1.0.1) + hashdiff (1.1.0) httparty (0.21.0) mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) i18n (1.14.1) concurrent-ruby (~> 1.0) - io-console (0.6.0) - irb (1.8.3) + io-console (0.7.1) + irb (1.11.0) rdoc reline (>= 0.3.8) jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.6.3) + json (2.7.1) language_server-protocol (3.17.0.3) launchy (2.5.2) addressable (~> 2.8) @@ -193,10 +195,10 @@ GEM listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.21.4) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) - lumberjack (1.2.9) + lumberjack (1.2.10) mail (2.8.1) mini_mime (>= 0.1.1) net-imap @@ -207,28 +209,28 @@ GEM mini_mime (1.1.5) minitest (5.20.0) multi_xml (0.6.0) - mutex_m (0.1.2) + mutex_m (0.2.0) nenv (0.3.0) - net-imap (0.4.1) + net-imap (0.4.9.1) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout net-scp (4.0.0) net-ssh (>= 2.6.5, < 8.0.0) - net-smtp (0.4.0) + net-smtp (0.4.0.1) net-protocol - net-ssh (7.2.0) - nio4r (2.5.9) - nokogiri (1.15.4-x86_64-linux) + net-ssh (7.2.1) + nio4r (2.7.0) + nokogiri (1.16.0-x86_64-linux) racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - parallel (1.23.0) - parser (3.2.2.4) + parallel (1.24.0) + parser (3.3.0.0) ast (~> 2.4.1) racc pg (1.5.4) @@ -237,12 +239,12 @@ GEM method_source (~> 1.0) pry-rails (0.3.9) pry (>= 0.10.4) - psych (5.1.1.1) + psych (5.1.2) stringio - public_suffix (5.0.3) - puma (6.4.0) + public_suffix (5.0.4) + puma (6.4.1) nio4r (~> 2.0) - racc (1.7.1) + racc (1.7.3) rack (3.0.8) rack-session (2.0.0) rack (>= 3.0.0) @@ -251,20 +253,20 @@ GEM rackup (2.1.0) rack (>= 3) webrick (~> 1.8) - rails (7.1.1) - actioncable (= 7.1.1) - actionmailbox (= 7.1.1) - actionmailer (= 7.1.1) - actionpack (= 7.1.1) - actiontext (= 7.1.1) - actionview (= 7.1.1) - activejob (= 7.1.1) - activemodel (= 7.1.1) - activerecord (= 7.1.1) - activestorage (= 7.1.1) - activesupport (= 7.1.1) + rails (7.1.2) + actioncable (= 7.1.2) + actionmailbox (= 7.1.2) + actionmailer (= 7.1.2) + actionpack (= 7.1.2) + actiontext (= 7.1.2) + actionview (= 7.1.2) + activejob (= 7.1.2) + activemodel (= 7.1.2) + activerecord (= 7.1.2) + activestorage (= 7.1.2) + activesupport (= 7.1.2) bundler (>= 1.15.0) - railties (= 7.1.1) + railties (= 7.1.2) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -278,23 +280,23 @@ GEM nokogiri (~> 1.14) rails-ujs (0.1.0) railties (>= 3.1) - railties (7.1.1) - actionpack (= 7.1.1) - activesupport (= 7.1.1) + railties (7.1.2) + actionpack (= 7.1.2) + activesupport (= 7.1.2) irb rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.0.6) + rake (13.1.0) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - rdoc (6.5.0) + rdoc (6.6.2) psych (>= 4.0.0) - regexp_parser (2.8.2) - reline (0.3.9) + regexp_parser (2.8.3) + reline (0.4.2) io-console (~> 0.5) render_async (2.1.11) rexml (3.2.6) @@ -310,7 +312,7 @@ GEM rspec-mocks (3.12.6) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) - rspec-rails (6.0.3) + rspec-rails (6.1.0) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) @@ -319,23 +321,22 @@ GEM rspec-mocks (~> 3.12) rspec-support (~> 3.12) rspec-support (3.12.1) - rubocop (1.56.4) - base64 (~> 0.1.1) + rubocop (1.59.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.3) + parser (>= 3.2.2.4) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.1, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.29.0) + rubocop-ast (1.30.0) parser (>= 3.2.1.0) - rubocop-performance (1.19.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) + rubocop-performance (1.20.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) sassc (2.4.0) @@ -353,7 +354,7 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - spring (4.1.1) + spring (4.1.3) spring-commands-rspec (1.0.4) spring (>= 0.9.1) sprockets (4.2.1) @@ -363,27 +364,28 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sshkit (1.21.5) + sshkit (1.21.7) + mutex_m net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - standard (1.31.2) + standard (1.33.0) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.0) - rubocop (~> 1.56.4) + rubocop (~> 1.59.0) standard-custom (~> 1.0.0) - standard-performance (~> 1.2) + standard-performance (~> 1.3) standard-custom (1.0.2) lint_roller (~> 1.0) rubocop (~> 1.50) - standard-performance (1.2.1) + standard-performance (1.3.0) lint_roller (~> 1.1) - rubocop-performance (~> 1.19.1) - stringio (3.0.8) - terser (1.1.18) + rubocop-performance (~> 1.20.1) + stringio (3.1.0) + terser (1.1.20) execjs (>= 0.3.0, < 3) thor (1.3.0) tilt (2.3.0) - timeout (0.4.0) + timeout (0.4.1) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) diff --git a/app/models/subscriber.rb b/app/models/subscriber.rb index e310ef0..636abc3 100644 --- a/app/models/subscriber.rb +++ b/app/models/subscriber.rb @@ -18,15 +18,6 @@ def self.active? dates_active === Date.current end - # def self.fractional_part(float) - # float.to_s =~ /0\.(.+)$/ - # $1 - # end - - # def self.confirmation_number - # fractional_part(rand) - # end - def self.find_by_email(email) where("lower(email) = ?", email.downcase).first end diff --git a/app/models/tasks.rb b/app/models/tasks.rb index 1d8e3cd..43e39e3 100644 --- a/app/models/tasks.rb +++ b/app/models/tasks.rb @@ -54,4 +54,17 @@ def self.subscribe_all_sites_to_weather end puts msg.join("\n") end + + def self.purge_subs(delete: false) + unconfirmed = Subscriber.select { |s| !s.is_confirmed? && (s.updated_at < 1.week.ago) } + stale = Subscriber.select { |s| !s.admin? && s.is_confirmed? && (s.updated_at < 1.month.ago) && (s.sites.size == 0) } + puts "Total subscribers: #{Subscriber.all.size}. Unconfirmed: #{unconfirmed.size}. Stale: #{stale.size}." + if delete + unconfirmed.each(&:destroy) + stale.each(&:destroy) + else + puts "Run with delete:true to delete unconfirmed/stale subscriber records." + {unconfirmed:, stale:} + end + end end diff --git a/app/views/subscribers/admin.html.erb b/app/views/subscribers/admin.html.erb index 0cdad6f..49fecaa 100644 --- a/app/views/subscribers/admin.html.erb +++ b/app/views/subscribers/admin.html.erb @@ -36,6 +36,8 @@ Email: <%= @subscriber.email %>

+

Name and email can be changed for subscribers in the list below. You cannot change your own email from this page, nor can you set or remove admin status on other users. Use the rails terminal for those tasks.

+
<%= will_paginate @subscribers, class: :apple_pagination %>
@@ -46,7 +48,7 @@ Name Email Locations - Admin? + Subscribed? Actions @@ -54,10 +56,14 @@ <% @subscribers.each do |subscriber| %> <%= subscriber.id %> - <%= best_in_place subscriber, :name, as: :input %> + + <%= @subscriber.id == subscriber.id ? "[YOU] " : "" %> + <%= subscriber.admin? ? "[ADMIN] " : ""%> + <%= best_in_place subscriber, :name, as: :input %> + <%= best_in_place_if @subscriber.id != subscriber.id, subscriber, :email, as: :input %> <%= subscriber.sites.size %> - <%= subscriber.admin? ? "Yes" : "" %> + <%= subscriber.emails_enabled ? "Yes" : "No" %> <%= link_to "".html_safe, url_for(action: :manage, to_edit_id: subscriber.id) %> <% unless @subscriber.id == subscriber.id || subscriber.admin? %>