-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Add category moderation groups and more attributes to generic importer #32561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
script/bulk_import/generic_bulk.rb
Outdated
@@ -562,6 +631,7 @@ def import_user_options | |||
email_level: row["email_level"], | |||
email_messages_level: row["email_messages_level"], | |||
email_digests: row["email_digests"], | |||
hide_profile_and_presence: row["hide_profile_and_presence"] || false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be some work to make this setting more granular by splitting it into hide_profile
and hide_presence
, but hide_profile_and_presence
still appears to be kept in sync as follows:
discourse/app/models/user_option.rb
Lines 228 to 235 in 4117b08
def update_hide_profile_and_presence | |
if hide_profile_changed? || hide_presence_changed? | |
self.hide_profile_and_presence = hide_profile || hide_presence | |
elsif hide_profile_and_presence_changed? | |
self.hide_profile = hide_profile_and_presence | |
self.hide_presence = hide_profile_and_presence | |
end | |
end |
Simply setting hide_profile_and_presence
might be problematic. You could:
- Set both
hide_profile
andhide_presence
to the value ofhide_profile_and_presence
, if it’s explicitly provided inprocess_user_options
- Update the converter framework to support to also support
hide_profile
andhide_presence
and replicate the logic above to keep them in sync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a couple of updates here. Let me know if this would work? This is actually not used in the converter. It was due to an error that was caused during the import that requested this to be added if I remember correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the error:
ERROR: null value in column "hide_profile_and_presence" of relation "user_options" violates not-null constraint
…user option, and multi-tag-group support
979c141
to
016ca7a
Compare
@@ -76,6 +76,7 @@ def initialize | |||
@html_entities = HTMLEntities.new | |||
@encoding = CHARSET_MAP[charset] | |||
@bbcode_to_md = true if use_bbcode_to_md? | |||
@assign_plugin_enabled = defined?(::DiscourseAssign) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable?
group_data = { | ||
imported_id: row["id"], | ||
name: row["name"], | ||
full_name: row["full_name"], | ||
public_admission: row["public_admission"] || false, | ||
public_exit: row["public_exit"] || false, | ||
allow_membership_requests: row["allow_membership_requests"] || false, | ||
visibility_level: row["visibility_level"], | ||
members_visibility_level: row["members_visibility_level"], | ||
mentionable_level: row["mentionable_level"], | ||
messageable_level: row["messageable_level"], | ||
} | ||
group_data[:assignable_level] = row["assignable_level"] | ||
group_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group_data = { | |
imported_id: row["id"], | |
name: row["name"], | |
full_name: row["full_name"], | |
public_admission: row["public_admission"] || false, | |
public_exit: row["public_exit"] || false, | |
allow_membership_requests: row["allow_membership_requests"] || false, | |
visibility_level: row["visibility_level"], | |
members_visibility_level: row["members_visibility_level"], | |
mentionable_level: row["mentionable_level"], | |
messageable_level: row["messageable_level"], | |
} | |
group_data[:assignable_level] = row["assignable_level"] | |
group_data | |
{ | |
imported_id: row["id"], | |
name: row["name"], | |
full_name: row["full_name"], | |
public_admission: row["public_admission"] || false, | |
public_exit: row["public_exit"] || false, | |
allow_membership_requests: row["allow_membership_requests"] || false, | |
visibility_level: row["visibility_level"], | |
members_visibility_level: row["members_visibility_level"], | |
mentionable_level: row["mentionable_level"], | |
messageable_level: row["messageable_level"], | |
assignable_level: row["assignable_level"] | |
} |
hide_profile_and_presence: false, | ||
hide_profile: false, | ||
hide_presence: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why always false
? If this is just about setting defaults, then the USER_OPTION_DEFAULTS
hash in BulkImport
is the right way to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see discussion with @s3lase here - #32561 (comment)
if row["tag_group_ids"] && !row["tag_group_ids"].empty? | ||
intermediate_group_ids = JSON.parse(row["tag_group_ids"]) | ||
elsif row["tag_group_id"] && !row["tag_group_id"].empty? | ||
# Support old single tag_group_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a tag_group_id
attribute in the current IntermediateDB anymore. We should only support the lasted version, so reduce complexity. So, unless I'm missing something, we should remove this and make stuff less complicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @gschlager, I'm getting mixed messages between you and @s3lase. See his previous message - #32561 (comment)
Here's the tag_group_id and 021-tags.sql in intermediate.db.
|
||
if intermediate_group_ids.any? | ||
intermediate_group_ids.each do |intermediate_group_id| | ||
intermediate_group_id = intermediate_group_id.to_i if intermediate_group_id.is_a?(String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do this unconditionally:
intermediate_group_id = intermediate_group_id.to_i if intermediate_group_id.is_a?(String) | |
intermediate_group_id = intermediate_group_id.to_i |
But is it really needed? Do we store numbers as JSON strings for some reason?
|
||
UPDATE badges |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPDATE badges | |
UPDATE badges |
This PR improves the generic bulk import and base scripts by adding support for several previously unimplemented features and attributes: