Replacing a Write-Back Process with a Simple Report
While we were messing with getting merchant data from Salesforce.com, we had another little story in Pivotal Tracker about replacing the write-back of demand gap analysis with a simple report on our Metrics Site - a series of web pages we've put together for viewing the metrics of the runs.
Given that we've had a lot of timeouts in these specific write-backs, it made a lot of sense to me to get rid of the write-backs and just have a report for the merchant researchers to use. It was a pretty simple page to throw together - I had to update the CouchDB view to change the key of the view from:
["2012-09-24_14:51:21.232_cleveland", "cleveland", "Food & Drink"]
to the simpler:
["2012-09-24_14:51:21.232_cleveland", "Food & Drink"]
because we really didn't need the division in the key, but we really needed to be able to specify the key as well as have a nice reduce set of the counts by date/time and category of merchant. That took a bit to regenerate, but when it was done, I had everything I needed - or so I thought.
The code for generating the URL was pretty simple:
var et = run_opt.value + '_' + div_opt.value; var cat = cat_opt.value; var url = svr_opt.value + '?key=' + JSON.stringify([et,cat]);
and it wasn't obvious to me, but the ampersand in the Food & Drink was going to be a real pain in the rump for me because it's a valid JSON code, but it's also the argument separator in the URL. So I had to do a little modification:
var et = run_opt.value + '_' + div_opt.value; var cat = cat_opt.value.replace("&", "%26"); var url = svr_opt.value + '?key=' + JSON.stringify([et,cat]);
to get the ampersand into a hex value for sending to the server.
With this, I was all ready to go. I pushed the view changes to the prod and UAT CouchDBs, so in the morning, first thing, I'll be able to check it all in and then push the new pages to the server.
I sent a note to the project manager asking him if he really would prefer this, and why it'd be great for us to not have the write-back to Salesforce.com… I'm hoping this is going to work out really well.