Skip to content

Commit

Permalink
Merge pull request #8 from andela/ft-increase-timeouts-and-grace-peri…
Browse files Browse the repository at this point in the history
…ods-#155965539

#155965539 Increase set timeouts and grace values for days exceeding 30
  • Loading branch information
georgreen committed Apr 11, 2018
2 parents 6ec2244 + dc9237a commit 9b00f8c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
4 changes: 2 additions & 2 deletions hc/api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"properties": {
"name": {"type": "string"},
"tags": {"type": "string"},
"timeout": {"type": "number", "minimum": 60, "maximum": 604800},
"grace": {"type": "number", "minimum": 60, "maximum": 604800},
"timeout": {"type": "number", "minimum": 60, "maximum": 5184000},
"grace": {"type": "number", "minimum": 60, "maximum": 5184000},
"channels": {"type": "string"}
}
}
4 changes: 2 additions & 2 deletions hc/front/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def clean_tags(self):


class TimeoutForm(forms.Form):
timeout = forms.IntegerField(min_value=60, max_value=2592000)
grace = forms.IntegerField(min_value=60, max_value=2592000)
timeout = forms.IntegerField(min_value=60, max_value=29030400)
grace = forms.IntegerField(min_value=60, max_value=29030400)


class AddChannelForm(forms.ModelForm):
Expand Down
4 changes: 3 additions & 1 deletion hc/front/templatetags/hc_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ def __init__(self, name, nsecs):
HOUR = Unit("hour", MINUTE.nsecs * 60)
DAY = Unit("day", HOUR.nsecs * 24)
WEEK = Unit("week", DAY.nsecs * 7)
MONTH = Unit("month", WEEK.nsecs * 4)
YEAR = Unit("year", MONTH.nsecs * 12)


@register.filter
def hc_duration(td):
remaining_seconds = int(td.total_seconds())
result = []

for unit in (WEEK, DAY, HOUR, MINUTE):
for unit in (YEAR, MONTH,WEEK, DAY, HOUR, MINUTE):
if unit == WEEK and remaining_seconds % unit.nsecs != 0:
# Say "8 days" instead of "1 week 1 day"
continue
Expand Down
6 changes: 3 additions & 3 deletions hc/front/tests/test_hc_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def test_hc_duration_works(self):
(3660, "1 hour 1 minute"),
(86400, "1 day"),
(604800, "1 week"),
(2419200, "4 weeks"),
(2592000, "30 days"),
(3801600, "44 days")
(2419200, "1 month"),
(14515200, "6 months"),
(29030400, "1 year")
]

for seconds, expected_result in samples:
Expand Down
30 changes: 17 additions & 13 deletions static/js/checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ $(function () {
var HOUR = {name: "hour", nsecs: MINUTE.nsecs * 60};
var DAY = {name: "day", nsecs: HOUR.nsecs * 24};
var WEEK = {name: "week", nsecs: DAY.nsecs * 7};
var UNITS = [WEEK, DAY, HOUR, MINUTE];
var MONTH = {name: "month", nsecs: WEEK.nsecs * 4};
var YEAR = {name: "year", nsecs: MONTH.nsecs * 12};
var UNITS = [YEAR, MONTH, WEEK, DAY, HOUR, MINUTE];

var secsToText = function(total) {
var remainingSeconds = Math.floor(total);
Expand Down Expand Up @@ -32,18 +34,19 @@ $(function () {

var periodSlider = document.getElementById("period-slider");
noUiSlider.create(periodSlider, {
start: [20],
start: [5],
connect: "lower",
range: {
'min': [60, 60],
'33%': [3600, 3600],
'66%': [86400, 86400],
'83%': [604800, 604800],
'max': 2592000,
'20%': [3600, 3600],
'40%': [86400, 86400],
'60%': [604800, 604800],
'75%': [2419200, 2419200],
'max': 29030400,
},
pips: {
mode: 'values',
values: [60, 1800, 3600, 43200, 86400, 604800, 2592000],
values: [60, 3600, 86400, 604800, 2419200, 29030400],
density: 4,
format: {
to: secsToText,
Expand All @@ -61,18 +64,19 @@ $(function () {

var graceSlider = document.getElementById("grace-slider");
noUiSlider.create(graceSlider, {
start: [20],
start: [0],
connect: "lower",
range: {
'min': [60, 60],
'33%': [3600, 3600],
'66%': [86400, 86400],
'83%': [604800, 604800],
'max': 2592000,
'20%': [3600, 3600],
'40%': [86400, 86400],
'60%': [604800, 604800],
'75%': [2419200, 2419200],
'max': 29030400,
},
pips: {
mode: 'values',
values: [60, 1800, 3600, 43200, 86400, 604800, 2592000],
values: [60, 3600, 86400, 604800, 2419200, 29030400],
density: 4,
format: {
to: secsToText,
Expand Down
1 change: 1 addition & 0 deletions templates/front/my_checks.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ <h4 class="update-timeout-title">Name and Tags</h4>
1 day
</span>
</div>

<div id="period-slider"></div>

<div class="update-timeout-info text-center">
Expand Down

0 comments on commit 9b00f8c

Please sign in to comment.