mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-16 04:58:01 +00:00
Return full avatar URLs instead of digests in stats
- Replace digest_sha256 with avatar_url in top_viewed_avatars - Replace digest_sha256 with avatar_url in top_queried_emails - Replace digest_sha256 with avatar_url in top_queried_openids - All avatar URLs now use https://libravatar.org/avatar/{digest} format - Update tests to verify avatar_url presence and correct format - All 5 stats tests pass successfully This makes the stats API more user-friendly by providing complete avatar URLs that can be directly used in applications instead of requiring clients to construct the URLs themselves.
This commit is contained in:
@@ -160,6 +160,14 @@ class StatsTester(TestCase):
|
|||||||
100,
|
100,
|
||||||
"top avatar access count incorrect",
|
"top avatar access count incorrect",
|
||||||
)
|
)
|
||||||
|
# Check that avatar_url is present and starts with the correct base URL
|
||||||
|
self.assertIn("avatar_url", j["top_viewed_avatars"][0], "avatar_url missing")
|
||||||
|
self.assertTrue(
|
||||||
|
j["top_viewed_avatars"][0]["avatar_url"].startswith(
|
||||||
|
"https://libravatar.org/avatar/"
|
||||||
|
),
|
||||||
|
"avatar_url should start with https://libravatar.org/avatar/",
|
||||||
|
)
|
||||||
|
|
||||||
# Test top queried emails
|
# Test top queried emails
|
||||||
self.assertIn("top_queried_emails", j, "top_queried_emails missing")
|
self.assertIn("top_queried_emails", j, "top_queried_emails missing")
|
||||||
@@ -171,6 +179,14 @@ class StatsTester(TestCase):
|
|||||||
100,
|
100,
|
||||||
"top email access count incorrect",
|
"top email access count incorrect",
|
||||||
)
|
)
|
||||||
|
# Check that avatar_url is present and starts with the correct base URL
|
||||||
|
self.assertIn("avatar_url", j["top_queried_emails"][0], "avatar_url missing")
|
||||||
|
self.assertTrue(
|
||||||
|
j["top_queried_emails"][0]["avatar_url"].startswith(
|
||||||
|
"https://libravatar.org/avatar/"
|
||||||
|
),
|
||||||
|
"avatar_url should start with https://libravatar.org/avatar/",
|
||||||
|
)
|
||||||
|
|
||||||
# Test top queried openids
|
# Test top queried openids
|
||||||
self.assertIn("top_queried_openids", j, "top_queried_openids missing")
|
self.assertIn("top_queried_openids", j, "top_queried_openids missing")
|
||||||
@@ -182,6 +198,14 @@ class StatsTester(TestCase):
|
|||||||
75,
|
75,
|
||||||
"top openid access count incorrect",
|
"top openid access count incorrect",
|
||||||
)
|
)
|
||||||
|
# Check that avatar_url is present and starts with the correct base URL
|
||||||
|
self.assertIn("avatar_url", j["top_queried_openids"][0], "avatar_url missing")
|
||||||
|
self.assertTrue(
|
||||||
|
j["top_queried_openids"][0]["avatar_url"].startswith(
|
||||||
|
"https://libravatar.org/avatar/"
|
||||||
|
),
|
||||||
|
"avatar_url should start with https://libravatar.org/avatar/",
|
||||||
|
)
|
||||||
|
|
||||||
# Test photo format distribution
|
# Test photo format distribution
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
|
|||||||
@@ -589,7 +589,7 @@ class StatsView(TemplateView, JsonResponse):
|
|||||||
top_photos_data.append(
|
top_photos_data.append(
|
||||||
{
|
{
|
||||||
"access_count": top_associated.access_count,
|
"access_count": top_associated.access_count,
|
||||||
"digest_sha256": top_associated.digest_sha256,
|
"avatar_url": f"https://libravatar.org/avatar/{top_associated.digest_sha256}",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -597,7 +597,7 @@ class StatsView(TemplateView, JsonResponse):
|
|||||||
top_photos_data.append(
|
top_photos_data.append(
|
||||||
{
|
{
|
||||||
"access_count": top_associated.access_count,
|
"access_count": top_associated.access_count,
|
||||||
"digest_sha256": top_associated.digest,
|
"avatar_url": f"https://libravatar.org/avatar/{top_associated.digest}",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -610,7 +610,7 @@ class StatsView(TemplateView, JsonResponse):
|
|||||||
top_emails_data.append(
|
top_emails_data.append(
|
||||||
{
|
{
|
||||||
"access_count": email.access_count,
|
"access_count": email.access_count,
|
||||||
"digest_sha256": email.digest_sha256,
|
"avatar_url": f"https://libravatar.org/avatar/{email.digest_sha256}",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -623,7 +623,7 @@ class StatsView(TemplateView, JsonResponse):
|
|||||||
top_openids_data.append(
|
top_openids_data.append(
|
||||||
{
|
{
|
||||||
"access_count": openid.access_count,
|
"access_count": openid.access_count,
|
||||||
"digest_sha256": openid.digest,
|
"avatar_url": f"https://libravatar.org/avatar/{openid.digest}",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user