How to rebake Bios

AI-generated summary

The discussion revolves around rebaking bios after importing them into a database. pfaffman is inquiring about the best approach to rebake the bios without rebaking 230k posts. Falco suggests using a script to recalculate bios for users with a non-nil bio_raw field. pfaffman considers adding this script to the import process, and Falco advises against it due to potential concurrent work. However, since the import script only handles bios, pfaffman believes adding the script to the loop should be fine.

I’ve written an importer that pulls in a database of email addresses and Bios and sticks the bio into the About (aka bio_raw) field. It works fine, but the bios don’t show up because they aren’t getting baked. Inquiring minds want to know:

  • Will a posts:rebake rebake them?
  • Is there a way to rebake just the bios (and not 230K posts)?
  • Is there a way to trigger the rebake in the importer script?
  • If I’m patient will sidekiq notice?
  • Is there a question I should have asked other than these?

Something like:

users = UserProfile.where.not(bio_raw: nil)
users.each do |profile|
  profile.recook_bio
  profile.save
end

Thanks, @Falco. That’s the ticket!

Is there reason not to add

u.profile-recook_bio
u.profile.save

to my import script after

u.user_profile_update_column('bio_raw', the_imported_bio)

?

update_column updates the column without calling profile.save, which makes me wonder about profile.save, but there are lots of things I don’t understand yet. :slight_smile:

From a brief read, save would cook for you.

In a import script I believe there’s a lot of concurrent work filling all your CPU cycles, so I would postpone something like bio to the final part.

Thanks for RTFMing the code for me. I still have trouble finding the code, but I’m getting there. :slight_smile:

I think I see why to postpone the save. This script imports only bios, though, so I think in this case it’s probably fine to just stick it in this loop.