Add stats for dropped purchases
This commit is contained in:
parent
780a04d13f
commit
7517bf5f37
|
@ -3,6 +3,7 @@
|
|||
## New
|
||||
* Render notes as Markdown
|
||||
* Require login by default
|
||||
* Add stats for dropped purchases
|
||||
|
||||
## Improved
|
||||
* mark refunded purchases red on game overview
|
||||
|
|
|
@ -86,6 +86,12 @@
|
|||
{{ all_purchased_refunded_this_year_count }} ({{ refunded_percent }}%)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-2 sm:px-4 md:px-6 md:py-2">Dropped</td>
|
||||
<td class="px-2 sm:px-4 md:px-6 md:py-2 font-mono">
|
||||
{{ dropped_count }} ({{ dropped_percentage }}%)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-2 sm:px-4 md:px-6 md:py-2">Unfinished</td>
|
||||
<td class="px-2 sm:px-4 md:px-6 md:py-2 font-mono">
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
{% for session in sessions %}
|
||||
{% partialdef session-info inline=True %}
|
||||
<li class="sm:pl-2 mt-4 mb-2 dark:text-slate-400 flex items-center space-x-1">
|
||||
{{ session.timestamp_start | date:"d/m/Y H:m" }}
|
||||
{{ session.timestamp_start | date:"d/m/Y H:m" }}{% if session.timestamp_end %}-{{ session.timestamp_end | date:"H:m" }}{% endif %}
|
||||
({{ session.device.get_type_display | default:"Unknown" }}, {{ session.duration_formatted }})
|
||||
{% url 'edit_session' session.id as edit_url %}
|
||||
{% include 'components/edit_button.html' with edit_url=edit_url %}
|
||||
|
|
|
@ -389,13 +389,23 @@ def stats(request, year: int = 0):
|
|||
)
|
||||
this_year_purchases_refunded = this_year_purchases_with_currency.refunded()
|
||||
|
||||
this_year_purchases_unfinished = (
|
||||
this_year_purchases_unfinished_dropped_nondropped = (
|
||||
this_year_purchases_without_refunded.filter(date_finished__isnull=True)
|
||||
.filter(date_dropped__isnull=True)
|
||||
.filter(infinite=False)
|
||||
.filter(Q(type=Purchase.GAME) | Q(type=Purchase.DLC))
|
||||
) # do not count battle passes etc.
|
||||
|
||||
this_year_purchases_unfinished = (
|
||||
this_year_purchases_unfinished_dropped_nondropped.filter(
|
||||
date_dropped__isnull=True
|
||||
)
|
||||
)
|
||||
this_year_purchases_dropped = (
|
||||
this_year_purchases_unfinished_dropped_nondropped.filter(
|
||||
date_dropped__isnull=False
|
||||
)
|
||||
)
|
||||
|
||||
this_year_purchases_without_refunded_count = (
|
||||
this_year_purchases_without_refunded.count()
|
||||
)
|
||||
|
@ -475,6 +485,12 @@ def stats(request, year: int = 0):
|
|||
|
||||
all_purchased_this_year_count = this_year_purchases_with_currency.count()
|
||||
all_purchased_refunded_this_year_count = this_year_purchases_refunded.count()
|
||||
|
||||
this_year_purchases_dropped_count = this_year_purchases_dropped.count()
|
||||
this_year_purchases_dropped_percentage = int(
|
||||
safe_division(this_year_purchases_dropped_count, all_purchased_this_year_count)
|
||||
* 100
|
||||
)
|
||||
context = {
|
||||
"total_hours": format_duration(
|
||||
this_year_sessions.total_duration_unformatted(), "%2.0H"
|
||||
|
@ -513,6 +529,8 @@ def stats(request, year: int = 0):
|
|||
"purchased_unfinished": this_year_purchases_unfinished,
|
||||
"purchased_unfinished_count": this_year_purchases_unfinished_count,
|
||||
"unfinished_purchases_percent": this_year_purchases_unfinished_percent,
|
||||
"dropped_count": this_year_purchases_dropped_count,
|
||||
"dropped_percentage": this_year_purchases_dropped_percentage,
|
||||
"refunded_percent": int(
|
||||
safe_division(
|
||||
all_purchased_refunded_this_year_count,
|
||||
|
|
Loading…
Reference in New Issue