Fixed visits with loading screen
All checks were successful
Build on push / build-redirector (push) Successful in 29s
Build on push / build-api (push) Successful in 30s
Build on push / build-web (push) Successful in 1m6s

This commit is contained in:
Sven Heidemann 2025-01-10 13:18:38 +01:00
parent 5f4d4aeb73
commit 0285b95518
2 changed files with 8 additions and 4 deletions

View File

@ -40,6 +40,8 @@ async def _handle_request(path: str):
return await _handle_short_url(path, short_url)
if short_url.loading_screen:
await _track_visit(short_url)
return render_template(
"redirect.html",
key=short_url.short_url,
@ -53,6 +55,11 @@ async def _handle_short_url(path: str, short_url: ShortUrl):
if path.startswith("api/"):
path = path.replace("api/", "")
await _track_visit(short_url)
return _do_redirect(short_url.target_url)
async def _track_visit(short_url: ShortUrl):
try:
await shortUrlVisitDao.create(
ShortUrlVisit(0, short_url.id, request.headers.get("User-Agent"))
@ -60,9 +67,6 @@ async def _handle_short_url(path: str, short_url: ShortUrl):
except Exception as e:
logger.error(f"Failed to update short url {short_url.short_url} with error", e)
return _do_redirect(short_url.target_url)
async def _find_short_url_by_url(url: str) -> ShortUrl:
return await shortUrlDao.find_single_by({ShortUrl.short_url: url})

View File

@ -1 +1 @@
1.0.0
1.0.1