diff --git a/piwik/indico_piwik/queries/__init__.py b/piwik/indico_piwik/queries/__init__.py index 69e1127..58b8484 100644 --- a/piwik/indico_piwik/queries/__init__.py +++ b/piwik/indico_piwik/queries/__init__.py @@ -39,21 +39,20 @@ class PiwikQueryReportEventBase(PiwikQueryReportBase): def call(self, segmentation_enabled=True, **query_params): if segmentation_enabled: - query_params['segmentation'] = self.get_segmentation() + query_params['segment'] = self.get_segmentation() return super(PiwikQueryReportEventBase, self).call(module='API', date=[self.start_date, self.end_date], **query_params) def get_segmentation(self): segmentation = {'customVariablePageName1': ('==', 'Conference'), 'customVariablePageValue1': ('==', self.event_id)} + if self.contrib_id: segmentation['customVariablePageName2'] = ('==', 'Contribution') segmentation['customVariablePageValue2'] = ('==', self.contrib_id) segments = set() for name, (equality, value) in segmentation.iteritems(): - if isinstance(value, list): - value = ','.join(value) segment = '{}{}{}'.format(name, equality, value) segments.add(segment) diff --git a/piwik/indico_piwik/queries/metrics.py b/piwik/indico_piwik/queries/metrics.py index 62a2719..fc589e3 100644 --- a/piwik/indico_piwik/queries/metrics.py +++ b/piwik/indico_piwik/queries/metrics.py @@ -20,20 +20,20 @@ class PiwikQueryReportEventMetricBase(PiwikQueryReportEventBase): class PiwikQueryReportEventMetricVisitsBase(PiwikQueryReportEventMetricBase): def get_result(self, reduced=True): - query_params = {} if reduced else {'segmentation_enabled': False} - result = get_json_from_remote_server(self.call, **query_params) + result = get_json_from_remote_server(self.call) if reduced: return int(reduce_json(result)) if result else 0 return result if result else {} class PiwikQueryReportEventMetricDownloads(PiwikQueryReportEventMetricBase): - def call(self, download_url): + def call(self, download_url, **query_params): return super(PiwikQueryReportEventMetricDownloads, self).call(method='Actions.getDownload', - downloadUrl=quote(download_url)) + downloadUrl=quote(download_url), + **query_params) def get_result(self, download_url): - result = get_json_from_remote_server(self.call, download_url=download_url) + result = get_json_from_remote_server(self.call, download_url=download_url, segmentation_enabled=False) return {'cumulative': self._get_cumulative_results(result), 'individual': self._get_per_day_results(result)}