Skip to content

Commit

Permalink
stats on label size popularity
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Oct 17, 2024
1 parent b886953 commit ab23236
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
12 changes: 10 additions & 2 deletions auctions/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,16 @@ <h3>Admin Dashboard</h3>
</td>
</tr>
<tr>
<td>Printed invoices:</td>
<td> {{ printed_invoices }} / {{ total_invoices }} ({{invoice_percent|floatformat:2}}%)
<td>User with printed labels</td>
<td> {{ users_with_printed_labels }}
</td>
</tr>
<tr>
<td>Label preset usage:</td>
<td>
{% for preset in preset_counts %}
{{ preset.preset }}: {{ preset.count }}<br>
{% endfor %}
</td>
</tr>
<tr>
Expand Down
24 changes: 16 additions & 8 deletions auctions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5340,14 +5340,14 @@ def get_context_data(self, **kwargs):
context["feedback_last_30_days"] = (
Lot.objects.exclude(feedback_rating=0).filter(date_posted__gte=timezone.now() - timedelta(days=30)).count()
)
invoiceqs = (
Invoice.objects.filter(date__gte=datetime(2021, 6, 15, tzinfo=date_tz.utc))
.filter(seller_invoice__winner__isnull=False)
.distinct()
)
context["total_invoices"] = invoiceqs.count()
context["printed_invoices"] = invoiceqs.filter(printed=True).count()
context["invoice_percent"] = context["printed_invoices"] / context["total_invoices"] * 100
# invoiceqs = (
# Invoice.objects.filter(date__gte=datetime(2021, 6, 15, tzinfo=date_tz.utc))
# .filter(seller_invoice__winner__isnull=False)
# .distinct()
# )
# context["total_invoices"] = invoiceqs.count()
# context["printed_invoices"] = invoiceqs.filter(printed=True).count()
# context["invoice_percent"] = context["printed_invoices"] / context["total_invoices"] * 100
context["users_with_search_history"] = User.objects.filter(searchhistory__isnull=False).distinct().count()
# source of lot images?
activity = (
Expand Down Expand Up @@ -5401,6 +5401,14 @@ def get_context_data(self, **kwargs):
context["online_auction_lots_ending"] = Lot.objects.filter(
is_deleted=False, date_end__lte=timeframe, date_end__gte=timezone.now()
).count()
users_with_printed_labels = User.objects.filter(lot__label_printed=True).distinct()
context["users_with_printed_labels"] = users_with_printed_labels.count()
context["preset_counts"] = (
UserLabelPrefs.objects.filter(user__in=users_with_printed_labels)
.values("preset")
.annotate(count=Count("user"))
.order_by("-count")
)
return context


Expand Down

0 comments on commit ab23236

Please sign in to comment.