Thanks @pfaffman !
I see where().first
is more idiomatic Ruby than my Python-inspired [0]
later on, and lack of .first
is why my error checking for nil?
would never fire even when categories didn’t exist. That I can fix.
Google has UUIDs for categories, so now I know that I could use import_id
if I want to import new categories. For my current purposes, I actually want the categories to have been created and organized first because I’m back-filling. I could make a conditional for whether to create category or error on unknown category, depending on whether it would actually be used. If someone asks, that looks not hard. I probably won’t bother unless someone here says they would actually use it, though. Google+ category names are in practice often long and would make the Discourse UI look a little off, so I think in this case it’s likely to be worth the effort up front. Or, if you are going to run some of these imports on a professional basis, happy to hand off to you for that!
Does providing the G+-provided UUID when creating a topic/post mean that as long as I’m providing the same UUID, create_post
will see that it exists on the system and not re-create it? If so, that would make the script safe to run for incremental imports, which would be awesome!
Actual current version of my script:
https://github.com/johnsonm/discourse/blob/friendsmegplus/script/import_scripts/friendsmegplus.rb