mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Add post edits count to user activity (#13495)
This commit is contained in:
@@ -106,5 +106,9 @@ module DiscourseDev
|
||||
puts "Done!"
|
||||
end
|
||||
|
||||
def self.random
|
||||
super(::Post)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
23
lib/discourse_dev/post_revision.rb
Normal file
23
lib/discourse_dev/post_revision.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'discourse_dev/record'
|
||||
require 'faker'
|
||||
|
||||
module DiscourseDev
|
||||
class PostRevision < Record
|
||||
|
||||
def initialize
|
||||
super(::PostRevision, DiscourseDev.config.post_revisions[:count])
|
||||
end
|
||||
|
||||
def create!
|
||||
data = { raw: Faker::DiscourseMarkdown.sandwich(sentences: 5) }
|
||||
|
||||
::PostRevisor.new(Post.random).revise!(User.random, data)
|
||||
end
|
||||
|
||||
def populate!
|
||||
@count.times { create! }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -415,6 +415,8 @@ class PostRevisor
|
||||
@post.link_post_uploads
|
||||
@post.save_reply_relationships
|
||||
|
||||
@editor.increment_post_edits_count if @post_successfully_saved
|
||||
|
||||
# post owner changed
|
||||
if prev_owner && new_owner && prev_owner != new_owner
|
||||
likes = UserAction.where(target_post_id: @post.id)
|
||||
|
||||
@@ -25,6 +25,11 @@ task 'topics:populate' => ['db:load_config'] do |_, args|
|
||||
DiscourseDev::Topic.populate!
|
||||
end
|
||||
|
||||
desc 'Create post revisions'
|
||||
task 'post_revisions:populate' => ['db:load_config'] do |_, args|
|
||||
DiscourseDev::PostRevision.populate!
|
||||
end
|
||||
|
||||
desc 'Add replies to a topic'
|
||||
task 'replies:populate', [:topic_id, :count] => ['db:load_config'] do |_, args|
|
||||
DiscourseDev::Post.add_replies!(args)
|
||||
|
||||
Reference in New Issue
Block a user