Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit e2300fd

Browse files
committed
remove network scope in report and add network_managed, network_buy, network_sell
Auto-detect scope based on groups/metrics is no longer possible
1 parent 98430f6 commit e2300fd

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
----------------
33

44
- :meth:`atomx.Atomx.report` takes ``name`` parameter to name reports
5+
- remove ``network`` scope in :meth:`atomx.Atomx.report` and add
6+
``network_managed``, ``network_buy``, ``network_sell``
57
- Add new models:
68
- :class:`atomx.models.AccountManager` (alias for `User`)
79
- :class:`atomx.models.Banned` (alias for `Reason`)

atomx/__init__.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,10 @@ def report(self, scope=None, groups=None, metrics=None, where=None, from_=None,
138138
See the `reporting atomx wiki <https://wiki.atomx.com/reporting>`_
139139
for details about parameters and available groups, metrics.
140140
141-
:param str scope: either 'advertiser', 'publisher' or 'network' to select the type
142-
of report. If undefined it tries to determine the `scope` automatically based
143-
on the `groups` and `metrics` parameters and the access rights of the api user.
141+
:param str scope: Specifies the report type. Should be one of:
142+
'advertiser', 'publisher', 'network_managed', 'network_buy', 'network_sell'.
143+
If undefined it tries to determine the `scope` automatically based
144+
on the access rights of the api user.
144145
:param list groups: columns to group by.
145146
:param list metrics: columns to sum on.
146147
:param list where: is a list of expression lists.
@@ -182,22 +183,17 @@ def report(self, scope=None, groups=None, metrics=None, where=None, from_=None,
182183
raise MissingArgumentError('Either `groups` or `metrics` have to be set.')
183184

184185
if scope is None:
185-
for i in report_json.get('groups', []) + report_json.get('metrics', []):
186-
if '_network' in i:
187-
scope = 'network'
188-
break
189-
else:
190-
user = self.user
191-
if len(user.networks) > 0:
192-
pass # user has network access so could be any report (leave scope as None)
193-
elif len(user.publishers) > 0 and len(user.advertisers) == 0:
194-
scope = 'publishers'
195-
elif len(user.advertisers) > 0 and len(user.publishers) == 0:
196-
scope = 'advertisers'
197-
198-
if scope is None:
199-
raise MissingArgumentError('Unable to detect scope automatically. '
200-
'Please set `scope` parameter.')
186+
user = self.user
187+
if len(user.networks) > 0:
188+
pass # user has network access so could be any report (leave scope as None)
189+
elif len(user.publishers) > 0 and len(user.advertisers) == 0:
190+
scope = 'publishers'
191+
elif len(user.advertisers) > 0 and len(user.publishers) == 0:
192+
scope = 'advertisers'
193+
194+
if scope is None:
195+
raise MissingArgumentError('Unable to detect scope automatically. '
196+
'Please set `scope` parameter.')
201197
report_json['scope'] = scope
202198

203199
if where:

0 commit comments

Comments
 (0)