Exporting from a SaaS application

Recently I had a request from a customer of my applicant tracking system application to do an export of all her data. This was one of those features that I had always planned to do, but not never got around to it, and eventually decided I would just handle it when it came up. Well, it finally came up, so it was time to deal with it. Let's call it just-in-time feature delivery. :)

In Catch the Best, there are two sets of user data. The first set is in the database and is made up of notes, contact info, etc., about job applicants. The second set of data is the documents the candidates send in with their job applications, which are stored via the attachment_fu plugin. Exporting the first set of data is fairly simple, but the other set of data took a little more work. Here's what I did.

First, to get the data out of the database, I decided to put the to_xml method provided by ActiveRecord to good use, redefining it in my various models to meet my needs. For example, I have this in my Submission model:

And then in Attachment I have a similar to_xml method that spits out the relative path to the file, so that it can be matched up with the files that I will be including with the export.

For the resumes, I iterate over all the attachments that belong to the customer, adding them to a zipfile that the customer will download. It looks something like this:

That submissions.xml file at the end is actually the output of that to_xml call in the Submission model. All of the attachments and the to_xml dump are added to a single zip file, which the customer can then download. Add a couple of UI bits, and self-serve data exports from my SaaS application are good to go.

That's much better than doing it by hand, and I got to wait more than a year after I launched Catch the Best before I spent time on that feature. Everybody wins. :)