-
-
Notifications
You must be signed in to change notification settings - Fork 234
Description
There is a data inconsistency in the display of page views: the bottom left widget and the homepage display different page view totals during the hackathon. Both areas should present the same page view count for clarity and accuracy.
Bug Details:
- The homepage stats card (top right) shows a different total page view count than the bottom left widget.
- Example: The homepage reports "Page Views: 40" while the bottom left widget shows "Total: 64 Views" (see attached screenshot).

Root cause investigation (code references):
- Page view logic in
website/templates/includes/page_stats.html
uses{% get_page_views current_url_path 30 as page_views %}
via the custom Django tag:# website/templatetags/custom_tags.py @register.simple_tag
def get_page_views(url_path, days=30):
...
# Get views for the given url_path for the last N days
daily_views = (
IP.objects.filter(path__contains=url_path, created__gte=start_date, created__lte=end_date)
.values("created__date")
.annotate(total_views=models.Sum("count"))
.order_by("created__date")
)
...
return json.dumps(view_counts_dict)
- Homepage card likely aggregates views site-wide, while the widget aggregates by URL path.
- Homepage stats from `website/views/core.py`:
```python
# website/views/core.py
def website_stats(request):
...
# Calculate total views
total_views = sum(view_stats.values())
...
context = {
"url_info": url_info,
"total_views": total_views,
"web_stats": web_stats,
...
}
return render(request, "website_stats.html", context)
- Widget JS pulls from page_views data for the current path, not site-wide.
Suggested Fix:
- Make both the homepage card and the widget use the same total page view aggregation logic (preferably site-wide for hackathon clarity).
- Refactor the widget to use the same
total_views
value as the homepage card. Consider updatingget_page_views
or passing site-wide stats to the widget. - Ensure both use the same queryset and summing logic for the last 30 days.
Relevant code snippets:
- website/templates/includes/page_stats.html
- website/views/core.py
- website/templatetags/custom_tags.py
Acceptance Criteria:
- The page view count in the homepage card and bottom left widget always matches for the same time period.
- All display logic uses consistent aggregation (ideally site-wide, not per-path).
- Only Tailwind CSS is used (no inline styles).
- Use Poetry for any dependency management.
- If the root cause is not fixed in the first attempt, add debugging and try again.
- No exceptions should be shown in user-facing error messages; instead, provide detailed descriptions.
Please investigate the aggregation logic and update both components to ensure page view numbers match.
Files likely involved:
website/templates/includes/page_stats.html
website/views/core.py
website/templatetags/custom_tags.py
- Any JS files for widget chart logic (should not be inline in HTML)
References:
Metadata
Metadata
Assignees
Type
Projects
Status