diff --git a/CHANGELOG.md b/CHANGELOG.md
index b7978c3..e1498a0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/games/templates/stats.html b/games/templates/stats.html
index 0be97dd..1b664ce 100644
--- a/games/templates/stats.html
+++ b/games/templates/stats.html
@@ -86,6 +86,12 @@
{{ all_purchased_refunded_this_year_count }} ({{ refunded_percent }}%)
+
+ Dropped |
+
+ {{ dropped_count }} ({{ dropped_percentage }}%)
+ |
+
Unfinished |
diff --git a/games/templates/view_game.html b/games/templates/view_game.html
index 66edefe..ca0cbde 100644
--- a/games/templates/view_game.html
+++ b/games/templates/view_game.html
@@ -75,7 +75,7 @@
{% for session in sessions %}
{% partialdef session-info inline=True %}
- {{ 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 %}
diff --git a/games/views.py b/games/views.py
index 6cb8387..3f8399c 100644
--- a/games/views.py
+++ b/games/views.py
@@ -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,
|