Skip to content

Commit

Permalink
Cleaner version display format (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandenburgh authored Sep 16, 2024
1 parent 8c4d06a commit a192807
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 13 deletions.
49 changes: 37 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ beautifulsoup4 = "^4.12.3"
django-allauth = {extras = ["socialaccount"], version = "^0.63.2"}
django-login-required-middleware = "^0.9.0"
django-s3-file-field = {version = "^1.0.1", extras = ["s3"]}
parver = "^0.5"

[tool.poetry.group.dev.dependencies]
django-stubs = "^4.2.7"
Expand Down
13 changes: 12 additions & 1 deletion rdwatch/core/views/server_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any

from ninja import Field, Router, Schema
from parver import Version

from django.http import HttpRequest

Expand Down Expand Up @@ -40,6 +41,16 @@ def get_status(request: HttpRequest):
hostname = socket.gethostname()
ip = socket.gethostbyname(hostname)

parsed_version = Version.parse(api.version)

version = 'v'
version += '.'.join(str(v) for v in parsed_version.release)

# If this is a pre-release version, include the pre-release version string
post_num: int | None = parsed_version.post
if post_num is not None:
version += f'.post{post_num}+{parsed_version.local}'

try:
smartflow_status = SmartFlowClient().get_health().to_dict()
except Exception:
Expand All @@ -49,6 +60,6 @@ def get_status(request: HttpRequest):
uptime=uptime,
hostname=hostname,
ip=ip,
rdwatch_version=api.version,
rdwatch_version=version,
smartflow=smartflow_status,
)

0 comments on commit a192807

Please sign in to comment.