diff --git a/openlibrary/core/admin.py b/openlibrary/core/admin.py
index 86369d8012e..ba6bf350431 100644
--- a/openlibrary/core/admin.py
+++ b/openlibrary/core/admin.py
@@ -99,7 +99,7 @@ def get_counts(self, ndays=28, times=False):
@cache.memoize(engine="memcache", key="admin._get_visitor_counts_from_graphite", expires=5 * 60)
-def _get_visitor_counts_from_graphite(self, ndays: int = 28) -> list[list[int]]:
+def _get_visitor_counts_from_graphite(ndays: int = 28) -> list[list[int]]:
"""
Read the unique visitors (IP addresses) per day for the last ndays from graphite.
:param ndays: number of days to read
@@ -114,6 +114,7 @@ def _get_visitor_counts_from_graphite(self, ndays: int = 28) -> list[list[int]]:
"tz": "UTC",
"format": "json",
},
+ timeout=5,
)
response.raise_for_status()
visitors = response.json()[0]["datapoints"]
diff --git a/openlibrary/templates/admin/index.html b/openlibrary/templates/admin/index.html
index 3eaa77af901..1f6f9c60953 100644
--- a/openlibrary/templates/admin/index.html
+++ b/openlibrary/templates/admin/index.html
@@ -245,8 +245,10 @@
$_("Members")
- $_("Unique Visitors")
-
+ $# Conditional check since the graphite source is currently unreliable, hiding the stat when it returns nothing
+ $if counts.get("visitors") and counts["visitors"].get_summary(28):
+ $_("Unique Visitors")
+
$_("Borrows")
diff --git a/openlibrary/templates/home/stats.html b/openlibrary/templates/home/stats.html
index b9255f92b55..aa913c8523e 100644
--- a/openlibrary/templates/home/stats.html
+++ b/openlibrary/templates/home/stats.html
@@ -7,43 +7,39 @@ $_('Around the Library')
-
-
+ $# Conditional check since the graphite source is currently unreliable, hiding the stat when it returns nothing
+ $if stats["visitors"].get_summary(28):
+
-
-
-
+
-
-
+
+
-
-
+ $# Conditional check since the graphite source is currently unreliable, hiding the stat when it returns nothing
+ $if stats["visitors"].get_summary(28):
+
diff --git a/static/css/components/home.css b/static/css/components/home.css
index e04bb83b942..2b1aafff902 100644
--- a/static/css/components/home.css
+++ b/static/css/components/home.css
@@ -55,26 +55,20 @@ div.chartHome a:hover,
#home-stats-charts {
display: flex;
flex-wrap: wrap;
+ justify-content: space-between;
}
#home-stats-charts .statschart {
- flex: 1;
height: 110px;
text-align: center;
- padding: 1px;
+ margin: 0 var(--spacing-inline-sm);
+ cursor: pointer;
}
-/* stylelint-disable-next-line max-nesting-depth */
-#home-stats-charts .statschart .chartShow {
- width: 145px;
- height: 60px;
- margin: 0 var(--spacing-inline-sm);
+#home-stats-charts .statschart div {
border-bottom: 1px solid var(--grey);
- cursor: pointer;
}
-/* stylelint-disable no-descending-specificity */
-/* stylelint-disable max-nesting-depth */
#home-stats-charts .statschart a {
color: var(--black);
text-decoration: none;
@@ -97,8 +91,6 @@ div.chartHome a:hover,
font-size: 0.625em;
text-transform: uppercase;
}
-/* stylelint-enable no-descending-specificity */
-/* stylelint-enable max-nesting-depth */
#home-resource {
font-size: 13px;