Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/sentry/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from sentry.search.utils import parse_datetime_string, InvalidQuery
from sentry.utils.dates import parse_stats_period

MIN_STATS_PERIOD = timedelta(hours=1)

MAX_STATS_PERIOD = timedelta(days=90)
# make sure to update this message if you are changing the min/max period
INVALID_PERIOD_ERROR = 'Time window must be greater than an hour and less than or equal to 90 days'
# make sure to update this message if you are changing the max period
INVALID_PERIOD_ERROR = 'Time window must be less than or equal to 90 days'


class InvalidParams(Exception):
Expand Down Expand Up @@ -81,7 +81,7 @@ def get_date_range_from_params(params, optional=False, validate_window=True):

if validate_window:
delta = end - start
if delta < MIN_STATS_PERIOD or delta > MAX_STATS_PERIOD:
if delta > MAX_STATS_PERIOD:
raise InvalidParams(INVALID_PERIOD_ERROR)

return start, end
2 changes: 1 addition & 1 deletion tests/sentry/api/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_stats_period(self):
assert end - datetime.timedelta(seconds=3600) == start

with self.assertRaises(InvalidParams):
get_date_range_from_params({'statsPeriod': '1s'})
get_date_range_from_params({'statsPeriod': '91d'})

def test_date_range(self):
start, end = get_date_range_from_params({
Expand Down