Skip to content

Commit

Permalink
metrics: .format -> f-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
yashlamba committed Sep 18, 2023
1 parent e6288eb commit 51fafa0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion site/zenodo_rdm/metrics/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def get_uptime():
url,
json={
"api_key": api_key,
"custom_uptime_ranges": "{}_{}".format(start_ts, end_ts),
"custom_uptime_ranges": f"{start_ts}_{end_ts}",
},
)

Expand Down
4 changes: 2 additions & 2 deletions site/zenodo_rdm/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


def get_metrics(metric_id):
cached_data = current_cache.get("ZENODO_METRICS_CACHE::{}".format(metric_id))
cached_data = current_cache.get(f"ZENODO_METRICS_CACHE::{metric_id}")
if cached_data is not None:
return cached_data

Expand All @@ -27,7 +27,7 @@ def calculate_metrics(metric_id, cache=True):

if cache:
current_cache.set(
"ZENODO_METRICS_CACHE::{}".format(metric_id),
f"ZENODO_METRICS_CACHE::{metric_id}",
result,
timeout=current_app.config["ZENODO_METRICS_CACHE_TIMEOUT"],
)
Expand Down
4 changes: 1 addition & 3 deletions site/zenodo_rdm/metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ def metrics(metric_id):
tasks.calculate_metrics.delay(metric_id)
retry_after = current_app.config["ZENODO_METRICS_CACHE_UPDATE_INTERVAL"]
return Response(
"Metrics not available. Try again after {}.".format(
humanize.naturaldelta(retry_after)
),
f"Metrics not available. Try again after {humanize.naturaldelta(retry_after)}.",
status=503,
headers={"Retry-After": int(retry_after.total_seconds())},
)

0 comments on commit 51fafa0

Please sign in to comment.