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

Commit 23da536

Browse files
committed
Add daterange parameter to :meth:atomx.Atomx.report
1 parent 4a54f68 commit 23da536

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

CHANGES.txt

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

44
- Add ``editable`` parameter to :meth:`atomx.Atomx.report`.
5+
- Add ``dsp`` reporting scope.
6+
- Add ``daterange`` parameter to :meth:`atomx.Atomx.report`.
57

68

79
1.6
@@ -22,6 +24,7 @@
2224
* :class:`atomx.models.Timezone`
2325
* :class:`atomx.models.Zipcode`
2426

27+
2528
1.5
2629
---
2730

atomx/__init__.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,18 @@ def search(self, query, index=None):
144144
for v in search_result[m]]
145145
return search_result
146146

147-
def report(self, scope=None, groups=None, metrics=None, where=None, from_=None, to=None,
148-
timezone='UTC', emails=None, when=None, interval=None, name=None,
147+
def report(self, scope=None, groups=None, metrics=None, where=None,
148+
from_=None, to=None, daterange=None, timezone='UTC',
149+
emails=None, when=None, interval=None, name=None,
149150
sort=None, limit=None, offset=None, save=True, editable=False):
150151
"""Create a report.
151152
152153
See the `reporting atomx wiki <https://wiki.atomx.com/reporting>`_
153154
for details about parameters and available groups, metrics.
154155
155156
:param str scope: Specifies the report type. Should be one of:
156-
'advertiser', 'publisher', 'network_managed', 'network_buy', 'network_sell'.
157+
'advertiser', 'publisher', 'inventory', 'dsp',
158+
'network_managed', 'network_buy', 'network_sell'.
157159
If undefined it tries to determine the `scope` automatically based
158160
on the access rights of the api user.
159161
:param list groups: columns to group by.
@@ -167,10 +169,15 @@ def report(self, scope=None, groups=None, metrics=None, where=None, from_=None,
167169
and ``not in`` a list of numbers.
168170
169171
:param datetime.datetime from_: :class:`datetime.datetime` where the report
170-
should start (inclusive). (defaults to last week)
172+
should start (inclusive). (Defaults to last week)
171173
:param datetime.datetime to: :class:`datetime.datetime` where the report
172-
should end (exclusive). (defaults to `datetime.now()` if undefined)
173-
:param str timezone: Timezone used for all times. (defaults to `UTC`)
174+
should end (exclusive). (Defaults to `datetime.now()` if undefined)
175+
:param str daterange: Use :param:`daterange` to automatically set the reports
176+
`from` and `to` parameters relativ to the current date.
177+
Both :param:`from_` and :param:`to` have to be ``None`` for it.
178+
Dateranges are: today, yesterday, last7days, last14days, last30days, monthtodate,
179+
lastmonth, yeartodate, lifetime. (Defaults to ``None``)
180+
:param str timezone: Timezone used for all times. (Defaults to `UTC`)
174181
For a supported list see https://wiki.atomx.com/timezones
175182
:param emails: One or multiple email addresses that should get
176183
notified once the report is finished and ready to download.
@@ -217,7 +224,9 @@ def report(self, scope=None, groups=None, metrics=None, where=None, from_=None,
217224
report_json['when'] = when
218225
report_json['interval'] = interval
219226

220-
else: # normal report
227+
elif not from_ and not to and daterange: # Rolling report
228+
report_json['daterange'] = daterange
229+
else: # Normal report
221230
if from_ is None:
222231
from_ = datetime.now() - timedelta(days=7)
223232
if isinstance(from_, datetime):

0 commit comments

Comments
 (0)