DEV: Add import support for Topic Voting plugin (#29442)
Some checks are pending
Licenses / run (push) Waiting to run
Linting / run (push) Waiting to run
Tests / core frontend (${{ matrix.browser }}) (Chrome) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (annotations, core) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (backend, core) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (backend, plugins) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (frontend, plugins) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (frontend, themes) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (system, chat) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (system, core) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (system, plugins) (push) Waiting to run
Tests / ${{ matrix.target }} ${{ matrix.build_type }} (system, themes) (push) Waiting to run
Tests / core frontend (${{ matrix.browser }}) (Firefox ESR) (push) Waiting to run
Tests / core frontend (${{ matrix.browser }}) (Firefox Evergreen) (push) Waiting to run

DEV: Add import support for Topic Voting plugin
- Implemented bulk import functionality specifically for topic_voting_votes.
- Updated the method name from import_votes to import_post_voting_votes for improved clarity and maintainability.
- Co-authored-by: Gerhard Schlager <gerhard.schlager@discourse.org>
This commit is contained in:
Ruben Oussoren
2024-10-31 08:30:28 -04:00
committed by GitHub
parent 4b533c47f0
commit 4b8b7b2fb5
2 changed files with 87 additions and 2 deletions

View File

@ -761,6 +761,8 @@ class BulkImport::Base
POST_VOTING_VOTE_COLUMNS = %i[user_id votable_type votable_id direction created_at]
TOPIC_VOTING_COLUMNS = %i[topic_id user_id archive created_at updated_at]
BADGE_COLUMNS = %i[
id
name
@ -1051,6 +1053,10 @@ class BulkImport::Base
create_records(rows, "post_voting_vote", POST_VOTING_VOTE_COLUMNS, &block)
end
def create_topic_voting_votes(rows, &block)
create_records(rows, "topic_voting_vote", TOPIC_VOTING_COLUMNS, &block)
end
def create_post_custom_fields(rows, &block)
create_records(rows, "post_custom_field", POST_CUSTOM_FIELD_COLUMNS, &block)
end
@ -1558,6 +1564,12 @@ class BulkImport::Base
vote
end
def process_topic_voting_vote(topic_vote)
topic_vote[:created_at] ||= NOW
topic_vote[:updated_at] ||= NOW
topic_vote
end
def process_user_avatar(avatar)
avatar[:id] = @last_user_avatar_id += 1
avatar[:created_at] ||= NOW