diff --git a/README.md b/README.md index d521144..8d149e8 100644 --- a/README.md +++ b/README.md @@ -249,6 +249,8 @@ run_migration | `EXPORTER_CLICKHOUSE_DATABASE` | ❌ | `agile` | Database for exporter CH tables | | `EXPORTER_CLICKHOUSE_ISSUES_TABLE` | ❌ | `issues` | Table when store issues metadata | | `EXPORTER_CLICKHOUSE_ISSUE_METRICS_TABLE` | ❌ | `issue_metrics` | Table when store issue metrics | +| `EXPORTER_WORKHOURS_START` | ❌ | 9 | The beginning of working hours for calculating business hour metrics | +| `EXPORTER_WORKHOURS_END` | ❌ | 22 | The end of working hours for calculating business hour metrics | # Monitoring diff --git a/tracker_exporter/defaults.py b/tracker_exporter/defaults.py index 3186af0..a021276 100644 --- a/tracker_exporter/defaults.py +++ b/tracker_exporter/defaults.py @@ -6,9 +6,13 @@ UPLOAD_TO_STORAGE = os.environ.get("EXPORTER_ENABLE_UPLOAD", "false").lower() in ("true", "yes") # Business days settings -BUSINESS_HOURS_START = dt.time(9) -BUSINESS_HOURS_END = dt.time(22) WORKDAYS = [0, 1, 2, 3, 4] # From Monday to Friday +try: + BUSINESS_HOURS_START = dt.time(int(os.environ.get("EXPORTER_WORKHOURS_START", "9"))) + BUSINESS_HOURS_END = dt.time(int(os.environ.get("EXPORTER_WORKHOURS_END", "22"))) +except (ValueError, TypeError): + BUSINESS_HOURS_START = dt.time(9) + BUSINESS_HOURS_END = dt.time(22) # Monitoring settings MONITORING_ENABLED = os.environ.get("EXPORTER_MONITORING_ENABLED", "false").lower() in ("true", "yes")