From e269c95bcec514ce1b6c6c330ba34984ca36e8c4 Mon Sep 17 00:00:00 2001 From: Oleg Valter Date: Sat, 16 Sep 2023 08:34:29 +0300 Subject: [PATCH 1/2] fix initial revision for policy posts & improve seed error reporting --- db/seeds.rb | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 96dbdaa3f..9c38c693d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -26,6 +26,7 @@ processed = ERB.new(File.read(f)).result(binding) data = YAML.load(processed) created = 0 + errored = 0 skipped = 0 updated = 0 data.each do |seed| @@ -39,6 +40,9 @@ puts "Running full Posts update..." seed['body'] = ApplicationController.helpers.render_markdown(seed['body_markdown']) + + system_usr = User.find(-1) + Community.all.each do |c| RequestContext.community = c post = Post.find_by doc_slug: seed['doc_slug'] @@ -46,13 +50,33 @@ .where.not(post_history_type: PostHistoryType.find_by(name: 'initial_revision')) .count.zero? + # post exists, still original version: update post post.update(seed.merge('community_id' => c.id)) + + no_initial = PostHistory.where(post: post) + .where(post_history_type: PostHistoryType.find_by(name: 'initial_revision')) + .count.zero? + + if no_initial + puts "[#{c.name}:#{seed['doc_slug']}] missing initial revision, creating..." + PostHistory.initial_revision(post, system_usr) + end + updated += 1 elsif post.nil? # post doesn't exist: create post - Post.create seed.merge('community_id' => c.id) - created += 1 + status = Post.create seed.merge('community_id' => c.id, 'user' => system_usr) + + if status.errors.size + status.errors.full_messages.each do |msg| + puts "[#{c.name}:#{seed['doc_slug']}] invalid: #{msg}" + end + + errored += 1 + else + created += 1 + end else # post exists, versions diverged: skip skipped += 1 @@ -92,7 +116,7 @@ end end unless Rails.env.test? - puts "#{type}: Created #{created}, #{updated > 0 ? "updated #{updated}, " : ''}skipped #{skipped}" + puts "#{type}: Errored #{errored}, Created #{created}, #{updated > 0 ? "updated #{updated}, " : ''}skipped #{skipped}" end rescue StandardError => e puts "Got error #{e}. Continuing..." From 84fcbb508ba65d6555445d283323d21dee1ea5a2 Mon Sep 17 00:00:00 2001 From: Monica Cellio Date: Sun, 1 Oct 2023 17:49:41 -0400 Subject: [PATCH 2/2] adjusted Discord guidance to account for discriminators being optional now or soon --- app/views/users/edit_profile.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/edit_profile.html.erb b/app/views/users/edit_profile.html.erb index 25f8c6a0c..1d7b35005 100644 --- a/app/views/users/edit_profile.html.erb +++ b/app/views/users/edit_profile.html.erb @@ -57,7 +57,7 @@
<%= f.label :discord, class: 'form-element' %> - Your Discord user tag, in the format username#1234. + Your Discord user tag, username or username#1234. <%= f.text_field :discord, class: 'form-element', autocomplete: 'off', placeholder: 'username#1234' %>
@@ -102,4 +102,4 @@ <%= submit_tag 'Claim Content', name: nil, class: 'button is-outlined' %> <% end %> -<% end %> \ No newline at end of file +<% end %>