Skip to content

Commit cf6f4c1

Browse files
authored
Merge pull request #287 from cmu-delphi/sir-dryrun
[sir-complainsalot] Add grace period and dry run
2 parents d357d01 + 9b48cce commit cf6f4c1

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

sir_complainsalot/delphi_sir_complainsalot/check_source.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def to_md(self):
2626
source=self.data_source, signal=self.signal, geos=", ".join(self.geo_types),
2727
message=self.message, updated=self.last_updated.strftime("%Y-%m-%d"))
2828

29-
def check_source(data_source, meta, params):
29+
def check_source(data_source, meta, params, grace):
3030
"""Iterate over all signals from a source and check if they exceed max age."""
3131

3232
source_config = params[data_source]
@@ -44,7 +44,7 @@ def check_source(data_source, meta, params):
4444

4545
age = (now - row["max_time"]).days
4646

47-
if age > source_config["max_age"]:
47+
if age > source_config["max_age"] + grace:
4848
if row["signal"] not in complaints:
4949
complaints[row["signal"]] = Complaint(
5050
"is more than {age} days old".format(age=age),

sir_complainsalot/delphi_sir_complainsalot/run.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def run_module():
2222

2323
complaints = []
2424
for data_source in params["sources"].keys():
25-
complaints.extend(check_source(data_source, meta, params["sources"]))
25+
complaints.extend(check_source(data_source, meta, params["sources"], params.get("grace",0)))
2626

2727
if len(complaints) > 0:
2828
for complaint in complaints:
@@ -34,6 +34,9 @@ def run_module():
3434

3535
def report_complaints(complaints, params):
3636
"""Post complaints to Slack."""
37+
if not params["slack_token"]:
38+
print("\b (dry-run)")
39+
return
3740

3841
blocks = format_complaints(complaints)
3942

0 commit comments

Comments
 (0)