I’ve created a yammer importer for someone and they would like for it to be publicly available. (Hey @gerhard , I think this one is in your wheelhouse.) I can’t quite make sense of yammer’s popularity and/or whether it’s something that will soon have lots of people clammering for a new platform or whether most of those people just expect to lose their data when they leave the platform.
The yammer export is a bunch of CSV files, so the import script uses script/import_scripts/base/generic_database.rb
. It includes importing PMs, which required adding a couple of tables to the generic_database.rb
. I thought that it made more sense to add separate code for PMs than to try to coerce the existing code to handle them and risk breaking it for the other importers that use it (zendesk, zendesk_api, and answerbase). Also, attachments are handled differently than they must be in the scripts that use generic_database.rb
, so my PM tables don’t manage uploads the way that the othere do (which I couldn’t quite make sense of). I also added an upload table rather than use topic_upload
and post_upload
as the generic importer uses.
def create_upload_table
@db.execute <<-SQL
CREATE TABLE IF NOT EXISTS upload (
id #{key_data_type} NOT NULL PRIMARY KEY,
user_id INTEGER,
original_filename TEXT,
filename TEXT,
description TEXT,
url TEXT
)
SQL
end
The current code processes uploads when it sees reference to them in raw
. It also replaces references to users with discourse @username
references. It also handles some bizarre opengraphobject
and uses those, if they exist to generate topic titles (which are missing from most topics in the dump I wrote this for).
Questions:
- is this too much handwaiving to be able to answer these questions?
- should I create a PM to core, or just include this as a standalone repo (I will include a script that will copy the code into the discourse source tree and run it from there)
- do the additions to
generic_database
sound reasonable or should I contnrive to add to that class in my import script or just include my additional functions in my own script and have it just refer to the global@db
?