def get_subscriptions_over_time(self, project, start, end): """ Return array of (timestamp, count) tuples, for use of plotting subscriptions over time """ subscriptions = self.interest_manager.getByProjectBetween(project, start, end) # subscriptions = self.get_mock_subscriptions() # replace this by real data result = [] for subscription in subscriptions: posted = parser.parse(str(subscription.posted)) result.append([util.unix_time_millis(posted),1]) return result
def get_traffic_over_time(self, project, start, end): """ Get traffic per day over given interval, format traffic as list of tuples (timestamp, traffic-count) """ settings = self.getSettingsByProject(project) traffic = self.ga_manager.get_daily_visits(settings.ga_view, start, end) result = [] for item in traffic.get('rows'): ms = util.unix_time_millis(parser.parse(item[0])) count = int(item[1]) result.append([ms, count]) return result
def get_conversions_over_time(self, project, start, end): """ Get conversion count per day over given interval, format traffic as list of tuples (timestamp, traffic-count) """ settings = self.getSettingsByProject(project) conversion = self.ga_manager.get_daily_conversions_for_goal(settings.ga_view, settings.goal_to_track, start, end) self.logger.debug(conversion) result = [] if not conversion.get('rows'): return result for item in conversion.get('rows'): ms = util.unix_time_millis(parser.parse(item[0])) count = int(item[1]) result.append([ms, count]) return result
def get_campaigns_over_time(self, project, start, end): """ Return a list of highchart flags tuples ({x, title, text}) representing the mailchimp campaigns available for token in project. """ mc_man = MailchimpManager(project.mailchimp_api_token) json = mc_man.get_campaigns(start, end, project.mailchimp_list_id) result = [] for item in json.get('data'): if(item.get('status') == 'sent'): dt = parser.parse(item.get('send_time')) result.append({'x':util.unix_time_millis(dt), 'title': 'M', 'text': u'Mailchimp campaign verstuurd: {}'.format(item.get('title'))}) # sort the array of dicts by the value of x newlist = sorted(result, key=itemgetter('x')) return newlist