Merge recent Bit.ly schema changes into a single migration
Add a view "bitly_story_clicks_retrieved" which dynamically calculates the date ranges for which we have Bit.ly click data
Make the "bitly_story_clicks_retrieved" view also return an sum of clicks for the date range to make it more similar to what "bitly_story_referrers" table does
Rename "bitly_story_clicks" table to "bitly_story_daily_clicks", "bitly_story_clicks_retrieved" view to "bitly_story_clicks" to make the interface very similar to Bit.ly referrers
Calculate delta days correctly
Use correct table name
Aggregate stats correctly into updated "bitly_story_daily_clicks" and "bitly_story_referrers" tables
Rename index keys
Delete old aggregation results from the correct table
Use the "bitly_story_clicks" view and "bitly_story_referrers" table for generating CM dumps
"bitly_story_referrers" is a faster table, so use only that for checking whether story's stats have been aggregated
Add "bitly_processed_stories" table for storing a list of controversy stories that have gone through the whole Bit.ly processing chain; some stores are not found on Bit.ly API so they don't get to have any records in "_clicks" and other tables, and there's no other way to find out whether those stories have been processed or not without any record on the database
Refer to stories_id correctly