You’d do something like
cd /var/discourse
./launcher enter app
rails c
to get to the console. You’d then do stuff
If you don’t understand them, then you probably don’t want to do it yourself.
Here are scripts that I believe worked on or about Jan 12, 2018. I don’t promise that they work, but I don’t see why not. Take backups and light a candle. ![]()
# alpha sort all categories matching search and their sub-categories
def sort_matching_categories_and_subcategories(search)
categories = Category.where("name like ?", search)
position = 100
categories.order(:name).each do |cat|
position += 5
cat.position = position
cat.save!()
c_position = 0
children = Category.where(:parent_category_id=>cat.id)
children.order(:name).each do |c|
c_position += 5
c.position = c_position
c.save!()
end
end
end
# alpha sort subcategories of a single category matching search
def sort_matching_subcategories(search)
categories = Category.where("name like ?", search)
if categories.count > 1
puts "Found more than one category"
end
categories.order(:name).each do |cat|
c_position = 5
children = Category.where(:parent_category_id=>cat.id)
children.order(:name).each do |c|
c_position += 5
c.position = c_position
c.save!()
end
end
end
If you need more help than that and have a budget, see Redirecting… or send me an email.
I hope this helps!